View Full Version : Incremental string Names

02 February 2009, 02:26 PM
Hi guys me again..
I'm having some problems when naming the components of my rig.
I need them to build up incrementally so Leg_Left01, Leg_Left02 etc.. the way I have it set up really doesn't allow for the script to be closed an opened up to continue.
It resets it and starts from the beginning meaning I get two Leg_Left01 bones etc..

Is there a way I can use Max's way of doing things? as if you create a default box in max continuously in maxscript it will name the next box 02, 03 etc.. can I do that with my name strings?

At the moment I am using a ridiculous
X = 0
X = X + 1
"name0" + X as string

02 February 2009, 02:31 PM
if you want to do it -exactly- like max, look into 'uniqueName'. That will generate a unique object name based on the first index available.

So if you have Sphere01, Sphere02, Sphere03, and you call 'uniqueName "Sphere"', it will return "Sphere04".
On the flip side, if you deleted Sphere02 and are left with Sphere01 and Sphere03, and you call 'uniqueName "Sphere"', it will return 'Sphere02'.

So the question would be if you want it truly sequential, or the max way.

If you want it truly sequential, you'll have to get all the objects with the base name, find the highest index number (there's another thread for getting the index number as a standard integer, but if the base name is the same then a sorting of the array and then getting the last element will do), and add 1 to that.

02 February 2009, 06:18 PM
Thanks a lot ZeBoxx I knew there was a simpler way to do this... uniqueName will do perfectly. thank you

CGTalk Moderation
02 February 2009, 06:18 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.