THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/03/2011 at 10:01, xxxxxxxx wrote:
Hi there,
I'll post this here again, because it's only about Python now.
I want to join the hierarchy of the selected Object to one.
But The next objects are added, too, even they are NOT in the list ?! :nauseated_face::nauseated_face::angry:
import c4d
from c4d import utils
def GetHNext(op, start = None) :
if not op: return
if op.GetDown() :
return op.GetDown()
while (not op.GetNext()) and (op.GetUp()) :
op = op.GetUp()
if start == op:
return
return op.GetNext()
return
def GetHierarchyInList(op) :
lst = list()
sop = op
while op:
lst.append(op)
op = GetHNext(op,sop)
return lst
def main() :
lst = GetHierarchyInList(op) ## Get the Hierarchy of op
if not lst[0]: return
for i in lst: ## print all Objects in the list
print i.GetName()
obj = utils.SendModelingCommand(## Use modeling command
command = c4d.MCOMMAND_JOIN,
doc = doc,
list = lst )
obj[0].SetAbsPos(c4d.Vector(0,250,0))
doc.InsertObject(obj[0]) ## Insert new Object
doc.SetActiveObject(obj[0])
obj[0][c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(130/255.0,255/255.0,100/255.0)
c4d.EventAdd()
if __name__=='__main__':
main()
I have the following Hierarchy:
I select the Cube and in the list obtained by GetHierarchyInList(op) there is only the Cube and the Sphere, as wanted.
But at the end, all objects are collapsed by MCOMMAND_JOIN.
Any Idea ?
Here an example scene, so you don't have to set up your own.
click
Thanks, nux