Hi,
I made a little script to "straighten" a spline to have its overall slope.
It works but I want to apply the script to selected splines ( loop ) and then it don't work anymore... Anybody can help ? :-)
BS = selection[1]
BSW = BS.wirecolor
SP = copy BS
select SP
macros.run "Modifier Stack" "Convert_to_Spline"
verts = numKnots SP
NP=SplineShape pos:[0,0,0]
addNewSpline NP
PO = getKnotPoint SP 1 1
addKnot NP 1 #corner #line [0,0,PO.z]
NEWD = 0
for i=1 to (verts-1) do
(
PA = getKnotPoint SP 1 i
PB = getKnotPoint SP 1 (i +1)
PAF = [PA.x,PA.y,0]
PBF = [PB.x,PB.y,0]
DISTx= (( distance PAF PBF ))
NEWD = DISTx + NEWD
--print ( DISTx as string)
addKnot NP 1 #corner #line [NEWD,0,PB.z]
)
updateShape NP
NP
NP.wirecolor = BSW
NP.name = BS.name + "_red"
delete SP
Comments (3)
Comment policy
Your code will work for the first spline in a shape. If you have a shape with 2 or more splines only the first one will be processed.
Do you want to create a script which works like this one: http://www.scriptspot.com/3ds-max/scripts/stretch-spline
Here is your code, modified to process shapes with multiple splines.
Hi Miauu ! Thanks for answer
Hi, thanks very much ! It works like a charm :-)
Is there a way to make another for separate spline objects with :
for sp in selection do ( ) ? So I can have separate wirecolor ?
Thanks a lot !
This will get all splines of a shape and will create separate objects from each spline: