Checking for Existing Names

Add this script to a "Batch Script" editor (F10) and execute it with Script > Run.

The script compares all nodes against a given name, prints out a message if the name has been found, and selects the appropriate node. If the object does not exist you will also get a message.

The script's output is formatted and the name of the searched object is printed in quotes ("Cube03"). To do this, a so-called escape character is used before the quote mark (\"):

# Define which name you want to look for, create empty list and get the scene's nodes
checkForName  = "Cube03"
nodeNames     = []
nodeSelection = []
sceneNodes    = scene.getNodes()

# Loop through the nodes and add every node's name to the "nodeNames" list
for entry in sceneNodes:
	nodeNames.append(entry.getName())

# If the search name is part of "nodeNames" print out a message and select the node
if (checkForName in nodeNames):
	scene.message("Object \""+checkForName+"\" exists.")
	nodeSelection.append(scene.getNode(checkForName))

# Otherwise, print out that the name has not been found 
else:
	scene.message("Object \""+checkForName+"\" ist not part of the project.")
 
scene.selectNodes(nodeSelection, True)