Hi,
I’m trying to retrieve an object’s position constraint’s target and weight. See below for illustration.
How is this possible in pymxs? I tried using the “help” function but it returns an error
import pymxs
rt = pymxs.runtime
obj_list = rt.selection
for obj in obj_list:
# help function to get the possible properties and methods
# but this returns an error instead.
print (help(obj))
break
I tried using
obj.position.controller
but it returns None
even though there is a constraint attached.
You can’t get access to the objects controller directly using pymsx.
You have to use the objects getattr method if I remember correctly.
node.postition.gettettr("controller")
Thanks for the response.
Swordslayer from Reddit helped arrived with the working code:
import pymxs
rt = pymxs.runtime
obj = rt.selection[0]
transformCtrl = rt.getSubAnim(obj, 'transform').controller
posCtrl = rt.getSubAnim(transformCtrl, 'position')
print (posCtrl[1].controller.weight[0] )
My bottleneck is retrieving the name/target of the weight (i.e. the object it was weighted)
I tried using
posCtrl[1].controller.name[0]
or
posCtrl[1].controller.target[0]
but it doesn’t work 
Here is the docs for position constraint:
https://help.autodesk.com/view/MAXDEV/2022/ENU/?guid=GUID-4F0CBB0A-28B1-4182-8164-2BB730C86D06
getNumTargets()
getNode <index>
getWeight <index>
are what you want
1 Like
This gets the weight of the controller in the controller stack rather than weights of attributes specific to the controller type
@Munkybutt
Thanks for the response.
the getNode()
, getWeight()
and `getNumTargets)
works as expected!
Thanks for linking the doc. I searched it earler but I just couldn’t find where it belong.
I’m really reliant on the help()
method in every API.
yeah pymxs just wraps the maxscript api so all the info is in the maxscript docs.