ScriptSpot

Forum topic · General Scripting

attaching multiple splines

By remykonings · 2019-01-20

Description

Hi,

I can't seem to find clearly how this should work. I like to select a bunch of splines and then executing a script to attach all of them into a single spline, from there to move that spline to z=0.

I've been searching and reading at the help menu at "attach()" but i still find it hard to bring it together yet.

Some help is appreciated :)

Comments (3)

.

miauu · 2019-01-21


(
	function AttachSplines sp splines: =
    (    	
    	convertToSplineShape sp
    	for s in splines where s != sp do addandweld sp (converttosplineshape s) -1
    	sp
    )
    
	if selection.count != 0 do
	(
		splObjsArr = for o in selection where canConvertTo o SplineShape collect o
		newSpl = AttachSplines splObjsArr[1] splines:splObjsArr	
		newSpl.pos.z = 0
	)
	
)

The code will move the spline to z=0 not all of its knots.

*

remykonings · 2019-01-24

Thank you, that works great.

UtilitiesEx.attachAll

johnim · 2019-01-21

try this:
UtilitiesEx.attachAll (selection as array)
for k in selection do (k.pos = [k.pos.x,k.pos.y,0] ; k.pivot = ((k.max + k.min)/2))