Objectdata and Bevel objects
-
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().
But the result is not a nice bevel. It looks as if there are 2 bevels done on the cube.
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
-
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
-
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
-
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
-
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
-
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