PDA

View Full Version : grouping similar/duplicate named objects


dehahs
07-05-2008, 01:43 PM
Hi.

i've written a script to import 3ds files into max and rename objects within each file to correspond to the file name, which is simple enough.

now i want to group all the objects of the same name as they come into max (for easier selection) but i can't figure out how to. here's the script (quite rudimentary):


impath="E:\\DI\\DI ConstructionAnimation\\3ds\\"
impcount= impath.count+3

--change the import file type as needed
impext="*.3ds"

impfile=impath+impext

igsfiles = getFiles impfile
nof = igsfiles.count

for f = 1 to nof do
(
importfile igsfiles[f] #noPrompt
impname = substring igsfiles[f] impcount 100
max select all
$.name = impname
group selection name: impname
max freeze selection
)
max unfreeze all



the problem is that the current script ends up grouping everything in the scene with the same name.

also, is there a workaround script that can select similarly named objects and group them by that same name?

thanks very much.

RustyKnight
07-07-2008, 07:11 AM
for f = 1 to nof do
(
importfile igsfiles[f] #noPrompt
impname = substring igsfiles[f] impcount 100
max select all
$.name = impname
group selection name: impname
max freeze selection
)Okay, this seems to be wrong (for what you want to do). Basically it is saying,

Import file, select ALL the objects in the scene, rename them (to the name of the file), group them and repeat...which will then rename and group all the objects already in the scene with those you have just imported...messy

Okay, firstly, I would take a look at getMaxFileObjectNames. This will allow you to get the names of all the objects in a max file without having to open it. You could then use this information to group objects together once you have imported the file.

I would next suggest you take a look at matchPattern. It provides you a means to match string values based on a wildcard pattern. This will allow you to find like named objects, based on your requirements as "simular" is very subjective.

Shane

dehahs
07-08-2008, 06:14 PM
i looked at the getMaxFileObjectNames andmatchPattern funcitons and managed to acquire arrays of duplicate named objects. but i don't know how to select objects in the array and then group them.

how do you select objects in max from an array?

thanks.

dehahs
07-08-2008, 09:46 PM
hey. nvm i figured it out, pretty simple solution in hindsight:

x = $*
select x[1]

i=1
j=i+1

while x[i].name == x[j].name do
(
selectmore x[j]
j+=1
)
group selection name: x[i].name

thanks for the help.

CGTalk Moderation
07-08-2008, 09:46 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.