Search code examples
scriptingattributesmayamel

Attribute template in Maya


I am working in Maya 2014. I have my custom attributes showing in the Channels Box. I am now trying to show my custom attributes in the Attribute Editor. I have an AETemplate file called AECamera_OrthoTemplate.mel code below:

global proc AECamera_OrthoTemplate( string $nodeName ) {    

    editorTemplate -beginScrollLayout ;
    editorTemplate -beginLayout "Camera" -collapse 0 ;
    editorTemplate -label "Always Show Frustrum" -addControl "boolAttr" ;
    editorTemplate -label "Frustrum NearZ" -addControl "numAttr" ;
    editorTemplate -label "Frustrum FarZ" -addControl "numAttr" ;
    editorTemplate -label "Frustrum Width" -addControl "numAttr" ;
    editorTemplate -label "Frustrum Height" -addControl "numAttr" ;
    editorTemplate -endLayout ;

    // Currently editing values on the shape object,
    // so drag in the shape attributes as well
    AEshapeTemplate $nodeName ;

    editorTemplate -addExtraControls ; 
    editorTemplate -endScrollLayout ;
}

When viewing the Attribute Editor with my custom camera shape selected I see the open Camera layout with nothing inside it and the controls all appear to be placed inside the Extra Attributes layout section right at the bottom. I want to see those controls nested in the Camera section.

Any help to get me past this hurdle would be appreciated,

Thanks.


Solution

  • I had misunderstood the -addControl flag, it requires the name of the attribute rather than the type of control to create.

    It auto-magically deduces the control type from the attribute when it is recognized.

    The reason the controls were ending up in the extra attributes section is due to Maya being clever and putting any unknown attributes into this section.

    Hope this is helpful to someone else.