Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. BackendKG
    3. Posts
    B
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by BackendKG

    • RE: xRef file path is broken if created via python

      Sorry for not making my post as clear as it should have been, next time I will do better 🙂

      The good thing is, I fixed it! The problem was how I loaded my initial master project.

      # instead of using
      c4d.documents.LoadDocument()
      
      # i replaced it with
      c4d.documents.LoadFile()
      

      ... and now my xRef works just fine!

      Thank you again!

      posted in Cinema 4D SDK
      B
      BackendKG
    • xRef file path is broken if created via python

      Hello,

      I made a simple python plugin for automated project generation in C4D 2023.1.3.
      It basically loads a 3D model, creates a xRef that points to a master project file which includes all materials and then saves the document. The idea is, to have one file where I can edit materials, which automatically transfer to all my generated projects.

      Everything works fine, except the xRef connection.
      When I open my generated project, all xRef settings are greyed out and seem to have a broken file path (even though I inserted an absolute path, it displays just the filename). The weird thing is, that all the xRef materials and objects are imported successfully, but the connection to the file is lost and won't update. When I do it manually everything works as expected.

      This post helped me a lot to set it up: https://developers.maxon.net/forum/topic/14319/does-xref-or-xref-simple-are-now-accessible-with-python

      So my code looks like this (only the important parts):

      # loading the master project
      doc = c4d.documents.LoadDocument("C:/path/to/master/project.c4d", c4d.SCENEFILTER_NONE)
      
      # creating the xref for the materials
      xref_materials = c4d.BaseObject(c4d.Oxref)
      doc.InsertObject(xref_materials)
      materialFileId = c4d.DescID(c4d.DescLevel(c4d.ID_CA_XREF_FILE, c4d.DTYPE_FILENAME, 0))
      xref_materials.SetParameter(materialFileId, "C:/path/to/material/project.c4d", c4d.DESCFLAGS_SET_USERINTERACTION)
      c4d.EventAdd()
      
      # loading the 3d model
      c4d.documents.MergeDocument(doc, "C:/path/to/model.obj", c4d.SCENEFILTER_OBJECTS)
      
      # saving the project to another location
      c4d.documents.SaveDocument(doc, "C:/path/to/target/file.c4d", c4d.SAVEDOCUMENTFLAGS_NONE, c4d.FORMAT_C4DEXPORT)
      

      I also tested different path formats like "file:///" and relative paths, but the problem persists.
      Pre configuring the xRef in a seperate C4D project file and merging that into the current project, instead of creating the xRef directly, didn't work either.
      Am I missing something?

      Thank you very much for your help,
      David

      posted in Cinema 4D SDK python 2023
      B
      BackendKG