thank you for reaching out to us and thank you @bentraje for providing help.
The major problem with your code is that you have the line
Cloner.InsertObject(EffectorList) in there. But there is no variable of the name
Cloner within the scope of
effectorsCreation. Which is why your code will raise a
NameError on this line. But even if the variable
Cloner from your function
cloner_creation would be visible within
effectorsCreation, it would still raise an
AttributeError, because your
Cloner is of type
BaseObject which has no attribute (i.e., method) of the name
I would also recommend not to insatiate an
c4d.InExcludeData from scratch, because you will lose any existing links by doing so and then writing back that newly allocated
InExcludeData. In this case here it does not really matter, since you also instantiate the MoGraph cloner, i.e., its effectors list will still be empty. Below you can find a commented section of your code and a proposal how I would write something like that (which is effectively also what @bentraje did).
# This is a lightly commented version of your code, pointing out the major
# problem with your version.
Effector = c4d.BaseList2D(1025800)
# This does not do anything; it just creates an InexCludeData instance.
EffectorList = c4d.InExcludeData() # Initialize an InExclude data
# That does not work, Cloner is not visible in this scope, it would also
# be an BaseObject, which does not have a InsertObject method.
Cloner.InsertObject(EffectorList) # Add effector to effectors list
# Instantiate a MoGraph cloner and Python effector. One can also use
# BaseList2D.__init__(), this version here is just more verbose.
cloner = c4d.BaseObject(1018544)
effector = c4d.BaseObject(1025800)
# Get a copy of the InExcludeData Effectors parameter of the cloner.
inExcludeData = cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST]
# Add the effector in an activated state (1)
# Important, we have to write the modified InExcludeData back, since we
# only retrieved a copy of it.
cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = inExcludeData
# Add both nodes to the currently active document.
# Update Cinema 4D.