美文网首页
010 - 修改零件实体名称2

010 - 修改零件实体名称2

作者: 怪怪001 | 来源:发表于2023-12-25 21:56 被阅读0次

设计背景:把多实体零件的实体名称修改为文件名和两位数的序号。

文件名:GT.ipt

实体1:GT01

实体2:GT02

......

实体99:GT99

Sub Main

    If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub

    Dim oPDoc As PartDocument = ThisDoc.Document

    Dim oBodies As SurfaceBodies = oPDoc.ComponentDefinition.SurfaceBodies

    fileName=ThisDoc.Document.DisplayName.Replace(".ipt","")

    i=1

    For Each oBody As SurfaceBody In oBodies

        oBody.Name=fileName+Format(i, "00")

        i=i+1

    Next 

    If oPDoc.RequiresUpdate Then oPDoc.Update2(True)

End Sub

相关文章

网友评论

      本文标题:010 - 修改零件实体名称2

      本文链接:https://www.haomeiwen.com/subject/njnkndtx.html