TurtlesAndBacon
TurtlesAndBacon

Reputation: 13

Python for Maya: Change Display Layer to "Reference"

Is there a way to set a display layer's layer state to reference using python? It doesn't matter if the change happens at the layer's creation, or after the fact.

To provide a little context: I'm writing a script that creates image planes, pulls in a reference image with a 'standardized' image name, applies it to the image plane, moves them into place, and creates a display layer with it's state set to reference. So far, everything but setting the layer's state to reference is working.

This is an example of what I'm doing:

    front_ip = cmds.imagePlane(
    name="front_IP",
    fileName="front_ref.jpg",
    lookThrough="front",
    showInAllViews=False)
    cmds.move(0,0,-950)
    cmds.createDisplayLayer(name="front_ref_L")

Upvotes: 1

Views: 2053

Answers (2)

Keerthy Kumar
Keerthy Kumar

Reputation: 1

Where did you find your method of creating? The below code works but it needs a delay before running the reference code.

layer = cmds.createDisplayLayer()
cmds.layerButton(layer, edit=True, layerState='reference')

Upvotes: 0

Green Cell
Green Cell

Reputation: 4783

As far as I know you can't change a display layer to reference exactly at creation, but you can use setAttr to do it afterwards:

cmds.polySphere() # Create a sphere.
layer = cmds.createDisplayLayer() # Create a layer and add selected sphere.
cmds.setAttr("{}.displayType".format(layer), 2) # Change layer to reference.

Upvotes: 2

Related Questions