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

    Objectdata and Bevel objects

    Cinema 4D SDK
    python r20
    2
    6
    1.4k
    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.
    • P
      pim
      last edited by

      I have a objectdata plugin with a cube and a bevel object as children.
      I put the bevel as a child under the cube and csto it to one object that is returned by GetVirtualObjects().
      0_1543588280797_0a868465-5568-4c90-a90a-d52f9d1a2da8-image.png

      But the result is not a nice bevel. It looks as if there are 2 bevels done on the cube.
      0_1543588386096_781f6edc-7209-44f6-ad60-62a5fb8b125d-image.png

      Here the code that registers the objectdata plugin.

          pluginstr = "MultiBevel v01"       
          okyn = plugins.RegisterObjectPlugin(id=PLUGIN_ID_MULTIBEVEL, str=pluginstr,
                                      g=MULTIBEVEL,
                                      description="multibevel", icon=icon,
                                      info=c4d.OBJECT_GENERATOR | c4d.OBJECT_INPUT)
      

      And here GetVirtualObjects()

          def GetVirtualObjects(self, op, hierarchyhelp):
              
              doc = op.GetDocument()
      
              if op.GetDown() is None or op.GetDown().GetNext() is None: 
                  #print "Less than 2 objects detected. Return Null."
                  return c4d.BaseObject(c4d.Onull)
      
              res = op.GetAndCheckHierarchyClone(hierarchyhelp, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_ASPOLY, True)
      
              if res['dirty'] == False:
                  return res['clone']
                  
              objA = res['clone'].GetDown()
              objBevel = op.GetDown().GetNext().GetClone()       #get Bevel object. Not returned by GetAndCheckHierarchyClone (only polygon objects)
      
              objBevel.InsertUnder(objA)
              objList = c4d.utils.SendModelingCommand(
                  command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                  list = [objA],
                  mode = c4d.MODELINGCOMMANDMODE_ALL,
                  doc = doc,
                  flags = c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE)
              if objList == False:
                  print "Error Current State to object!"  
                  return None
              
              beveledObject = objList[0]  
              return beveledObject
      
      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by r_gigante

        Hi Pim, thanks for writing us.

        With regard to the question posted, actually the modifier is indeed running twice: first of the result of the GetAndCheckHierarchyClone, the second on the object itself being parent of the modifier. Although in your code it doesn't produce the right result, I'd say that the behavior is indeed consistent on how our deformers have been conceived.

        As a workaround, if it make sense for you, you can disable the deformer running "on" the parent whilst leaving enabled the deformer insisting on the result of the GetAndCheckHierarchyClone().

        def GetVirtualObjects(self, op, hh):
            doc = op.GetDocument()
            bc = op.GetDataInstance()
        
            if op.GetDown() is None or op.GetDown().GetNext() is None: 
                #print "Less than 2 objects detected. Return Null."
                return c4d.BaseObject(c4d.Onull)
        
            source = op.GetDown()
            modifier = op.GetDown().GetNext()
            modifier.SetDeformMode(False)
        
            resGCHC = op.GetAndCheckHierarchyClone(hh, source, c4d.HIERARCHYCLONEFLAGS_ASIS, True)
        
            if resGCHC['dirty'] == False:
                return resGCHC['clone']
                
            clonedSource = resGCHC['clone'].GetDown()
            clonedModifier = resGCHC['clone'].GetDown().GetNext()
            clonedModifier.SetDeformMode(True)
            clonedModifier.InsertUnder(clonedSource)
        
            objList = c4d.utils.SendModelingCommand(
                command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                list = [clonedSource],
                mode = c4d.MODELINGCOMMANDMODE_ALL,
                doc = doc,
                flags = c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE)
        
            if objList == False:
                print "Error Current State to object!"  
                return None
            
            return objList[0]
        

        Best, Riccardo

        1 Reply Last reply Reply Quote 1
        • P
          pim
          last edited by

          Thanks, that works for me.

          I noticed that it is not possible to select edges or polygons on the resulting virtual object.
          Is there a way to select them?

          -Pim

          1 Reply Last reply Reply Quote 0
          • r_giganteR
            r_gigante
            last edited by

            Hi Pim,

            as for any other generator (think of a cube generator) you can't select low-level elements (points, edges or polygons) if you don't convert the generator into a polygonal object.

            Best, Riccardo

            1 Reply Last reply Reply Quote 2
            • r_giganteR
              r_gigante
              last edited by

              Hi Pim,

              with regard to your last question, it's worth to mention that although you can't interactively define selections, you can indeed deliver SelectionTags within your ObjectData.

              Best, Riccardo

              1 Reply Last reply Reply Quote 3
              • P
                pim
                last edited by

                Hi Riccardo,

                I am not sure what you mean, but I guess you mean that you define selection tags on one of the children and use that selection on the resulting objectdata object?

                -Pim

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