Test for multi/sub object

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 07 July 2011   #1
Test for multi/sub object

Hi all,

I'm stuck with some script and any help would be much appreciated.

I have a maxscript that loops though the SceneMaterials and searches for a selection of textures, which names are obtained from a text file. When located a texture is placed into its opacity map.

Now the problem I have is when I get to a multi/sub object in the material list I get this error

Unknown property: "diffuseMap" in #Multi/Sub-Object:02 - Default(Standard:Material #46, Standard:Material #38, Standard:Material #39, Standard:Material #40, Standard:Material #41, Standard:Material #42)


So I need a way to test whether the current material is a multi/sub object.

Something like:
if( SceneMaterials[i] == multi/sub) then

Thanks
 
Old 07 July 2011   #2
if classof scenematerials[i] == multiMaterial
 
Old 07 July 2011   #3
if isKindOf scenematerials[i] multimaterial then...

To be complete..

Johan
__________________
Online: LinkedIn
 
Old 07 July 2011   #4
A much better way to approach this than searching through the scenematerials for scenematerials[i].diffusemap is to use the getclassinstances function. This means it doesn't matter if your map is in a multi-sub, a multi-sub within a multi-sub, a blend material, a composite etc...

example bit of psuedo code... doesn't work...

For o in getclassinstances Standardmaterial where o.diffusemap != undefined and (matchpattern o.diffusemap.bitmap.file pattern:"*something*") == true then o.opacitymap = bitmaptexture filename:(getfilenamepath o.diffusemap.bitmap.filename + getfilenamefile o.diffusemap.bitmap.filename + "_opacity.bmp")

This will then work for all StandardMaterials regardless of where they are in material heirachy.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 07 July 2011   #5
Thanks dude. That way works much better.

As a quick fix I made another script that would work on the selected material, but now I can combine them both

The funny thing is I came across that method but didn't think it applied to my situation.
 
Old 07 July 2011   #6
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



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 08:08 PM.


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