Editing Spline knots

Hi everyone!

In order to make a script that randomizes splines used for path constraint objects (that what i want does not work with pflow) .

I want to go through every Spline Knot and randomize its position

like this

addmodifier new_path (Edit_Spline ())
verts = numKnots new_path
for i=1 to verts do(
vert = getKnotPoint new_path 1 i
offs = random -pos_off.value pos_off.value
vert.x = vert.x + offs
vert.y = vert.y + offs
setKnotPoint new_path 1 i vert
updateShape new_path
)

but i found out, that the changes are made within the spline object and not within the modifier, how can i change that?

thanks in advance vor help

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Phasma's picture

LOL!

Sometimes you suddenly notice that you think way to complicated!

just adding a noise modifier on every reference and changing the seed creates exacly what i want :-)

barigazy's picture

Is that simple :) Cheers,man!

Is that simple :)
Cheers,man!

bga

Phasma's picture

Thank you very much!

But sadly this does not work for this purpose.
I still want to have the fredom to change the vertex positions of the master path. as the referenced paths will have a spline ik mod on them they will not update the vertex movement on the master path.. so i really need to put the random position offset into a new edit_spline modifier.

I am trying a new way now:

select new_path
modPanel.addModToSelection (Edit_Spline ()) ui:on
verts = numKnots new_path
subobjectLevel = 1
for i=1 to verts do(
setKnotSelection new_path 1 #(i)
)

in the for loop i just need a move selected knot funktioality. This way it is a bit slow to create (ui in max will flicker and stuff) but it recreates the workflow like you would do it by hand. I just need to move the selected knot now.

Any Ideas?

barigazy's picture

SOLUTON

This MAXScriptHelp say:

"When setting a Knot selection using the setKnotSelection method, you are always affecting the base object - the EditableSpline at the bottom of the stack. It is not directly possible to set the sub-object vertex selection of a specific Edit_Spline modifier using this method. The selection flows up the stack through any existing Edit_Spline modifiers and changes the sub-object selections of all of them."

But you can try this:

theShape = splineShape name:"ZigZag"
addnewSpline theShape
xp = 20
for i = 0 to 9 do
(
	yp = if mod i 2 != 0 then -1 else 1
	addKnot theShape 1 #corner #line [i*xp,10*yp,0] 
)
updateShape theShape
sIKMod = Spline_IK_Control linkTypes:2 Box:off helper_cross:on helper_size:5
addModifier theShape sIKMod
sIKMod.Createhelper (sIKMod.getKnotCount())
if sIKMod.getHelperCount() != 0 do 
(
	for ph in sIKMod.helper_list do ph.name = uniquename (theShape.name+"_PH_")
)
for h = 1 to sIKMod.getHelperCount() do
(
	sIKMod.helper_list[h].pos += Point3 (random -10 10) (random -10 10) (random -10 10)
)
--uncomment this to delete all helpers
--delete $'ZigZag_PH_*'

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.