Author Topic: I need help accessing the render elements trough max script  (Read 3265 times)

2019-08-14, 18:49:55

arqrenderz

  • Active Users
  • **
  • Posts: 1079
  • https://www.behance.net/Arqrenderz1
    • View Profile
    • arqrenderz
Hi guys as the title says I need help accessing the render elements trough max script, the thing is that we are using a home brew script to manage our cameras and scenes, but sometimes the render elements are not saved and we are losing a ton of time because of this...
Another topic would be if anyone knows how to really acces the layer manager system through max script, we have an issue organizing layers when a new layer or an old one is deleted, all our layers gets scrambled.
Many thx to all.

Another this is that we use the exr images with all the render elements on it (just one big file instead of many)
« Last Edit: 2019-08-15, 01:20:42 by arqrenderz »

2019-08-15, 01:29:23
Reply #1

Njen

  • Active Users
  • **
  • Posts: 557
    • View Profile
    • Cyan Eyed
Accessing the render elements can be done by:
Code: [Select]
re = maxOps.GetCurRenderElementMgr()

Then you can do things like:
Code: [Select]
reNum = re.numrenderelements()
singleRe = re.getrenderelement 1

Accessing layers can be done with:
Code: [Select]
layermanager

Then things like this can happen:
Code: [Select]
layermanager.getLayer 1
layerManager.deleteLayerbyname "layer001"
layerManager.getLayerFromName "layer001"

2019-08-15, 01:34:14
Reply #2

Njen

  • Active Users
  • **
  • Posts: 557
    • View Profile
    • Cyan Eyed
Here are some freebie layer functions.

Delete any empty layers:
Code: [Select]
fn deleteEmptyLayers =
(
DeletedLayerCount = 0

for i = Layermanager.count-1 to 1 by-1 do
(
layer = layermanager.getLayer i
local thislayername = layer.name
layer.nodes &theNodes
layerChildren = layer.getNumChildren()
if thenodes.count == 0 and layerChildren == 0 then
(
LayerManager.deleteLayerbyname thislayername
DeletedLayerCount += 1
)
)
)

Show a layer and all of it's children:
Code: [Select]
fn showLayerAndChildren layer =
(
layerName = LayerManager.getLayerFromName layer

if layerName != undefined then
(
layerName.ishidden = false
numChildLayers = layerName.getNumChildren()
for i = 1 to numChildLayers do
(
layerChild = layerName.getChild i
layerChild.ishidden = false
)
)
else
(
print ("No layer named \"" + layer + "\"")
)
)

2019-08-15, 21:34:45
Reply #3

arqrenderz

  • Active Users
  • **
  • Posts: 1079
  • https://www.behance.net/Arqrenderz1
    • View Profile
    • arqrenderz
Hi Njen  thx!

Another question, do you know how to read or access the layer order in max?
And how to introduce new layers in a determined order, or if a new layer comes to the file how to get the new layer order?

Any time we introuduce a new layer the order of the old ones gets scrambled, and we lose all the organization of the file and layers by camera.
How do you get to know all of this code? we use the max script reference guide and a lot of interfaces don't appear on it.

A big thx again.