Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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. bergerac14
    3. Posts
    B
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by bergerac14

    • RE: Commiting Xrefs to the scene

      No worries - i solved it with a call command in the end. It would be good to know how to commit xref materials to the scene as well though.

      posted in Cinema 4D SDK
      B
      bergerac14
    • Commiting Xrefs to the scene

      Hey!

      Im looking to make a simple script that commits all xrefs to the scene before sending it off to render. I have this working so far (it's still WIP) and is almost doing what i need - I just need to figure out how to get the materials to commit to the file too.

      Im basically trying to emulate what happens if you select and xref and hit 'c'

      Any / all info much appreciated!

      Cheers,

      C

      import c4d
      from c4d import gui, utils
      #Welcome to the world of Python
      
      
      def GetNextObj(op):
          if op==None: return None
          if op.GetDown():
              return op.GetDown()
          while not op.GetNext() and op.GetUp():
              op = op.GetUp()
          return op.GetNext()
      
      # Main function
      def main():
          obj = doc.GetFirstObject()
      
          allobjs = []
          allXrefs = []
          xRef = 1025766
      
          # Gets all objs and stores them in a list
          while GetNextObj(obj):
              allobjs.append(GetNextObj(obj))
              obj = GetNextObj(obj)
          
          print len(allobjs)
      
          for i in allobjs:
              if i.GetType() == 1025766:
                  allXrefs.append(i)
      
          res = utils.SendModelingCommand(command=c4d.MCOMMAND_MAKEEDITABLE,
      
                                          list=allXrefs,
      
                                          mode=c4d.MODELINGCOMMANDMODE_ALL,
      
                                          bc=c4d.BaseContainer(),
      
                                          doc=doc)
                                      
          doc.StartUndo() 
                      
          for i in res:
              doc.InsertObject(i)
          
      
          #for i in res:
              #doc.AddUndo(c4d.UNDOTYPE_NEW,i)
          
          #for i in allXrefs:
              #doc.AddUndo(c4d.UNDOTYPE_DELETE,i)
          
          for i in allXrefs:
              i.Remove()
          
          doc.EndUndo()
      
          c4d.EventAdd()
      
      posted in Cinema 4D SDK r21
      B
      bergerac14