Thank you so much @i_mazlov . I'm still new to this and your reply is extremely helpful. Thanks again!
Apologies for the double post. I wanted to completely remove the old post since I kinda spammed too many replies on it while I was figuring out what was wrong.
Appreciate the help. Have a good day!
Posts made by hoffwerr
-
RE: GetChildren into an InExcludeData
-
GetChildren into an InExcludeData
Hi there!
I'm trying to add all the children (no grandchildren) underneath an object to an InExcludeData on the parent.
This s what I could come up with but it doesn't seem to work for some reason that I can't figure out.
import c4d def main(): obj = op.GetObject() print (obj) children = obj.GetChildren() print (children) GroupList = c4d.InExcludeData() GroupList.InsertObject(children, 1) obj[c4d.ID_USERDATA,1] = GroupList c4d.EventAdd()
This is the error I'm getting.
Traceback (most recent call last): File "Python", line 10, in main TypeError: argument 1 must be c4d.BaseList2D, not list
TEST_ADD_HEIARCHY.c4d
Any idea how to fix that ? -
RE: Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
@hoffwerr said in Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion:
Ok. I did some more research and I think I'm kinda close to figuring this out. I ended up using a Python tag instead.
import c4d def main(): obj = op.GetObject() print (obj) effectors = obj.GetChildren() print (effectors) GroupList = c4d.InExcludeData() GroupList.InsertObject(effectors, 1) obj[c4d.MGGROUPEFFECTOR_EFFECTORLIST] = GroupList c4d.EventAdd()
Seems to work just fine up until adding the selection to the InExcludeData
<c4d.BaseObject object called Group/Group with ID 1019351 at 1949340925248> [<c4d.BaseObject object called Plain.2/Plain with ID 1021337 at 1949342765760>, <c4d.BaseObject object called Plain.3/Plain with ID 1021337 at 1949342765632>, <c4d.BaseObject object called Plain.4/Plain with ID 1021337 at 1949342766400>] Traceback (most recent call last): File "Python", line 10, in main TypeError: argument 1 must be c4d.BaseList2D, not list
I'm getting this error at the bottom with the objects being a "list" instead of "c4d.BaseList2D". Can't seem to figure this one out.
I'm really confused on why "GetChildren" doesn't work while GetNext and GetDown seem to work just fine. GetChildren seems like it's the ideal way to do this since I only want the children and none of the grand children.
-
RE: Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
This is based from this thread.
https://developers.maxon.net/forum/topic/10016/13482_python-node-with-hierarchy/4But it's unfortunately causing crashes. It seems to be returning every single object under the main object so all the children and grand children, etc. Is there anyway to limit this to just the children ?
-
RE: Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
Ok, I did some more research and found some old topic with a similar problem. This seems to work for me at least. I'm able to get all the child objects and auto add them to the InExcludeData.
import c4d def AddHierarchyToInEx(obj, inex) : if obj is None: return while obj is not None: inex.InsertObject(obj, 1) AddHierarchyToInEx(obj.GetDown(), inex) obj = obj.GetNext() def main(): obj = op.GetObject() InExData = c4d.InExcludeData() AddHierarchyToInEx(obj.GetDown(), InExData) obj[c4d.MGGROUPEFFECTOR_EFFECTORLIST] = InExData c4d.EventAdd()
-
RE: Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
Ok. I did some more research and I think I'm kinda close to figuring this out. I ended up using a Python tag instead.
import c4d def main(): obj = op.GetObject() print (obj) effectors = obj.GetChildren() print (effectors) GroupList = c4d.InExcludeData() GroupList.InsertObject(effectors, 1) obj[c4d.MGGROUPEFFECTOR_EFFECTORLIST] = GroupList c4d.EventAdd()
Seems to work just fine up until adding the selection to the InExcludeData
<c4d.BaseObject object called Group/Group with ID 1019351 at 1949340925248> [<c4d.BaseObject object called Plain.2/Plain with ID 1021337 at 1949342765760>, <c4d.BaseObject object called Plain.3/Plain with ID 1021337 at 1949342765632>, <c4d.BaseObject object called Plain.4/Plain with ID 1021337 at 1949342766400>] Traceback (most recent call last): File "Python", line 10, in main TypeError: argument 1 must be c4d.BaseList2D, not list
I'm getting this error at the bottom with the objects being a "list" instead of "c4d.BaseList2D". Can't seem to figure this one out.
-
RE: Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
Hi @i_mazlov ,
Thanks for getting back to me about my question. I'm basically trying to auto populate the "Effectors" list in the Group Effector with whatever effectors are child of it. I thought I'd just use a Hierarchy node and somehow plug that in directly in that Effectors with Xpresso but it turned out to be not straight forward as I thought.
So my idea was to somehow setup a quick python script where it would cycle through the Hierarchy node output and add them all into an In-Exclusion list. I think the ObjectList is exactly the opposite of what I'm trying to do. The Input is an In-Exclusion list while the output is an Object/Instance.
Not sure what would be the Ideal workflow for something like this.
-
Xpresso & Pyhton - Convert Link List (Hierarchy Node) to In-/Exclusion
Hi there!
I'm trying to convert the output of a Hierarchy Node into an In-/Exclusion list.
I've done quite a bit of research to try to figure this one out but I'm honestly not a coder and I couldn't figure it out at all.This is kind of of what I'm trying to do.
Any change I can get some help on this.
Thanks!