[Closed] object exists?
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.
“);
}
checkObj();
Thanks
Originally posted by Technofreak
[B]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.
“);
}
checkObj();Thanks [/B]
Pretty much 1:1 conversion:
fn checkObj =
(
if getNodeByName “Ball” == undefined then
ball = sphere name:“Ball”
else
messagebox “Ball already exists.” title:“Warning”
)
checkObj()
Originally posted by Bobo
[B]Pretty much 1:1 conversion:fn checkObj =
(
if getNodeByName “Ball” == undefined then
ball = sphere name:“Ball”
else
messagebox “Ball already exists.” title:“Warning”
)checkObj() [/B]
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.