Background Image Script?

 From:  Michael Gibson
6162.20 In reply to 6162.19 
Hi FDP,

> Is there a way to select objects by name and then change that name?
> E.g. objectpicker(object.objectname == "Unnamed")?

You can get an object list of all current objects by doing moi.geometryDatabase.getObjects(); then if you want to only target "unnamed" objects look for objects that have a .name property that returns an empty string which is represented in JavaScript by just 2 quotes with nothing inside of them.

Here's an example:

code:
function SetObjectNames( newname )
{
	// Set any unnamed objects to have the given name.

	var objects = moi.geometryDatabase.getObjects();
	
	for ( var i = 0; i < objects.length; ++i )
	{
		var obj = objects.item(i);
		
		// An "unnamed" object will have an empty string as its name property.
		if ( obj.name == '' )
			obj.name = newname;	
	}
}


So a call to this function like: SetObjectNames( 'flimflam' ); will set any unnamed objects to have the name 'flimflam', but would not change objects that already have a name.

- Michael