用mel编写自定义节点的属性编辑器界面

用mel编写自定义节点的属性编辑器界面比较麻烦,而且网上例子又少, 下面给出一个范例,说明基本的格式
 
   
  1. // 初始化节点时调用
  2. global proc initControl(string $attrName)
  3. {
  4. // 传进来的参数是节点属性名,使用这个方法获得节点名称
  5. string $nodeName = `plugNode $attrName`;
  6. setUITemplate -pst "attributeEditorTemplate";
  7. button -label "Compute Weight" -c ("cageDeform -init -name " + $nodeName) computeWeightButton;
  8. setUITemplate -ppt;
  9. }
  10. // 修改节点时(例如点击另一个同类节点)调用
  11. // 此函数的目的是对按钮绑定的命令做相应修改,使其能应用于相应节点
  12. global proc modifyControl(string $attrName)
  13. {
  14.   // 当attrName = “cageDeformer1.noAttr”
  15. // plugNode 命令能够提取节点名字cageDeformer1
  16. string $nodeName = `plugNode $attrName`;
  17. print $nodeName;
  18. button -e -c ("meshControl -init -name " + $nodeName) computeWeightButton;
  19. }
  20. // 函数名同文件名一样,同节点名cageDeformer对应
  21. global proc AEcageDeformerTemplate(string $nodeName)
  22. {
  23. editorTemplate -beginScrollLayout;
  24.         // 新建一个卷展栏
  25. editorTemplate -beginLayout "Weight Scheme" -collapse false;
  26. // addControl自动指定合适类型的控件
  27. editorTemplate -addControl "maxNeighbourNum";
  28. editorTemplate -addControl "weightPower";
  29.          // 在指定的时机调用前面的函数
  30. editorTemplate -callCustom "initControl" "modifyControl" "noAttr";
  31. editorTemplate -endLayout;
  32. editorTemplate -suppress "outMesh";
  33. editorTemplate -suppress "inControlMesh";
  34. editorTemplate -suppress "refMesh";
  35. editorTemplate -suppress "refControlMesh";
  36. editorTemplate -beginLayout "Node Behavior" -collapse true;
  37. editorTemplate -addControl "nodeState";
  38. editorTemplate -addControl "caching";
  39. editorTemplate -endLayout;
  40. editorTemplate -addExtraControls;
  41. editorTemplate -endScrollLayout;
  42. }

下面是-callCustom的文档解释

Specifies that at this point in the template when building the dialog, the procedure specified by the first argument is to be called to create some UI objects when a new node type is edited. The procedure specified by the second argument is to be called if an attribute editor already exists and another node of the same type is now to be edited. The replacing procedure should connect any controls created by the creating procedure to the equivalent attributes in the new node. A list of zero or more attributes specifies the attributes which the two procedures will involve. The procedures should have the signature:
proc AEcustomNew(string attributeName1, string attributeName2)
The number of attributes specified in the call should correspond to the number of attributes in the procedure signature.
 




转载于:https://www.cnblogs.com/dydx/p/4286746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值