[Closed] delete all objects with word in name
Hi guys
Im looking for a way to delete all objects that have a spicific word in the name.
For example if have objects in the scean called:
Character1_anim_control-upperarm
Character1_anim_control-forearm
Character1_mesh_arm
and i want to delete all the object that have the anim part in them.
Any advice on how to do this would be great.
Cheers
Robert
The simplest thing you can do is
delete $*_anim_*
You can use any pattern and wildcards combination, for example to affect only Character1, you can obviously say
delete $Character1_anim_*
If you need multiple patterns to determine the objects, you can use the longer form
delete (for o in objects where matchpattern o.name pattern:"*_anim*" collect o)
The beauty of this form is that you can use any number of patterns and boolean operations like AND, OR etc.
For example, to delete all objects that have “anim” in their name but do NOT start with “Character1”, you can say
delete (for o in objects where matchpattern o.name pattern:"*_anim*" AND NOT matchpattern o.name pattern:"Character1_*" collect o)
Hope this helps.
If you want to just select them first, you can use wildcards with maxscript, so:
select $anim
which translates into “select any object that has “anim” somewhere in the middle of its name. note the “$” sign which tells max that you’re giving it an object name.
alternatively, if you’d like to just delete them:
delete $anim
which once again uses the $ to designate an object name and the “*” tells it the object name can start with anything and end with anything so long as “anim” is somewhere in the middle…