ScriptSpot

Forum topic · Scripts Wanted

Select odd/Even Splines segment

By Tricota · 2008-08-17

Description

Hi Guys, i know this might be maybe a line, but I cannot get it work, I need the code to select odd/even spline segement.

Per example I want to do a Road Paint, so I create a spline, then Divide it, and then I have to select manualy every line in between to delete it and make the white painting. I know there should be a pretty easy script to do that

Thanks a Lot!!
Tricota

Comments (9)

Same but for vertices?

titol · 2014-01-14

Can anyone explain how to do the same but for vertices? Cheers

barigazy · 2014-01-14

You can use this fn (BTW works whit lines)
So select line and run the code


fn selectKnots spl which: = if isKindOf spl Line or isKindOf spl Splineshape do
(
	max create mode
	with redraw off for s = 1 to numSplines spl do
	(
		setKnotSelection spl s #()
		for k = 1 to numKnots spl s do
		(
			if which == #even then (if mod k 2 == 0 do setKnotSelection spl s #(k) keep:on)
			else (if mod k 2 != 0 do setKnotSelection spl s #(k) keep:on)
		)
	)
	max modify mode
	subobjectLevel = 1
)

After you run above function use next line


-- select all odd knots
selectKnots selection[1] which:#odd

or this line

-- select all odd knots
selectKnots selection[1] which:#even

Thank you

titol · 2014-01-15

YES! it works...seems to be a really long process to get it done by script but for what I need to do this is great!

Thank you very much for taking the time to reply with this!!!

Cheers

.

miauu · 2014-01-15

There was Select Even/Odd tool in Polyboost(The Tools - Tools), but why it is not implemented in RIbbon i don't know.

barigazy · 2014-01-15

For splines?

.

miauu · 2014-01-15

I doubt that it suports splines. Your snipped is more universal.
It is strange why AD not implemented all tools from PB?

barigazy · 2014-01-15

I suppose they were busy with caddies :)

.

miauu · 2014-01-15

+10 ;)

Christopher Grant · 2008-08-18

Here's a quick script that should do what you want assuming you only have 1 spline within your object (because it only works on the first spline sub object currently). In the example I tested I just created a quick line object, went to segment subobj and divided it, then ran the script.

To run this script, simply select your spline, and go to Maxscript / Run Script and run the attached file.


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

setSegSelection $ 1 selsegs 
Attachments