spline_ik_control helper creation problem via script

spline_ik_control helper creation problem via script

adnanmg
Advocate Advocate
585 Views
4 Replies
Message 1 of 5

spline_ik_control helper creation problem via script

adnanmg
Advocate
Advocate
Hi,

using spline_IK_Control modifier in max 2010. Given a spline called cur_spline, I'm running the following code:


addmodifier cur_spline (spline_Ik_Control())
cur_spline.spline_ik_control.helper_size=2.5
cur_spline.spline_ik_control.linkTypes=2
cur_spline.spline_ik_control.createHelper (cur_spline.spline_ik_control.getKnotCount())

For some reason the helpers are created at the origin instead of at each spline vertex location. Also, they do not move the vertices, nor do all of them show up in the control objects box in the spline_ik_control modifier.

However, if I click the create helper button in the interface, it works correctly. I need to get it working correctly via maxscript. Secondly, I would like to rename the helper objects using maxscript. Is there a way to get them to be created correctly in the script as well as then access them and name them in the same script?

Thanks in advance!

Adnan
0 Likes
586 Views
4 Replies
Replies (4)
Message 2 of 5

adnanmg
Advocate
Advocate
For some reason, using getKnotCount() does not work, but if I use numKnots, it works. Is there something I need to do different in my syntax?
0 Likes
Message 3 of 5

Steve_Curley
Mentor
Mentor
There's nothing actually wrong with your code as presented - it works here.

You're making it difficult to read (the code) by specifying everything in full. Much easier to use an intermediate variable for the controller which you can reference directly.

"Rename the helper objects". Do you mean the modifier itself (normally "Spline IK Control") or the individual helpers ("Point01" etc)?

Naming the modifier is easy (see the code below).

Renaming the helpers - I don't see a way to do that during the creation proces, but it can be done afterwards. Note that the modifier panel names won't update immediately (if the spline is currently selected) - just deselect it and reselect it to see the changes. Note that the spline does not need to be selected in the first place.

ikCtrl = spline_IK_Control name: (uniquename "MySplineIKControlModifier") helper_size: 2.5 linkTypes: 2
addModifier cur_spline ikCtrl
ikCtrl.createHelper (ikCtrl.getKnotCount())

-- rename the helpers
for i = 1 to ikCtrl.getKnotCount() do
ikCtrl.helper_list.name = (uniquename "myHelperObject")


And please - always put code fragments in CODE tags - it prevents the forum software messing with it and making it impossible to copy/paste directly from the post.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 4 of 5

Anonymous
Not applicable

For some reason the helpers are created at the origin instead of at each spline vertex location. Also, they do not move the vertices, nor do all of them show up in the control objects box in the spline_ik_control modifier.


Putting this again here, because my question disappeared. I'm having this same problem. The script it self works as it should, but it creates the helpers in the origin and they have no effect on the spline_IK_control.

Here's my piece of code:

spineSpline_IK_Mod = Spline_IK_Control name:(uniquename "spineSplineIKControl") linkTypes:2;
addModifier theSpline spineSpline_IK_Mod;
spineSpline_IK_Mod.createHelper 4;


Any help would be nice. I'm running 32-bit version on 64-bit Vista.
0 Likes
Message 5 of 5

Anonymous
Not applicable
There is a difference between this two code...
myshape = splineshape wirecolor:blue
addnewspline myshape
addknot myshape 1 #corner #line
addknot myshape 1 #corner #line
addknot myshape 1 #corner #line
updateshape myshape
ikctrl = spline_IK_control helpersize:8 linkTypes:2
addmodifier myshape ikctrl
ikctrl.createHelper (ikctrl.getKnotCount())

this one works like a charm, and create a Line with 3 knot and a modifier with 3 control...
but when you put this code inside parenthesizes wont work...
and now try this one...
rollout cv "Create Line" width:162 height:300
(
button btn1 "Create Line" pos: width:135 height:25
on btn1 pressed do
(
myshape = splineshape wirecolor:blue
addnewspline myshape
addknot myshape 1 #corner #line
addknot myshape 1 #corner #line
addknot myshape 1 #corner #line
updateshape myshape
ikctrl = spline_IK_control helpersize:8 linkTypes:2
addmodifier myshape ikctrl
ikctrl.createHelper (ikctrl.getKnotCount())
)
)
createdialog CV 162 300

exactly the same code, just put it inside roll-out with a button.
it's not working now...
but if you replace "(ikctrl.getKnotCount())" in the last line of the base code, with just "3" digit, it's again works. I don't no if the problem is .getknotcount or simply parenthesizes.
0 Likes