Removes 2 verticles splines from the multuiple EditableSpline objects

here is have script which do the job to remove 2-vertices splines from the Editable Spline objects, however I'm failed to make it work on multiple EditableSpline objects selected please help
<code>
fn deleteSplinesWithTwoVerts obj =

(

    if classof obj == Editable_Spline or isKindOf obj SplineShape then 

    (

        subObjectLevel = 1 -- switch to spline sub-object level

        

        for i = obj.numSplines to 1 by -1 do -- Iterate through splines from last to first to avoid reindexing issues when deleting

        (

            if (numKnots obj i) == 2 then

                deleteSpline obj i

        )

 

        subObjectLevel = 0 -- reset to object level

    )

    else

    (

        messageBox "Please select an EditableSpline object."

    )

)

 

-- Execute function

deleteSplinesWithTwoVerts selection[1]

</code>

Comments

Comment viewing options

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

.

(
	function DeleteSplinesWithTwoVerts obj =
	(
		for i = numSplines obj to 1 by -1 where ((numKnots obj i) == 2) do deleteSpline obj i
		updateShape obj
	)
	for o in selection where classof o == line or classOf o == splineShape do DeleteSplinesWithTwoVerts o
)

Comment viewing options

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