newbie help, changing knot type

I am trying to make a simple script to change a selected spline knot type. it goes as as follows:

a = ((getsplineselection $ )[1]) --------to get the spline integer
b = ((getknotselection $ a )[1]) --------to get the knot integer
setknottype $ a b #corner --------assigns new knot type to selection

I dragged the macro into a toolbar to make a button and it works as I need it to. The problem arises when I restart max. when I press my macroscript button again I get an error

" --unable to convert: undefined to type: integer"

so for some reason a & b are not kicking back an integer when the desired knot is selected.

In the maxscript help file the syntax for getknottype is defined as:

setKnotType (#smooth | #corner | #bezier | #bezierCorner)

Any help is greatly appreciated ! this is driving me nuts :)

also, I made a simple ui for it and the when I run the script nothing happens. I used the visual maxscript editor the final script looked something like this:

rollout knots "knot types" width:140 height:171
(
button btn1 "corner" pos:[14,32] width:107 height:24
button btn2 "smooth" pos:[15,62] width:107 height:24
button btn3 "bezier" pos:[16,96] width:107 height:24
button btn4 "bez corner" pos:[16,130] width:107 height:24
on btn1 pressed do
(
a = ((getsplineselection $)[1])
b = ((getknotselection $ a)[1])
setknottype $ a b #corner
)
on btn2 pressed do
(
a = ((getsplineselection $)[1])
b = ((getknotselection $ a)[1])
setknottype $ a b #smooth
)
on btn3 pressed do
(
a = ((getsplineselection $)[1])
b = ((getknotselection $ a)[1])
setknottype $ a b #bezier
)
on btn4 pressed do
(
a = ((getsplineselection $)[1])
b = ((getknotselection $ a)[1])
setknottype $ a b #bezierCorner
)
)

any help regarding this problem is also greatly appreciated,
Thanks,

Paul

Comments

Comment viewing options

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

Wow, thanks! This is

Wow, thanks!

This is great,works perfectly :)

barigazy's picture

This is your tool

This is your tool
--work on single selected shape (with multiple attached splines) without assigned modifiers.
--supports multiple selected knots

try(destroydialog ::knotsRoll)catch()
rollout knotsRoll "knot types"
(
	fn filterSpline spl = (classof spl == Line or classof spl == SplineShape)
	fn changeKnotTypes btn: = 
	(
		if selection.count == 1 and filterSpline selection[1] and (selection[1].modifiers).count == 0 do
		(
			local spl = selection[1]
			for s = 1 to (numSplines spl) do
			(
				if (knots = getKnotSelection spl s).count != 0 do
				(
					local type = case btn of (
						(1):#corner
						(2):#smooth
						(3):#bezier
						(4):#bezierCorner
					)
					for k = 1 to knots.count do setKnotType spl s knots[k] type
				)
			)
			updateshape spl
		)
	)
	button btn1 "Corner" pos:[5,5] width:100 height:20
	button btn2 "Smooth" pos:[5,30] width:100 height:20
	button btn3 "Bezier" pos:[5,55] width:100 height:20
	button btn4 "BezierCorner" pos:[5,80] width:100 height:20
	on btn1 pressed do (changeKnotTypes btn:1)
	on btn2 pressed do (changeKnotTypes btn:2)
	on btn3 pressed do (changeKnotTypes btn:3)
	on btn4 pressed do (changeKnotTypes btn:4)
)
createDialog knotsRoll 110 105

barigazy

Comment viewing options

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