How to continue the auto-increment of names


#1

Hi,

I’m currently working on a script to rig dynamic ropes and I’m confronted to a renaming problem.

When I create the first rig in the scene everything is great:love:. But if I run the script again, maya start to mess up in the renaming process.

On the first run of the script auto-incrementation of the names causes no problem as I carefully store names in variable for reuse. But in the end of my script, I group my objects by category to avoid having 10k object in my outliner. And there’s the trick, long names changes and maya do not continue the auto-increment on the short names.

Well, actually, it only does it halfway. Meaning that the first object I create on the second run of the script is not incremented, but the second will have a correct incrementation in the whole scene.

Like that:

//first run
Section
Section1
Section2
Section3

//second run
Section
Section4
Section5
Section6

:curious:
So I’m quite confuse…

Is there a way to automatically increment this first name, or do I have to check all the names by myself in the script ?


#2

would it be possible to look at ur script?

an idea…

string $name = “Section”;
int $i;
string $newName = ($name + $i);
rename $name $newName;


#3

for now I Have this :


 	int $j;
 	for ($j = 0; $j < $number_Of_CVs; $j ++)
 	{
 
 		select -r $Ptemp1[0] $Ptemp2[0] $Ptemp3[0];
 
  		$Gtemp = `group`;
  		$Gtemp = `rename $Gtemp Section`;
  		$GrpList[$j] = $Gtemp;
 	}
  

It barely works (and i really don’t understand why) because this didn’t…


 	int $j;
  	for ($j = 0; $j < $number_Of_CVs; $j ++)
  	{
  
  		select -r $Ptemp1[0] $Ptemp2[0] $Ptemp3[0];
  
  		$Gtemp = `group -n Section`;
  		$GrpList[$j] = $Gtemp;
  	}
 

but with the first code, I still end up with my duplicated name…


#4

Try concatonating this when naming:
“_#”;

It should increment when necessary.
If you are still having trouble, post your script :slight_smile:

Good Luck.


#5

Thanks Pyrokinesis !

simple and useful!

I will definitively keep that trick in mind…


#6

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.