-
Set Parent command, and access attribute on Constrain Tag (Cinema 4d Python)
Set Parent command, and access attribute on Constrain Tag (Cinema 4d Python)
Hi Guys
for past 7 days I started learning and working with python in cinema 4d and I solved some of my problems with python but this one ( that I discuss here )get me in trouble and I don’t know what should I do.
I want a python code that do these tasks in order
- I select two objects in order
- the script make a null at same abs position of the first selected object
- then it adds the second selected object to created null as child of that ( it does it with “set parent” command in cinema 4d ( c4d.CallCommand(1025539) ) because the object is animated and doing it in other ways ruins the animation )
- then add a constrain tag (Constraints : Transform) to the null object
- then make some adjustment to the constrain tag attribute
- check maintain original
- add the first selected object as Target in the constrain tag
- finish!
I am OK with first two step but with step 3 after the “call command” using “SetActiveObject” wont do anything and the command “set parent” still waiting for me to select the parent object with my mouse from object manager or viewport,
step 4 is ok, but for step 5 I don’t know how to access the add tag attribute, I guess it is something related to “SetParameter” , “DescID” “DescLevel” ? , “BaseContainer” ?,…. they are all in my head like spaghettis, but I Tried different ways that and different thing but it didn’t worked (I am new to whole this thing and I don’t have Good foundation on getting an object by its ID or …. and accessing its parameters and changing them)
this is my code so far:
from typing import Optional import c4d doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def main() -> None: objSel = doc.GetOrderedActiveObjects() parPos = objSel[0].GetAbsPos() null1 = c4d.BaseObject(c4d.Onull) doc.InsertObject(null1) null1.SetAbsPos(parPos) doc.SetActiveObject(null1,0) c4d.CallCommand(1019364) # c4d.CallCommand(100004788, 50049) # New Tag c4d.CallCommand(1025539) # Set Parent c4d.EventAdd() if name == 'main': main()
<hr>
this is a link to a video in my google drive that I explained case more clear
https://drive.google.com/file/d/1KJZIITeovTlNnFEEXG5D3-zLo4-yOVHB/view?usp=sharing
I appreciate any help 🌸🌸🌸
thank you guys ✌✌
sorry for my English
Sorry, there were no replies found.