open/break ~400 splines

Hi there,

this should be a really simple script. But I can't fathom out how to do this:
I need to open up a couple of hundred splines. They are all closed but I need them now to be open. I use them as a spline for forest pack. Exploding them will not bring the right result. They need to stay intact, but need to be open.

I was thinking of selecting every first vertex of every spline and braking that.
However I don't know how to select the vertex by number nor what the break function is. MaxScript recorder will only show me the subObjectlevel = 1 but not what happens after that.

Any help is much appreciated

Comments

Comment viewing options

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

.

For some reason ths code below will open only the last spline in the selection.
TRy to fix it. :)

(
	splinesArr = for s in selection where classOf s == SplineShape or classOf s == Line collect s
	for s in 	splinesArr do
	(
		select s
		max modify mode
		splineNum = numSplines s
		if splineNum > 0 do
		(
			for n = 1 to splineNum do
			(
				subobjectlevel = 1
				setKnotSelection s n #(1) keep:true
			)
			splineOps.startBreak s
			updateShape s
		)
	)
)
obaida's picture

You need to add

You need to add "windows.ProcessPostedMessages()" instead of "updateshape s"
Thanks to denisT https://forums.cgsociety.org/t/max-script-help-multi-object-selection-to...

obaida's picture
jahman's picture

.

processPostedMessages forces max to process GUI messages, why would you need it here?
just move updateShape out of the loop and that's it

obaida's picture

its not working with

its not working with updateShape even its out of the loop !!
it works with 1 shape only and not applied to other selected shapes

jahman's picture

.

oh, I see now that it uses modify mode for some unknown reason. In this case you're right that processPostedMessages is needed before switching to next shape.

I'd rather add another extra knot if the spline is closed and just make it open afterwards. This way it should work without switching to modify mode (which is always slower)

smth like this should work

delete shapes
gc()
 
s1 = Ngon nsides:7 circular:true
convertToSplineShape s1
 
s2 = copy s1 pos:(s1.pos + [s1.max.x - s1.min.x, 0, 0])
 
invec  = getInVec  s2 1 1
outvec = getOutVec s2 1 1
kt     = getKnotType s2 1 1
pt     = getKnotPoint s2 1 1
index  = case kt of
(
	#bezier       : addKnot s2 1 kt #line pt invec outvec
	#bezierCorner : addKnot s2 1 kt #line pt invec outvec
	default       : addKnot s2 1 kt #line pt
 
)
setInVec  s2 1 index invec
setOutVec s2 1 index outvec
 
open s2 1
updateShape s2

Comment viewing options

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