Autodesk Inventor iLogic: 如何将文件名赋值给 iProperty 的‘库存编号’
以下是在 Autodesk Inventor 中使用 iLogic 代码将文件名赋值给 iProperty 的‘库存编号’的示例代码:
Public Sub SetInventoryNumber()
Dim oDoc As Document = ThisDoc.Document
Dim oPropertySets As PropertySets = oDoc.PropertySets
Dim oSummaryInformation As PropertySet = oPropertySets.Item("Inventor Summary Information")
Dim oInventoryNumber As Property = oSummaryInformation.Item("库存编号")
' 获取文件名(不包括文件扩展名)
Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName)
' 将文件名赋值给库存编号
oInventoryNumber.Value = fileName
End Sub
在 Autodesk Inventor 中,您需要将此代码添加到一个 iLogic 规则中,并在需要设置库存编号的时候运行该规则。请确保已将 iLogic 面板添加到 Inventor 界面上。
要添加 iLogic 规则,请按照以下步骤操作:
- 打开 Autodesk Inventor,并打开要设置库存编号的文件。
- 单击屏幕顶部的“工具”选项卡,然后选择“iLogic 规则编辑器”。
- 在 iLogic 规则编辑器中,单击“新建规则”按钮,然后输入规则名称(例如“SetInventoryNumber”)。
- 将上述示例代码复制并粘贴到规则编辑器中。
- 单击“保存并关闭”按钮以保存规则,并关闭 iLogic 规则编辑器。
- 单击 iLogic 面板上的“规则”下拉菜单,并选择刚刚创建的规则。
- 单击 iLogic 面板上的“运行规则”按钮以运行规则。
运行规则后,文件名将被赋值给 iProperty 的‘库存编号’。您可以通过打开“iProperties”对话框,然后切换到“Inventor 总结信息”选项卡来验证是否成功设置了库存编号。
原文地址: http://www.cveoy.top/t/topic/phcY 著作权归作者所有。请勿转载和采集!