Automatically add effector object into In-/Exclusion User Data
-
Hello,
How to automatically add effector object into In-/Exclusion User Data when the object that contain In-/Exclusion User Data is selected and I add new effector, like as Cloner object. -
Hi @mfersaoui, first all please or the next topic, use the Q&A New Functionality and read How to Post Questions, I've setup your topic correctly but please do it for the next time.
Regarding your issue as background this is not the cloner that is listening for insertion of an effector, but the effector through the message (MSG_MENUPREPARE) which is responsible for adding himself in the currently selected object.
So if you want to do this, the proper solution could be to create a SceneHook in order to a tracks scene change and new addition, but this can't be done in python since scenehook are not supported.
So I'm afraid the only way you have is to create a MessageData plugin in order to react to EVMSG_CHANGE and iterate yourself into the scene to find what's new.Cheers,
Maxime. -
@m_adam Thank you,
Now I'm searching for how to add an Object to an In-Exclude user data. I tried with the following code but this doesn't work.import c4d def main(): effectors = op[c4d.ID_USERDATA,2] # In/Exclude User Data plain = doc.GetFirstObject() # Plain object (Effector) effectors.InsertObject(plain, 1) c4d.EventAdd() if __name__=='__main__': main()
-
@mfersaoui said in Automatically add effector object into In-/Exclusion User Data:
import c4d
def main():
effectors = op[c4d.ID_USERDATA,2] # In/Exclude User Data
plain = doc.GetFirstObject() # Plain object (Effector)
effectors.InsertObject(plain, 1)
c4d.EventAdd()
if name=='main':
main()Here is the solution for how to add an Object to an In-Exclude user data.
import c4d def main(): plain = doc.GetFirstObject() # Plain object (Effector) inexclude = c4d.InExcludeData() #Create an InExcludeData class instance inexclude.InsertObject(plain,1) op[c4d.ID_USERDATA,2] = inexclude c4d.EventAdd() if __name__=='__main__': main()
-
@mfersaoui said in Automatically add effector object into In-/Exclusion User Data:
@m_adam Thank you,
Now I'm searching for how to add an Object to an In-Exclude user data. I tried with the following code but this doesn't work.import c4d def main(): effectors = op[c4d.ID_USERDATA,2] # In/Exclude User Data plain = doc.GetFirstObject() # Plain object (Effector) effectors.InsertObject(plain, 1) c4d.EventAdd() if __name__=='__main__': main()
The actual issue is that effectors = op[c4d.ID_USERDATA,2] perform a copy of the InExcludeData so that means you have to reassign the data correctly after it since you don't do the change directly from the InExcludeData of the BaseContainer.
op[c4d.ID_USERDATA,2] = effectorCheers,
Maxime.