The exists command returns true if the argument is a valid command, subroutine, or script.
if (exists("sphere")) {
sphere; // make a sphere
}
The objExists function returns true when an object exists with a certain name:
sphere -name "george";
// Result: george makeNurbSphere1 //
print(objExists("george"));
1
print(objExists("martha"));
0
attributes on nodes: attributeExists
Use attributeExists to check whether a given attribute exists on a node. The command has the form:
attributeExists("attributeName","nodeName")
if (attributeExists("visibility","mySphere")) {
setAttr mySphere.visibility on;
}