Skip to content

Instantly share code, notes, and snippets.

@oglops
Last active March 26, 2021 22:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oglops/e97867bf2df1a9211ac8ce8c913c1dc4 to your computer and use it in GitHub Desktop.
Save oglops/e97867bf2df1a9211ac8ce8c913c1dc4 to your computer and use it in GitHub Desktop.
embed a model panel into script editor with xml attribute editor template in maya 2015
import maya.cmds as cmds
import maya.utils as mutils
def AEaddModelPanelModule( plug, uiLabel, annot):
paneLayoutName = cmds.paneLayout(h=300)
modelPanel = "customModelPanel"
if cmds.modelPanel(modelPanel, q=1, ex=1):
cmds.modelPanel(modelPanel, e=1, p=paneLayoutName)
else:
cmds.modelPanel(modelPanel, label="ModelPanel Test", cam='persp')
mutils.executeDeferred(
lambda *x: cmds.modelPanel(modelPanel, e=1, menuBarVisible=0))
cmds.setParent(u=1)
<?xml version='1.0' encoding='UTF-8'?>
<templates>
<template name="AEtransform">
<attribute name="frameExtension" type="maya.long">
<label>Frame Extension</label>
</attribute>
<attribute name="enumAttr" type="maya.enum">
<label>Enum Attr</label>
</attribute>
<attribute name="imageName" type="maya.string">
<label>Image Name</label>
</attribute>
<attribute name="dummy" type="maya.float">
<label>Anything you want</label>
<description language="cb">py.AEaddModelPanel.AEaddModelPanelModule</description>
</attribute>
</template>
<view name="Custom" template="AEtransform">
<property name="frameExtension"/>
<property name="enumAttr"/>
<property name="imageName"/>
<property name="dummy"/>
</view>
</templates>
createNode transform -n "ctrl_grp";
addAttr -ci true -sn "imageName" -ln "imageName" -dt "string";
addAttr -ci true -sn "frameExtension" -ln "frameExtension" -at "long";
addAttr -ci true -sn "enumAttr" -ln "enumAttr" -min 0 -max 2 -en "Green:Blue:Red"
-at "enum";
setAttr -k on ".imageName";
setAttr -k on ".frameExtension";
setAttr -k on ".enumAttr";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment