Remember 3December
Find out where to celebrate your 3D CG art...
  • 1/3
You are here:Forum Home / Autodesk 3ds® Max® / MaxScript / Instance Replace - How to keep materials?
  RSS 2.0 ATOM  

Instance Replace - How to keep materials?
Rate this thread
 
36323
 
Subscribe to this thread
avatar
  • El-d
  • Posted: 04 November 2009 11:50 AM
  • Total Posts: 26
  • Joined: 2006-10-24 08:24:38

Hi All,

I’m using instance replace to ... errmm obviously replace a series of objects with an instanced one.

The issue I have is that it doesn’t keep the materials for the original object but uses the object to be replaced material.

Am i just being blind and missing something obvious or does it not transfer the material as well?

To demonstrate, the original script that I cannibalised is as follows.

-- Author :  HanyElTiby mailto:Ha_tiby@Hotm*****
-- 
Version:  3ds max 4
--
-- 
--***********************************************************************************************
-- 
MODIFY THIS AT YOUR OWN RISK

rollout Instance_Replace 
"Make instances" width:200 height:100
(
 pickbutton btn1 
"Pick_master" pos:[85,9] width:100 height:23
 label lbl1 
"Master Object :" pos:[10,12] width:75 height:20
 button btn3 
"Make Instances" pos:[10,40] width:176 height:23
 on btn1 picked obj 
do
 
(
 
global Master_Obj obj
 btn1
.text obj.name
 )
 on btn3 pressed 
do
 for 
i in selection do instancereplace i Master_Obj
)
rollout Help 
"Help" width:200 Height:60
(
 label lbl5 
"1 : Pick master Object first                    2 : Select Objects to be instances then press Make Instances button" pos:[10,10] width:180 height:45

)
-- create the rollout window and add the  rollout
if InstanceReplaceFloater != undefined do
 
(
 closerolloutfloater InstanceReplaceFloater
 ) 
InstanceReplaceFloater 
newRolloutFloater "InstanceReplace" 210 120 
addRollout Instance_Replace InstanceReplaceFloater
addRollout Help InstanceReplaceFloater rolledup
:true

Cheers

El-d



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 7088
  • Joined: 2007-08-07 03:06:12

I’m afraid the help is quite clear on this. Materials are NOT instanced from the source object to the destination object.

All you should need to do is assign the material from the one to the other:-

on btn3 pressed do
   
(
   
for i in selection do 
      
(
      instancereplace i Master_Obj
      i
.material Master_Obj.material
      )
   )

Material assignments like that are automatically instances unless you specifically ask for a copy.



Max 4.2 through 2010, XP-Pro 64 SP2.
NVidia 8800GTX-768 (Driver 185.85).
Core 2 Quad Q6600 2.4GHz, 4Gb Ram, 4Gb Swap, DX9.0c.

Attachment Attachment
Replies: 1
/img/forum/dark/default_avatar.png

Thanks again… a bad habit of mine just skimming text.
El-d

Author: El-d

Replied: 05 November 2009 06:50 AM  




   
  Settings Choose Theme color: