Notifications
Clear all

[Closed] Replace Object

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:-)

2 Replies

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”…

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, 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