I'm adding custom attributes to light nodes and having problems with attribute editor. Currently I use:
scriptJob -permanent -e DagObjectCreated "AddExtraLightAttrs"; If AttributeEditor is already open when I create new light, new attrs are added _after_ AE refresh - this results in total mess in AE. If light is created before AE open, everything displays correctly, even subsequent light creations - so this has smth. to do with AE initialization/caching ... I've used this technique in the past, but now I create ramp attributes, which seem to be causing trouble. What can I do to fix this? Is there better alternative to scriptJob? I did a quick test with registering an API callback: OpenMaya.MDGMessage.addNodeAddedCallback which in turn calls a AddExtraLightAttrs MEL, but this doesn't seem to fix this. Or maybe I can make light AETemplate more bulletproof. I've also heard that new Maya allows to subclass lights to better handle custom attrs, but I couldn't find any docs for that. This is the code that adds a ramp attr: proc AddExtraLightAttrs_Ramp(string $node) { //color ramp addAttr -longName "ColorGradient" -attributeType "compound" -multi -numberOfChildren 3 $node; addAttr -shortName "ColorGradient_Position" -attributeType "float" -parent "ColorGradient" $node; addAttr -shortName "ColorGradient_Color" -attributeType float3 -storable 1 -parent "ColorGradient" $node; addAttr -shortName "ColorGradient_ColorR" -attributeType "float" -parent "ColorGradient_Color" $node; addAttr -shortName "ColorGradient_ColorG" -attributeType "float" -parent "ColorGradient_Color" $node; addAttr -shortName "ColorGradient_ColorB" -attributeType "float" -parent "ColorGradient_Color" $node; addAttr -shortName "ColorGradient_Interp" -attributeType "enum" -enumName "None:Linear:Spline:Smooth" -parent "ColorGradient" $node; //ramp index type addAttr -longName "ColorGradientInput" -attributeType "enum" -enumName "Distance:Intensity:Angle:IntensityAngle" $node; addAttr -longName "ColorGradientInputMaxPoint" -attributeType "float" $node ; addAttr -longName "ColorGradientMix" -attributeType "float"$node; setAttr ($node + ".ColorGradientInputMaxPoint") 1; } And this is part of modified AEspotLightTemplate: global proc AEspotLightTemplate ( string $nodeName ) { AEswatchDisplay $nodeName; editorTemplate -callCustom ("AEspotLightPreviewPortNew " + $nodeName ) ("AEspotLightPreviewPortReplace " + $nodeName ) "coneAngle"; editorTemplate -beginScrollLayout; editorTemplate -beginLayout (uiRes("m_AEspotLightTemplate.kSpotLightAttr")) -collapse 0; AElightCommon $nodeName; // THIS PART IS NEW editorTemplate -beginLayout "Colour Gradient" -collapse 0; AEaddRampControl($nodeName + ".ColorGradient"); editorTemplate -addControl "ColorGradientInput"; editorTemplate -addControl "ColorGradientInputMaxPoint"; editorTemplate -callCustom "AEmfdlSlider_New" "AEmfdlSlider_Replace" "ColorGradientMix 0 1"; editorTemplate -endLayout; // REST OF FILE IS ORIGINAL -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/49397247-e12d-4865-9e50-24681670e44d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.