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

    Active Objects - Change attributes

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 422 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 03/06/2017 at 19:51, xxxxxxxx wrote:

      Hello!

      I'm trying to change some attributes from a different objects at the same time, in this case I'm trying to change "use color" and "display color" attribute for testing with that.

      When I use the code with one object works fine but if the object have some children objects the console shows me "IndexError: list assignment index out of range" but I don't understand why, because I've use a GetActiveObjects with a c4d.GetActiveObject_Children flag.

      I need to get the entire objects selection with other way maybe? Here is the code:

      import c4d
      from c4d import gui
        
      def geo_color() :
          doc = c4d.documents.GetActiveDocument()
          #activeObject = doc.GetActiveObject()
          activeObject = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
          
          #List of selected objects
          print activeObject
          
          #geo color actions
          activeObject[c4d.ID_BASEOBJECT_USECOLOR]=2
          #cdlg = c4d.gui.ColorDialog(1)
          #activeObject[c4d.ID_BASEOBJECT_COLOR]=cdlg
        
          #update scene
          c4d.EventAdd()
         
       
      if __name__=='__main__':
          geo_color()
      

      Thanks!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 04/06/2017 at 00:10, xxxxxxxx wrote:

        Get activeObjects return you a list of BaseList2D So you have to iterate throught this list basicly do

        import c4d
          
        def geo_color() :
            doc = c4d.documents.GetActiveDocument()
            activeObjects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
            #If we get nothing select we quit
            if not activeObjects:
                return
          
            #Loop through the content of activeObjects and call each element of activeObjects obj
            #obj are BaseList2D so we can set their value
            for obj in activeObjects:
                obj[c4d.ID_BASEOBJECT_USECOLOR] = 2
          
            # update scene
            c4d.EventAdd()
          
          
        if __name__ == '__main__':
            geo_color()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 12/06/2017 at 14:54, xxxxxxxx wrote:

          Thanks! That's make sense.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post