Notifications
Clear all

[Closed] Help with spline segment

Hi
I’m a begginer at scripting and i would need some help.
i am trying to write a script like a tool for using more in architecture ( to create road signs dashed line on the street ).

The idea is to select a spline line, to add a “normalize spline” modifier and then to delete the segments with the pair or impair no. I looked in maxscript reference but i wasn’t able to find the answer to “how to select or delete a segment from a spline ? “

for example in $line01 that has 5 segments … how to delete segments no 1, 3, 5

Thanks

5 Replies

Hi apunctg, Im a beginner too but I believe I can help. You could select the segments you wanted to delete using the setSegSelection() method and then use splineOps.delete operation to delete the selected segments. There may be other ways to do what you want but this is the method I could think of. It sounds like you want to delete every other segment so you can select the segments using a for loop using the example below.

–array to store segments to delete
segs = #()

–add every other spline to the segs array
for i = 1 to (numSegments $ 1) by 2 do
(
append segs i
)

–select segments
setSegSelection $ 1 segs

–delete segments
splineOps.delete $

note: to get this to work you may have to you may have to convert to a spline shape after adding the Normalize Spl. modifier. To convert using maxscript use the convertToSplineShape() function. You also have to be in segment selection mode on the modifier

Thanx for the reply Blanks …

A friend helped me with this lines of code:

selsegs = #()
numsegs = (numSegments $ 1)
for i = 1 to numsegs do
if (mod i 2) == 1 do append selsegs i

setSegSelection $ 1 selsegs
actionMan.executeAction 0 “40020” – Edit: Delete Objects

But it includes some actionMan .
I have now another thing to ask. I don’t know how to transform the vertices(knots) of a spline from corner to “bezier” or to “bezier corner” . This would complete my questions about what i am trying to do with this little script. I will post the entire code here when i’ll finish it.

Thanks.

yeh just swap out the actionMan statement for splineOps.delete $

To change the knot type you would use the setKnotType() method.

–$ = selected spline shape, 1 = index of spline in spline shape, 5 = index of the knot, #corner = knot Type
setKnotType $ 1 5 #corner
–call updateShape to update it in the viewport
updateShape $

search it in the max documentation for more info

Many thanks Jamell for all your support and involvement in this script !!!

The script for doing dashed lines (road markings for architecture visuals) so far is this:


Mlength = 5
Mwidth = 0.25


modPanel.addModToSelection (Normalize_Spl ()) ui:on
$.modifiers[#Normalize_Spl].length = Mlength
macros.run "Modifier Stack" "Convert_to_Spline"

	
for n = 1 to (numSplines $) do
	(

		
		selsegs = #()


		for i = 1 to (numSegments $ n) by 2 do
		(
			append selsegs i
		)

		subobjectLevel = 1


		
			for k = 1 to (numKnots $ n) do
				(
					setKnotType $ n k #bezier
					updateShape $

				)
			
		setSegSelection $ n selsegs


	)
	

subobjectLevel = 2
splineOps.delete $  
subobjectLevel = 0
	



$.render_renderable = true
$.render_displayRenderMesh = true
$.render_rectangular = true
$.render_length = 0.01
$.render_width = Mwidth

convertToMesh $


hope to get an answer to your post to figure out this problem.

thanx again.

I would add a sweep modifier with real world mapping and do your dashes in the material…

opps I don’t mean I would…

I mean I do…