Community
3ds Max Programming
Welcome to Autodeskā€™s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Access material properties of an xRef Material

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
yvesadam4016
806 Views, 3 Replies

Access material properties of an xRef Material

So the backstory of what I'm trying to accomplish is that we have workflow where where use a VRaySwitchMtl with xref'd materials in it's slots to easily switch carpaints.

 

now I got the part to switch the material covered in my tool, where I switch the index of the switchMtl.

But I'd also like to change a colorpicker to the diffuse color of the chosen index's material, which is an xref material.

I have NO clue how to access those properties. I know I am supposed to be looking at the Interface: objXRefMgr section of the docs, but I can make heads nor tails of how that part works.

 

I get to this point:

obj.material[15].switchMtl[5].switchMtl[1]

which returns

object:xref

I also tried 

obj.material[15].switchMtl[5].switchMtl[1].xrefrecord 

gives me 

<MixinInterface:IXRefRecord>

and then I'm stumped.

 

So either I'm trying to accomplish something that can't be done (which I can't imagine) or I'm going to need some help here to fetch my material properties.

3 REPLIES 3
Message 2 of 4

if you have a reffered material its class is XRef_Material. Object of this class has a property #overrideMaterial which is original material with all its properties.

 

PS. there is a more correct method to get the source material : 

 

<material><XRef_Material>.GetSourceMaterial <bool>resolveNestedXRef

 

see the MXS Help for more details

 

 

Message 3 of 4

Thanks Denis. That second one is exactly what I was looking for.

 

for future reference for others, to actually access it (based on my initial shown code):

srcMat = obj.material[15].switchMtl[1].switchMtl[1].GetSourceMaterial true
show srcMat

This wil print out all accessible properties of the source material of the xRef_material.

Message 4 of 4
Anonymous
in reply to: yvesadam4016

can somebody help me, the first image is my original 3ds max file, with material and mapping set up, but when I xref this file in  new scene it show perfect in the viewport, but when I render it seems to loses the mapping. I am using corona renderer. the strange part is that only happens in this specific scene, I created new scenes to test it, and works fine.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report