View Full Version : Extract number from object name?

01 January 2009, 04:18 PM
....and then use it as an integer?

Is this possible?

Basically, i'm trying to use it as a multiplier. If the object name is object04, i want to multiply by 4, etc.

I'm admittedly not not much for scripting, but i've got a string of objects i'm trying to wire together, and this would save a lot of manual editing if I can just copy an object 100 times or so that has the wire code embedded in it.

01 January 2009, 06:01 PM
You can collect the objects into an array and use the index as multiplier (methinks)

theObjects = $object* as array
sort theObjects --if you didn't create the objects in the right order or renamed them
for i in 1 to theObjects.count do
theObject = theObjects[i]
Multipier = i

Might work :D

Edit: Missed a line... :banghead:

01 January 2009, 06:23 PM
Note that Piflik's approach will always start at one, even if the first object in the (sorted) array is, say, Sphere05.

Here's another approach:

obj = $GeoSphere05
$GeoSphere:GeoSphere05 @ [0.000000,0.000000,0.000000]
numberString = subString ((trimRight "0123456789").count + 1) -1
numberInt = numberString as integer

01 January 2009, 06:34 PM
nevermind :)

02 February 2009, 02:40 PM
I did a lot more searching and found the tank tread tutorial and was actually able to adapt that to what I was trying to do.

Took a while since I don't really know scripting, but it worked and I actually learned a little bit, too.

Thanks :)

CGTalk Moderation
02 February 2009, 02:40 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.