CGTalk > Software Specific Forums > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 03-28-2013, 01:31 PM   #1
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 122
Assigning MutiSubs from Scenematerials

Hi

Im looping over all the materials in a scene and as such assigning one to some geo if its the correct material, this works for Standard Materials but when i apply similar logic, but with the submats taken into consideration, it fails and assigns undefined effectively removing the material, why?

I know its the correct material and i know its in the scene because im putting it to the Material editor so i can even see it but even then when assigning it via the material editor it fails?

Code:
for obj in objs do ( for m in sceneMaterials do ( --check some stuff, find the material if bFoundMat == true then ( obj.material = m -- FAILS assigns undefined max mtledit meditMaterials[7] = sceneMaterials[m.name] -- WORKS i can see the material in the editor obj.material = sceneMaterials[m.name] -- FAILS assigns undefined obj.material = meditMaterials[7] -- FAILS assigns undefined ) ) )



any help understanding what is going on would be appreciated


Thanks
 
Old 03-28-2013, 03:07 PM   #2
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,099
Send a message via ICQ to denisT
what OBJ in your sample is? does it assign UNDEFINED or leave whatever it was?
 
Old 03-28-2013, 03:52 PM   #3
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 122
its an array of geo objects, ePoly/eMesh

And it assigns undefined removing the material that is currently on it
 
Old 03-28-2013, 03:58 PM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,099
Send a message via ICQ to denisT
what is the class of sceneMaterials[m.name]
 
Old 03-28-2013, 04:01 PM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,099
Send a message via ICQ to denisT
what FORMAT says:
Code:
for obj in objs do ( for m in sceneMaterials do ( --check some stuff, find the material if bFoundMat == true then ( obj.material = m -- FAILS assigns undefined meditMaterials[7] = sceneMaterials[m.name] -- WORKS i can see the material in the editor format "% >> % >> % = %\n" m obj.material sceneMaterials[m.name] (m == sceneMaterials[m.name]) ) ) )


i think that another part of your code wipes the material
 
Old 03-28-2013, 05:53 PM   #6
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 122
the material exists, i can get it to be one of the slots in the materials editor, it just never assigns to the geo
 
Old 03-28-2013, 06:12 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,099
Send a message via ICQ to denisT
Quote:
Originally Posted by broomy
the material exists, i can get it to be one of the slots in the materials editor, it just never assigns to the geo

what format does print?
 
Old 04-02-2013, 02:35 AM   #8
broomy
Potatoe
Dave Broomfield
Halifax, Canada
 
Join Date: May 2006
Posts: 122
I don't have that code any more so cant tell you what it prints sorry
I had to get it done quick and as such just generated the new sub mate on each object and wrote a simple cleaner that then consolidated any materials that had all the same diffuse maps
 
Old 04-02-2013, 02:35 AM   #9
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:03 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.