Solved how can i get the id of each target? note: I will add more with c4d.CallButton ()
Hi,
the description for this tag is obviously being built dynamically. By poking around in the editor, you can find out that the field Target in the tab Parent is starting at the id 30001
and placed with a stride of 10
. So the next ids would be at 30011
, 30021
, etc.
To test up to which point your tag has been populated, you should enumerate all possible ids consecutively and test for each if the data container of your tag contains an element of the type BaseLink
at that id. When an id fails this test, you know you have reached the end, i.e. the last id in your enumeration was the last valid id. The code could look something like this:
cid = 30001
result, data = [], constraint_tag.GetData()
while True:
if not data.GetType(cid) is c4d.DA_ALIASLINK:
break
result.append(cid)
cid += 10
Cheers,
zipit
MAXON SDK Specialist
developers.maxon.net
While the method provided by Zipit Is fine, it is not 100% reliable.
here how to achieve, unfortunately, the ELEMENT_Count value is hardcoded and no way for you to retrieve it.
constraintTag = doc.GetActiveTag()
targetCount = constraintTag[c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT]
for i in range(targetCount):
CONSTRAINT_ELEMENT = 10 # This is hardcoded
targetId = c4d.ID_CA_CONSTRAINT_TAG_PARENT_TARGET_COUNT + i * CONSTRAINT_ELEMENT + 1
print(constraintTag[targetId])
Cheers,
Maxime.
MAXON SDK Specialist