自定义命令定义示例
示例:用替代属性替换部分 URL
自定义命令的标签为 Button Label,有一个工具提示等。而且,当此命令处于激活状态时,它会检查当前选定的部分是否有指定的属性 (Source_file_name)。如果没有找到,则不会启用该按钮。如果找到了,该属性则会替换 URL 中的子字符串。
<menu
ui="rmb"
view="all"
pane="all"
select="any"
visible="getSelectedCount()==1 && getPropertyExists('Source_file_name')">
<command_name >MyCommand 1</command_name>
<label >Button Label</label>
<tooltip>This is a new command.</tooltip>
<icon>\my\icons\location\icon16x16.png</icon>
<action
target="browser">
http://somewhere.com/content.jsp?partName=<!Source_file_name!>
</action>
</menu>
示例:选择多个部分时,替换 URL 的一个部分
在此示例中,当用户选择两个部分时,Creo View 会获取这两部分的 Featrue_Id 属性值 (通过 getSelectedPartProperty 返回)。然后用这些值替换 URL 的两个子字符串。
<menu
ui="rmb"
view="all"
pane="all"
select="any"
visible="getSelectedCount()==2 && getSelectedPartProperty(1,'Feature_Id','featureId1') &&
getSelectedPartProperty(2,'Feature_Id','featureId2')">
<command_name >MyCommand 2</command_name>
<label >Button Label</label>
<action
target="browser">
http://www.somewhere.com/index.jsp?Id1=<!featureId1!>&Id2=<!featureId2!>
</action>
</menu>