selection prefix
I want to select objects based on their name.
Example:
I have a master control called "Bunnies_ctrl"
I have 3 helper objects called "Bunnies_helper"
I have 3 helpers objects called "Bunnies_temp"
First how do I collect the prefix of the selected objects name? I want to collect all the characters until i get to the underscore "_" so the result of the variable would then be "Bunnies"
Then I would use that variable to select the other helper objects. For example
select "Bunnies" + "_helper"
select "Bunnies" + "_temp"
The reason I want to collect the prefix is because it changes from "Bunnies" to "Donuts"
Comments
Search name up to "_"
How could I do this then.
Say for example I have all these objects in the scene
"donut_helper01"
"bunnies_pt04"
"cup_ctrl06"
I want to be able to select those objects and have a function that automatically finds the prefix and then stories it in a variable. That prefix is all the characters up till it his the underscore "_". Because the names of the objects could be anything but they always will have an underscore breaking up the prefix.
so the result would be
"donut"
"bunnies"
"cup"
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
I got it
I got it figured out here. Thank you very much for your help brot.
ObjName = $.name as stringStream ObjPrefix= readDelimitedString ObjName "_"
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
hey thanks for showing that
hey thanks for showing that one :P
Never get low & slow & out of ideas
Hey, to find a string within
Hey,
to find a string within another string you can use the "findString" method.
It will give you an index to work with, if the string is found. You could do a search for a "_" in the name of an object and, if it is found, all characters of the objects name up to that index are your prefix. You could then use a for loop from 1 to index-1 to construct a new string that is your prefix, or use the "substring" method to extract that part of the name.
To change part of object names you could do a search and replace like this:
Cheers
Never get low & slow & out of ideas