PDA

View Full Version : Replace Object


igor333
01-04-2005, 07:40 PM
Hi,
I have two max files :
1) few groups with lots of objects in each group.
2) One object with material and texture on it.

I need to open each group, then to replace each object with the object in the second
file (object without material ---> object with material)
This is what I have done for now:
group_name = #()
Obj_name = #()
count = 0
group_arr = #()
fobj_names = #()
objs_in_group_arr = #(#())
for i= 1 to selection.count do
(
group_flag = true
if classof(selection[i].baseobject) == Dummy then
(
append group_arr selection[i]
group_flag = false
count = count + 1
group_name = filterString selection[i].name "."
objs_in_group_arr[count] = #()
)
if (group_flag == true) then
(
Obj_name = filterString selection[i].name "."
if(Obj_name[1] == group_name[1]) then
(
append objs_in_group_arr[count] selection[i]
)
)
)
fobj_names = getmaxfileobjectnames "second.max"
mergemaxfile "first.max" fobj_names #select
for i = 1 to group_arr.count do
(
-- It doesn't work from here,I need to replace it in a different way
new_mesh = meshop.cloneFaces selection[1] selection[1].faces
setGroupOpen group_arr[1] true
for j = 1 to objs_in_group_arr[i].count do
(
new_mesh.position = objs_in_group_arr[i][j].position
delete objs_in_group_arr[i][j]
)
)

I have problems with the replace code.
1) Should i use the cloneFaces command to copy the object?
2) Is it true to just replace the objects positions and then delete the old one?
3) Is it a shortest way to select the objects from each group?

Thanks:-)

galagast
01-05-2005, 02:39 AM
new_mesh = meshop.cloneFaces selection[1] selection[1].faces
setGroupOpen group_arr[1] true
I may be mistaken, as ive only browsed through your script.. since u declared a for loop , i guess that "1" shud be "i"... :)

Kramsurfer
01-05-2005, 03:02 AM
I would...

1 - X-ref Object the single object from your one file into the "big" file. When you make changes to the single object it will update in the file with all the objects in it...

2 - Use Blur's "Replace Object" Script, found in the blur script pack available on www.ScriptSpot.com (http://www.ScriptSpot.com), to replace all the objects in the big file with the X-ref Object. You may have to ungroup them, but just do them one group at a time...

Good Luck

Keith Morrison
focus360.com

CGTalk Moderation
01-20-2006, 09:00 AM
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.