remoove submaterial from multimaterial

Become a member of the CGSociety

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

 
Thread Tools Display Modes
  06 June 2018
remoove submaterial from multimaterial

Is there a way to remoove submaterial with ID i from multimaterial? I maxscript documentation havenīt found such posibility.
 
  06 June 2018
I'm not sure what are you trying to do, the most simple solution I can think of is:

fn removeSubmaterial mat id = (
    for i = 1 to mat.materialList.count do (
        if (mat.materialIDList[i] == id) do (
            mat.materialList[i] = undefined
        )
    )
)
-- remove ID 4
removeSubmaterial $.material 4
 
  06 June 2018
Originally Posted by gtafan: Is there a way to remoove submaterial with ID i from multimaterial? I maxscript documentation havenīt found such posibility.
Try harder on documentation
Originally Posted by mxs reference: setSubMtl  <material> <index> <material>
This method sets the indexed sub material of the material to the specified material.
 
  06 June 2018
Sorry people, but I asked how to remoove submaterial from multimaterial, not set submaterial. Remoove specialy means that the number of submaterials will shrink.
 
  06 June 2018

fn RemoveSubMaterial mtl ID = if isKindOf mtl Multimaterial do (

   index = findItem mtl.materialIDList ID
   
   if index > 0 do 
   (
      deleteItem mtl.materialList index
      deleteItem mtl.materialIDList index
      deleteItem mtl.names index
   )
   
)

Last edited by Serejah : 06 June 2018 at 03:21 PM.
 
  06 June 2018
Originally Posted by Serejah:

fn RemoveSubMaterial mtl ID = if isKindOf mtl Multimaterial do (

   index = findItem mtl.materialIDList ID
   
   if index > 0 do 
   (
      deleteItem mtl.materialList index
      deleteItem mtl.materialIDList index   
   )
   
)
Sorry, but what is ID in your code? Isnīt ID the same as index? Also donīt I need to do this to?


fn RemoveSubMaterial mtl ID = if isKindOf mtl Multimaterial do (

   index = findItem mtl.materialIDList ID
   
   if index > 0 do 
   (
      deleteItem mtl.materialList index
      deleteItem mtl.materialIDList index
      deleteItem mtl.names index   
   )
   
)

Last edited by gtafan : 06 June 2018 at 11:28 AM.
 
  06 June 2018
So whatīs the diference between ID an index in that code?
 
  06 June 2018
ID is the face material ID
index is the material index in materiallist

And yes, you definitely need to delete names as well.
 
  06 June 2018
Originally Posted by Serejah: ID is the face material ID
index is the material index in materiallist

And yes, you definitely need to delete names as well.
OK thanks, just to make it more clear, let say I have multimaterial with materialIDList looking like this: (1, 2, 3, 4) and I delete the submaterial with ID 3, will it bekome (1, 2, 4)?
 
  06 June 2018
Looks like we also forgot about mapEnabled array, so think the code must look so:


fn RemoveSubMaterial mtl ID = if isKindOf mtl Multimaterial do (

   index = findItem mtl.materialIDList ID
   
   if index > 0 do 
   (
      deleteItem mtl.materialList index
      deleteItem mtl.materialIDList index
      deleteItem mtl.names index
      deleteItem mtl.mapEnabled index   
   )
   
)


Not easy to delete submaterial.
 
reply 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 02:38 AM.


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