Flatten Vertices on Edit Spline

Hello :)

I'm wondering what goes wrong with my script. It suppose to flatten all vertices to 0 on the Z-axis.

It seems to only work on non-splines.
Can it be adjusted so it will work with an Edit Spline too?

Thank you.

AttachmentSize
flatten_vertices.ms610 bytes

Comments

Comment viewing options

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

.

(
	on isEnabled return
	(
	  selection.count == 1 and  (classof selection[1] == SplineShape or classof selection[1] == Line) and selection[1].modifiers.count == 0
	)
	on execute do
	(
		selObjsArr = selection as array
		for spl in selObjsArr do
		(
			convertToSplineShape spl
			new_z = spl.pos.z
			splCnt = numSplines spl
			for s = 1 to splCnt do
			(
				knotsCnt = numKnots spl s
				for k = 1 to knotsCnt do
				(
					knt = getKnotPoint spl s k
					in_vec = getInVec spl s k
					out_vec = getOutVec spl s k
					knt.z = in_vec.z = out_vec.z = new_z
					setInVec spl s k in_vec
					setOutVec spl s k out_vec
					setKnotPoint spl s k knt
				)
			)
			updateShape spl
		)
	)
)
remykonings's picture

*

Indeed, It works well.

Thank you for all your effort and help.
It is very appreciated, not only on this topic but also all my others.

Happy New Year and thank you :)

miauu's picture

.

Glad to help.
Happy New Year to you too.

Comment viewing options

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