社区
Inventor 产品技术应用讨论区
欢迎访问欧特克Inventor论坛!分享知识,发帖提问,浏览Inventor热帖
取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

【博客】iLogic 规则——拆分文件名自动填写图名图号

3 条回复3
已解决
回复
1 条消息(共 4 条)
lynn_zhang
428 次查看, 3 条回复

【博客】iLogic 规则——拆分文件名自动填写图名图号

lynn_zhang_0-1718944551182.jpeg

 

作者: @王承之pmhker 

 

在工作中,我习惯模型画好之后在设计助手里面,根据零部件装配结构顺序对文件按照(图号+图名)的格式进行统一命名。

如部件:M2A1.02.01 履带机构(M2A1=设备代号,.02=总装下第二个子部件,.01=再下一级子部件,履带机构=图名);

零件:M2A1.02.01-03 履带板 (。。。-03=上述部件的第三个子零件,履带板=图名)。

 

当我们出工程图的时候,在标题栏、明细栏或图框中都需要显示零部件的图号(零件代号)和图名。

在使用如上方式对模型文件重命名后,所需内部属性在并不会自动关联,需要打开文件手动编辑,这工作就变得十分繁琐。

这时候就需要我们的 iLogic 一显身手了。

 

参考网友们的代码编写了如下规则,可用于在总装配文件中批量将所有子零部件的文件名拆分,把前面图号部分写入对应文件的【零件代号】属性,后面图号部分写入【标题】属性。后续出图工作中就可以直接引用。

 





Lynn Zhang
Community Manager


3 条回复3
2 条消息(共 4 条)

完整代码请阅读博客原文:iLogic 规则——拆分文件名自动填写图名图号

欢迎大家点赞、留言!





Lynn Zhang
Community Manager


3 条消息(共 4 条)

博客中展示的规则只对第一级零部件有效。

使用以下规则,可以对所有等级零部件进行操作

 

For Each oDocument As Document In ThisDoc.Document.AllReferencedDocuments
    Dim oPtno As [Property]= oDocument.PropertySets("Design Tracking Properties")("Part Number")
    Dim oTitle As [Property] = oDocument .PropertySets("Inventor Summary Information")("Title")
    Dim oCcFileName As String = System.IO.Path.GetFileNameWithoutExtension(oDocument.FullFileName)
    Dim vals() As String = oCcFileName.Split(" "c)
    Try
        If vals.Length = 1 Then
            oPtno.Value = vals(0)
        ElseIf vals.Length > 1 Then
            Dim oBOMStructure As Integer
            If oDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
                Dim oPartDocument As PartDocument = oDocument
                oBOMStructure = oPartDocument.ComponentDefinition.BOMStructure
            ElseIf oDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                Dim oAssemblyDocument As AssemblyDocument = oDocument
                oBOMStructure = oAssemblyDocument.ComponentDefinition.BOMStructure
            End If
            
            If oBOMStructure = BOMStructureEnum.kPurchasedBOMStructure Then
                Try
                    oPtno.Value = ""
                    oTitle.Value = vals(0)
                Catch   
                End Try
            Else
                Try 
                    oPtno.Value = vals(0)
                    oTitle.Value = vals(1)
                Catch   
                End Try     
            End If
        End If
    Catch   
    End Try
Next

 


If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!
如果我的回帖解决了您的问题,请点击 "接受为解决方案" 按钮. 这可以帮助其他人更快的找到解决方案!


王 承之
Autodesk AGN [Inventor 俱乐部] Leader
Inventor Club | Bilibili


AGN L    EESignature

4 条消息(共 4 条)

感谢王老师的补充说明!您是否能在博客原文里也添加这个规则?现在您已经有博客编辑权限了。





Lynn Zhang
Community Manager


找不到想要的内容?向社区提问或分享您的知识。

到论坛发帖  

”