stop loop or script

Hi Everyone this is my script and what i cant seem to figure out is how to stop the script right after it gives the messagebox "please Redo Balls" so it doesn't play to SPH2

(
)
obj = $SPH1
if obj == undefined then messagebox "please Redo Balls"
else
(
selectmore $SPH1
)
obj = $SPH2
if obj == undefined then messagebox "please Redo Balls"
else
(
selectmore $SPH2
)

thanks in advance.

Comments

Comment viewing options

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

thanks everyone!!!!

thanks everyone!!!!

pixamoon's picture

`

if you use loop "for ... do...." you can use just "exit"

it can look like this:

objArray = #($SPH1, $SPH2)
for obj in objArray do 
(
	if obj == undefined then 
		(
		messagebox "please Redo Balls"
		exit
		)
	else
	selectmore obj
)

cheers,
Pixamoon

miauu's picture

.

Regarding maxscript reference file using the EXIT command must be avoided as much as possible, so you can use:

objArray = #($SPH1, $SPH2)
stopLoop = false
for obj in objArray while stopLoop == false do 
(
	if obj == undefined then 
	(
		messagebox "please Redo Balls"
		stopLoop = true
	)
	else
	        selectmore obj
)
pixamoon's picture

`

good to know :)

I checked maxscript help and found only that "exit" can be extremely slow, but didn't find any info to avoid it "as much as possible". Can you post a link to that ?

best,
Pixamoon

miauu's picture

.

The exact words in maxscript reference are "Do not use return, break, exit or continue."

Here is the link.

pixamoon's picture

`

ah, that's true

This is in chapter "How To Make It Faster" - how to make scripts faster

There is also "Disable Undo system when possible" and more...

But sometimes is good to use undo :)

Of course is good to know those functions can make scripts slower.

Thanks,
Pixamoon

Comment viewing options

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