Autodesk Inventor iLogic 代码优化:获取当前项目名称

以下代码展示了如何修改 iLogic 代码,以显示当前文件所属项目的名称,而不是当前文件的名称。

原始代码:

Dim doc As Document = ThisApplication.ActiveDocument
Dim fileName As String = doc.FullFileName
MessageBox.Show('当前激活的项目文件的名称是:' & fileName, '项目文件名称')

修改后的代码:

Dim doc As Document = ThisApplication.ActiveDocument
Dim proj As Project = doc.ReferenceProject
Dim projFileName As String = proj.FullFileName
MessageBox.Show('当前激活的项目文件所属项目的名称是:' & projFileName, '项目文件所属项目名称')

代码解释:

  1. Dim doc As Document = ThisApplication.ActiveDocument:获取当前活动的文档。
  2. Dim proj As Project = doc.ReferenceProject:获取当前文档所属的项目。
  3. Dim projFileName As String = proj.FullFileName:获取项目文件的完整路径和文件名。
  4. MessageBox.Show('当前激活的项目文件所属项目的名称是:' & projFileName, '项目文件所属项目名称'):使用 MessageBox 显示项目文件的名称。

通过以上代码修改,您可以轻松地获取当前文件所属项目的名称,并将其显示在 MessageBox 中。

Autodesk Inventor iLogic 代码优化:获取当前项目名称

原文地址: https://www.cveoy.top/t/topic/qo4f 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录