Originally posted by dargodeen
Hi everyone ,
I am very new to max scripting. I need to write a script which connects the two selected objects with a spline and stay connected.ok now by far I have found two way of doing
That manually one with animateVertex and point3 expression and other with linkedXForm.
Now I have to automate the whole process with a script.
I started off with second method
for i in selection do
addKnot line1 1 #corner #line i.pos
subObjectLevel = 1
setKnotSelection line1 1 #(1)
addModifier line1 (Edit_spline())
subObjectLevel = 1
setKnotSelection line1 1 #(2)
Now the problem is I am not able to select the vert 2 on Edit_spline modifier
Which is on top of linkedXform.
setKnotSelection line1 1 #(2) ----is selecting vert 2 of the base modifier.
So can any help me how to go about it or the whole approach is wrong or is there a better way to get it.As I said I am new to max script and I am still learning and help is greatly appreciated.
There are some issues with using knot selections in splines you should be aware of. Your example looks simple, but you should never underestimate the hidden cliffs in a package as deep...
Below is a message I posted as an answer to a similar question on the Max support forum in June 2003. It might be helpful.
The original author wanted to link two spheres with a line like with a rope, so moving any of the spheres would move the vertices of the spline and keep them connected....
...When you set a Knot selection, you are ALWAYS affecting the base object - the EditableSpline at the bottom of the stack. When you make a selection below
using MAXScript, it FLOWS up the stack through all Edit_Spline modifiers and
changes their selections. So you always end up with the same knots selected
for both Linked_XForms.
You have to do two things to make it work - you have to go slightly backwards,
and use a SplineSelect as a "selection blocker" - as you probably know, you
can use BlaBla_Select to prevent sub-object selections from flowing up the stack in Max.
g.pos = [0,0,0]
g2.pos = [70,89,0]
NSS = splineShape()
addKnot NSS 1 #corner #line [0,0,0]
addKnot NSS 1 #corner #line [70,89,0]
--No changes so far...
max modify mode --switch to modify panel
select NSS --select the spline
ms = edit_spline name:"First ES" --create 1st Edit_Spline
addmodifier NSS (ms) --add to the TOP of the stack
subobjectLevel = 1 --vertex level...
setKnotSelection NSS 1 #(1) --select first vertex in BASE OBJECT
LX1 = Linked_XForm name:"First XForm" --Add Linked XForm
modPanel.addModToSelection LX1 --Add to the sub-selection
LX1.Control = $Sphere01 --Set control
--NOW IT IS GETTING FUNNY!
ms2 = splineselect name:"Protection" --Add a SplineSelect to stop the flow
addmodifier NSS (ms2) before:2 --Add it BEFORE the first Edit_Spline!
--Note: Since modifiers are always counted from top to bottom,
--having 2 modifiers on top will place the new modifier before them
--when using "before:2"
ms3 = edit_spline name:"Second ES" --Create second Edit_Spline
addmodifier NSS (ms3) before:3 --Add it BEFORE the SlineSelect "Blocker"
modPanel.setCurrentObject ms3 --Set the Modifier stack to it
subobjectLevel = 1 --vertex SO level
setKnotSelection NSS 1 #(2) --select second vertex
LX2 = Linked_XForm name:"Second XForm" --create new Linked XForm
modPanel.addModToSelection LX2 --Add on top of the current selection
LX2.Control = $Sphere02 --set second control
-----------------------End original message -------------------
Hope this helps.
01-27-2004, 07:13 AM
Thanks for the response bobo ,that helped.
06-19-2005, 07:13 AM
It's an old post, but pretty interesting. Now I understand why the method I was using wasn't working. Thanks a lot, Bobo!
Thanks Bobo! This is been pain in my ... long time. Not anymore :bounce:
02-06-2006, 02:39 PM
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.