Check State

I have a script where I need to have a check state running through every object in the selection and if any of the objects are being used as a variable then DO NOT run the script.

This is what I have so far and it is not right.
Because if 2 objects are ok and 1 is a bad object, the script still runs, it does not stop after finding the bad one.

StartObj = $Sphere005
EndObj = $Sphere001
CheckSt = false
 
for i = 1 to selection.count do
(
	obj = selection[i]
	if (obj.name == StartObj.name or obj.name == EndObj.name)then
	(
		CheckSt = false
	)
	else
	(
		CheckSt = true
	)
)
 
if CheckSt == false then 
(
	messagebox "Make sure the reference objects are NOT selected"
)
else
(
	--Run Scripted Function Here
)

Comments

Comment viewing options

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

Alright

Alright I'll implement this version of it instead.
Thanks again Anubis.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

if i see, this fn s'd be

if i see, this fn s'd be called per obj,
if so, the loop s'd be out of the fn, like...

fn getState obj = (
	not (obj.name == StartObj.name or obj.name == EndObj.name)
)
 
for obj in selection do
	if getState obj then ...

my recent MAXScripts RSS (archive here)

JokerMartini's picture

Thanks

Thanks Garp,
I'll be sure to implement this.
I appreciate the help.

JokerMartini

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Garp's picture

Run your code 'manually'.

At the end of the loop, your ChechSt variable will have its value set according to the last object tested.

Try this instead

fn state_ok = 
(
  for obj in selection do
    if (obj.name == StartObj.name or
        obj.name == EndObj.name) do return false
 
    return true
)
 
if state_ok() then 
(
	--Run Scripted Function Here
)
else messagebox "Make sure the reference objects are NOT selected"

Comment viewing options

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