View Full Version : Adding forces to spring controllers with maxscript

3rd Dimentia
08 August 2008, 07:44 AM
Has anyone had any luck adding forces to SpringPositionConstraints with maxscript?
I just can't seem to get it to work.

I've found 2 other threads with the same problem. But they were from some time ago and am wondering if anyone has found a way to get it to work since then?



08 August 2008, 09:33 AM
nope.. just as there is an .addSpring() method in the interface, there should have been a .addForce() . Or the parameter be made of variable size :)

There is a work-around, but it's not very proper...

1. create a lot of compatible spacewarps.. Gravities will do
2. add those to the External Forces list for a Spring constraint
3. file > save selected the object that constraint is on
when needing a new spring constraint, or having to enlarge an existing one, don't generate one, but..
4. load the object from the saved file (mergeMaxFile())
5. select it
6. switch to the motion panel (max motion mode)
7. copy the controller previously set up
( if extending an existing one, fill the copy with the existing one's forces, add the other forces, and assign )

You should find that the constraint's .forceNode list is full of 'undefined's. In the UI these are presented as "<deleted>". The constraint doesn't care much about these, but it does give you as many slots to put forces into as you'd like... within the limit of how many you had added in step 2 anyway... hence 'a lot'.. make sure you've got some headroom to work with :)

If you don't like all the "<deleted>" bits, just set one of the slots to some spacewarp, then delete that spacewarp; that appears to reset the constraint's innards.

fwiw.. I don't know why 'save selected' doesn't include the forces picked - it certainly includes any nodes picked. So just in case that's a bug that'd get fixed in the future, check your scene state after merging the object in.. make sure none of those forces from Step 1 are merged in as well (and if they are, delete them).

Steps 5 and 6 are a bit odd as well, but seems there's some initialization bit required.

a = $.position.controller.forcenode
#(undefined, undefined, undefined, undefined, undefined, undefined)
$.position.controller.forcenode[1] = gravity()
** system exception **
max motion mode
$.position.controller.forcenode[1] = gravity()
$Gravity:Gravity01 @ [0.000000,0.000000,0.000000]

There's probably something else that'll force it to initialize as well - haven't tried :)

CGTalk Moderation
08 August 2008, 09:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.