PDA

View Full Version : object exists?


Technofreak
04-16-2004, 11:24 PM
how do I check if my object exists in Max?
in Maya it would be:

proc checkObj()
{
string $ball[0];
if (!`objExists "ball"`)
{
$ball = `sphere -n "ball"`;
}
else
warning("ball already exists.\n");
}
checkObj();

Thanks

Bobo
04-16-2004, 11:37 PM
Originally posted by Technofreak
how do I check if my object exists in Max?
in Maya it would be:

proc checkObj()
{
string $ball[0];
if (!`objExists "ball"`)
{
$ball = `sphere -n "ball"`;
}
else
warning("ball already exists.\n");
}
checkObj();

Thanks

Pretty much 1:1 conversion:

fn checkObj =
(
if getNodeByName "Ball" == undefined then
ball = sphere name:"Ball"
else
messagebox "Ball already exists." title:"Warning"
)

checkObj()

Bobo
04-16-2004, 11:42 PM
Originally posted by Bobo
Pretty much 1:1 conversion:

fn checkObj =
(
if getNodeByName "Ball" == undefined then
ball = sphere name:"Ball"
else
messagebox "Ball already exists." title:"Warning"
)

checkObj()

Alternative:

fn checkObj =
(
if $Ball == undefined then
ball = sphere name:"Ball"
else
messagebox "Ball already exists." title:"Warning"
)

The nice thing about the original getNodeByName version is
that you can do exact case-sensitive matching,

getNodeByName "Ball" exact:true

will detect "Ball" but not "ball".

Otherwise, MAXScript is mostly case-insensitive.

Technofreak
04-19-2004, 05:36 PM
:thumbsup: "Very Impressive Mr. Anderson. " ............(scene from Matrix)


Thanks Bobo

CGTalk Moderation
01-18-2006, 02:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.