Notifications
Clear all

[Closed] uniqueName a part

Is there an easier way to make a unique name for section of a name.
Example being. I have these objects in the scene

doug_guide_arm001_l_001
doug_guide_arm001_l_002
doug_guide_arm001_l_003
doug_guide_arm001_l_004

doug_guide_arm001_r_001
doug_guide_arm001_r_002
doug_guide_arm001_r_003
doug_guide_arm001_r_004

doug_guide_hip001_m_001

I collect all the objects with same guide type name
guideType = “arm”
for obj in helpers where (matchPattern obj.name pattern:(“” + guideType + ““)) collect obj
now is there an easy way to version this number up. Scanning the collected objects and incremental it by 1 leaving the 3 digit padding and then returning the new name within a function.

so ideally ill supply a function a name and it will return the unique name.

resulting in
doug_guide_arm002_l_001

20 Replies
2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

why is not [color=Red]doug_guide_arm001_l_005[/color]?

(@jokermartini)
Joined: 11 months ago

Posts: 0

I want to group each arm so if there are multiples arms it would go

arm001_l_001 –left collarbone
arm001_l_002 –left shoulder
arm001_l_003 –left forearm
arm001_l_004 –left wrist

arm002_r_001 –right collarbone
arm002_r_002 –right shoulder
arm002_r_003 –right forearm
arm002_r_004 –right wrist

so if i created another arm it would be

arm003_r_001 –right collarbone
arm003_r_002 –right shoulder
arm003_r_003 –right forearm
arm003_r_004 –right wrist

 3ak
pat = "arm001"
execute ("select $helpers/*"+pat+"*")
for obj in selection do	obj.name = replace obj.name (pat.count-1 + findstring obj.name pat) 1 "2" 

What I came up with is more complex than it might need to be.


guideType = "spine"
exGroups = for obj in helpers where (matchPattern obj.name pattern:("*" + guideType + "*")) collect obj.name
txt = for itm in exGroups where (findString itm guideType) != undefined collect (findString itm guideType)
existingValues = #()
for v = 1 to exGroups.count do
(
	ver = (substring exGroups[v]  (txt[v]+guideType.count) 3) as integer + 1
	newVersion = (FormattedPrint ver format:"3.3d") as string --//Adds "v" plus 3 digit padding
	print newVersion
)

I first need to find the highest groupNumber before increment it by 1. Otherwise it would still be incorrect.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

so the function has to split a name on header, name, group index, type, and node index. after that we can talk about incrementing a part.

you rule is too special to be a general. so the function needs some guidance… about the part of the name that has to be incremented.

if you have group indexes 1,2,and 5 what the next available is 3 or 6?

This is my format
doug_guide_spine001_m_001
doug_guide_spine001_m_002
doug_guide_spine001_m_003

katie_guide_leg001_m_001
katie_guide_leg001_m_002
katie_guide_leg001_m_003

1.Character Name
2.Control “guide” –ex: guide,bone,control etc. doesn’t matter really for this.
3.Type + GroupNumber (3 digit padding)
4.Location –ex: l (left), m (middle), or r (right)
5.Node Index –UniqueName done in maxscript on point helper creation.

6 would be the next number.
It doesn’t matter if it is perfectly incremental by 1, as long as it is unique. That is more important.

definitely the regex might be a solution. we need to write the right one let’s try

The main reason behind the whole grouping through is so i can add multiple limbs or whatever it may be and manage them in a way that I feel is best. I appreciate the help.

Page 1 / 2