Hello!
Anyone know how to delete a render layer in the new render setup using python? Right clicking on a layer and hitting delete works, but I have no idea what command it's firing to delete the layer and any associated collections/overrides. Deleting the layer node directly causes all the errors ๐
Thanks for your time and help!
Solved! Go to Solution.
Hello!
Anyone know how to delete a render layer in the new render setup using python? Right clicking on a layer and hitting delete works, but I have no idea what command it's firing to delete the layer and any associated collections/overrides. Deleting the layer node directly causes all the errors ๐
Thanks for your time and help!
Solved! Go to Solution.
Solved by danielhhhh. Go to Solution.
I just know how to remove all render layers:
import maya.app.renderSetup.model.renderSetup as renderSetup rs = renderSetup.instance() rs.clearAll()
I just know how to remove all render layers:
import maya.app.renderSetup.model.renderSetup as renderSetup rs = renderSetup.instance() rs.clearAll()
Same question, I can't delete an "specific" render layer (not all) with python with render setup.
Same question, I can't delete an "specific" render layer (not all) with python with render setup.
Wish there was a direct Python call to delete individual layers but this worked for me:
# get the renderSetup JSON data data = renderSetup.instance().encode(None) # get render layers old_layers = data['renderSetup']['renderLayers'] # filter however you want to new_layers = [x for x in old_layers if x['renderSetupLayer']['name'] != 'YOUR_LAYER_NAME'] # replace the render layers data['renderSetup']['renderLayers'] = new_layers # write the new render setup data renderSetup.instance().decode(data, renderSetup.DECODE_AND_OVERWRITE, None)
Also works with collections:
for layer in data['renderSetup']['renderLayers']: if layer['renderSetupLayer']['name'] == 'YOUR_LAYER_NAME': old_collections = layer['renderSetupLayer']['collections'] new_collections = [x for x in old_collections if x['collection']['name'] != 'YOUR_COLLECTION_NAME'] layer['renderSetupLayer']['collections'] = new_collections
Wish there was a direct Python call to delete individual layers but this worked for me:
# get the renderSetup JSON data data = renderSetup.instance().encode(None) # get render layers old_layers = data['renderSetup']['renderLayers'] # filter however you want to new_layers = [x for x in old_layers if x['renderSetupLayer']['name'] != 'YOUR_LAYER_NAME'] # replace the render layers data['renderSetup']['renderLayers'] = new_layers # write the new render setup data renderSetup.instance().decode(data, renderSetup.DECODE_AND_OVERWRITE, None)
Also works with collections:
for layer in data['renderSetup']['renderLayers']: if layer['renderSetupLayer']['name'] == 'YOUR_LAYER_NAME': old_collections = layer['renderSetupLayer']['collections'] new_collections = [x for x in old_collections if x['collection']['name'] != 'YOUR_COLLECTION_NAME'] layer['renderSetupLayer']['collections'] = new_collections
Scratch my previous reply, found a way with just a couple direct calls:
import maya.app.renderSetup.model.renderLayer as renderLayer import maya.app.renderSetup.model.renderSetup as renderSetup
rs = renderSetup.instance()
layer = rs.getRenderLayer('YOUR_LAYER_NAME')
renderLayer.delete(layer)
Scratch my previous reply, found a way with just a couple direct calls:
import maya.app.renderSetup.model.renderLayer as renderLayer import maya.app.renderSetup.model.renderSetup as renderSetup
rs = renderSetup.instance()
layer = rs.getRenderLayer('YOUR_LAYER_NAME')
renderLayer.delete(layer)
just in case someone wants to delete collections:
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.app.renderSetup.model.collection as collTool
layer = 'your_layer'
collName = 'your_collection' (can be just a part of the name)
render_setup = renderSetup.instance()
render_layer = render_setup.getRenderLayer(layer)
collections = render_layer.getCollections()
if collections:
for coll in collections:
if collName in coll.name():
collTool.delete(coll)
print 'deleted ', collName,'from',layer
just in case someone wants to delete collections:
import maya.app.renderSetup.model.renderSetup as renderSetup
import maya.app.renderSetup.model.collection as collTool
layer = 'your_layer'
collName = 'your_collection' (can be just a part of the name)
render_setup = renderSetup.instance()
render_layer = render_setup.getRenderLayer(layer)
collections = render_layer.getCollections()
if collections:
for coll in collections:
if collName in coll.name():
collTool.delete(coll)
print 'deleted ', collName,'from',layer
Can't find what you're looking for? Ask the community or share your knowledge.