I work in layers, so everything has a place. I found a script that will assign an Object ID to everything on each layer, which is AWESOME. Now I want to automate the MultiMatteElement creation. I have 22 layers, so instead of creating 22 MultiMatteElement manually, typing the next three Object ID numbers in each MultiMatteElement, how can that be automated? Is this wishful thinking?
Someone else maybe has a more elegant method - but for now, you could simply create a load of multimattes with corresponding ids in a blank scene and then merge those into whatever scene you need them.
Then you just need to delete the ones you don’t need ![]()
This might do what you’re looking for.
I saw that, but I don’t need material ID’s, I need Object ID.
Here you go… Just change the “MMEnumber” to the number of objectID channels you need and execute the script. I’d recommend trying in an empty file first.
--setMMEnumber to desired number of ObjectID's
MMEnumber=0
re = maxOps.GetCurRenderElementMgr()
el = multimatteelement
if MMEnumber>0 then
(
for i = 1 to MMEnumber by 3 do
(
reName="MME " + i as string + "-"+ ((i +2) as string)
re.addrenderelement (el elementname:(reName) R_gbufID:(i) R_gbufIDOn:(on) G_gbufID:(i+1) G_gbufIDOn:(on) B_gbufID:(i+2) B_gbufIDOn:(on) )
)
)
I will try that. I lost the script I found to do the Object ID by layer. I’ll look for that again and give your script a try.
I get this
-- Syntax error: at ), expected <factor>
-- In line: )
Here is the script that allowed me to create Object ID’s for everything on each layer.
(
try(destroyDialog Test)catch()
rollout LayerMultiMatte “Layer MultiMattes” width:162 height:77
(
button ‘Create_Btn’ “Button” pos:[10,16] width:142 height:43 align:#left
fn GetUsedGBufferChannels sel =
(
MakeUniqueArray (for o in (if sel == false then objects else selection) where o.gbufferchannel != 0 collect o.gbufferchannel)
)
fn GetLayerNameByGBufferChannel index =
(
local layer_name
for o in objects while layer_name == undefined where o.gbufferChannel == index do layer_name = o.layer.name
layer_name
)
fn setLayerObjID ignoreEmptyLayers:on =
(
local getlayer = LayerManager.getlayer, layer, idx = 0
if not ignoreEmptyLayers then
(
for i = 0 to layerManager.count-1 where ((layer = getlayer i).nodes &objs; objs).count > 0 do objs.gbufferChannel = i+1
)
else
(
for i = 0 to layerManager.count-1 where ((layer = getlayer i).nodes &objs; objs).count > 0 do objs.gbufferChannel = (idx+=1)
)
)
on Create_Btn pressed do
(
setLayerObjID() -- this will ignore empty layer (id order 1,2,3,4,5 …)
if matchpattern (renderers.current as string) pattern:“V-Ray*” == true then
(
re = maxOps.GetCurRenderElementMgr()
VRay_mask_elements = for i=0 to re.NumRenderElements() where classof (re.GetRenderElement i) == MultiMatteElement collect re.GetRenderElement i
for gbuffer_index in GetUsedGBufferChannels false do
(
exclude = false
for m in VRay_mask_elements where m.R_gbufID == gbuffer_index do exclude = true
if not exclude then
(
layer_name = GetLayerNameByGBufferChannel gbuffer_index
mm = MultiMatteElement elementName:layer_name R_gbufIDOn:true R_gbufID:gbuffer_index G_gbufIDOn:false G_gbufID:0 B_gbufIDOn:false B_gbufID:0
re.AddRenderElement mm
)
)
)
)
)
createDialog LayerMultiMatte
)
Did you by chance run it in the listener rather than the editor? I get the same thing if I just run it in the listener and hit enter on the numpad. You can run it from the listener, just highlight everything and hit numpad enter.
Okay, that worked. I am not sure if it was I didn’t have it highlighted or the keypad enter. However, I got that far with the other script. I was hoping to get something to make the many MultiMatteElement
elements. Right now I have to make 23 MultiMatteElement and change the RBG digits in each one. It isn’t the end of the world, but that will be a pain.
The Power Mask script does it, but not with G-buffer.
SUCESS!
That’s all that script does is make MMEs. Give it the number of g buffer ID’s you need and it will generate multiple MMEs with sequentially numbere rgb channels.
It didn’t do anything for me. I did find a script that worked.
Did you change the “MMEnumber” in the script? Otherwise it won’t do anything.
Yes, the first one.
MMEnumber=26
Weird then. Works perfectly here but I’m on vray next and 2019 so maybe that has to do with it. Glad you got your problem solved regardless.