Notifications
Clear all

[Closed] Maxscript for Point Constraint and Orient Constraint?

Greetings everyone,
I am new to MaxScript, and I usually use Python in Maya.
I wrote an autoRig script in MaxScript, but when it arrives at putting orientation constraint or position constraint, it stops and demands user input to click on the constraining object.
How do you write the code in a way that can keep rigging without user input?

I checked the help docs and it has dozens of detailed properties for position constraint and orientation constraint, but never says the simple code I am trying to find:
How to write ‘point constraint <targetObj> <constrainerObj>’

I tried to write it like this:

--orient constrain the Left wrist bone to the buffer controller
	select wristBone
	macros.run "Constraints" "Orientation_Constraint"
	select L_wristBuffer_Ctrl
	clearSelection()

…Because that’s what it said in the MaxScript Listener, but it turns out the user selection of the constraining object doesn’t count as “selecting”.

My code for point constraint looks the same, only calling the “Position_Constraint” macro…

Thanks for the help!

3 Replies

So this example code works:

s = sphere pos:[20,20,20]
b = box pos:[-20,-20,-20]
posCtrl =Position_Constraint()
s.pos.controller = posCtrl
posConstraintInterface = posCtrl.constraints
posConstraintInterface.appendTarget $box001 20.0
node1 = posConstraintInterface.getNode 1
weight = posConstraintInterface.getWeight 1

I’m still not very familiar with MaxScript, so it’s hard for me to tell when a variable is being called, or some aspect of the 3DS Max interface.

“posConstraintInterface” seems to be part of the system…
and “node1” seems to be a variable, but it never gets called again. So maybe that’s part of Max interface too? (not sure what ‘getNode’ and ‘getWeight’ are doing.)

You seems pretty just follow the example says on it. I think you should experiment with it also.
This also works:


s = Sphere pos:[20,20,20]
b = Box pos:[-20,-20,-20]
posCtrl = Position_Constraint()
posCtrl.relative = true
posCtrl.appendTarget b 100 
s.position.controller = posCtrl

And I don’t really see any connections of other variable, tbh…