美文网首页
018 - 把工程图的属性赋值到对应的零件或者装配体的属性

018 - 把工程图的属性赋值到对应的零件或者装配体的属性

作者: 怪怪001 | 来源:发表于2024-05-26 21:25 被阅读0次

Sub Main()

    If Not ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then

        Messagebox.Show("Current document is not drawing docuemnt", "Inventor")

        Exit Sub

    End If

    Dim value_List As List(Of String) = New List(Of String)

    value_List.Add(iProperties.Value("Project", "Vendor"))

    value_List.Add( iProperties.Value("Project", "Stock Number"))

    value_List.Add(iProperties.Value("Project", "Project"))

    value_List.Add(iProperties.Value("Project", "Designer"))

    Dim oDoc As Document

    oDoc = ThisDrawing.ModelDocument

    If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then

        Update_Properties(oDoc, value_List)

        Dim oAsyDoc As AssemblyDocument

        oAsyDoc = oDoc

        Dim oReferDoc As Document

        Dim occ As ComponentOccurrence

        Dim oDef As AssemblyComponentDefinition

        oDef = oAsyDoc.ComponentDefinition

        For Each occ In oDef.Occurrences             

            If occ.SubOccurrences.Count = 0 Then

                oReferDoc = occ.ReferencedDocumentDescriptor.ReferencedDocument

                Update_Properties(oReferDoc, value_List)

            Else                

                oReferDoc = occ.ReferencedDocumentDescriptor.ReferencedDocument

                Update_Properties(oReferDoc, value_List)

                processAllSubOcc(occ, value_List)

            End If                

        Next

    Else If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then

        Update_Properties(oDoc, value_List)

    End If

End Sub

Private Sub processAllSubOcc(ByVal oCompOcc As ComponentOccurrence , value_List As List(Of String))

    Dim oSubCompOcc As ComponentOccurrence

    Dim oReferDoc As Document

    For Each oSubCompOcc In oCompOcc.SubOccurrences

        If oSubCompOcc.SubOccurrences.Count = 0 Then

            oReferDoc = oSubCompOcc.ReferencedDocumentDescriptor.ReferencedDocument

            Update_Properties(oReferDoc,value_List)            

        Else

            oReferDoc = oSubCompOcc.ReferencedDocumentDescriptor.ReferencedDocument

            Update_Properties(oReferDoc ,value_List)            

            Call processAllSubOcc(oSubCompOcc, value_List)

        End If

    Next

End Sub

Sub Update_Properties(oDoc As Document, value_List As List(Of String))

    oDoc.PropertySets.Item("Design Tracking Properties").Item("Vendor").Value = value_List.Item(0)

    oDoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value = value_List.Item(1)

    oDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = value_List.Item(2)

    oDoc.PropertySets.Item("Design Tracking Properties").Item("Designer").Value = value_List.Item(3)    

    oDoc.Save()

End Sub

相关文章

  • Odin Inspector 系列教程 --- Required

    Required Attribute特性:用于任何对象属性,如果对应属性没有赋值,则在检查器中出现对应的提示消息。...

  • 6. 实现字典转模型的自动转换

    思路:利用运行时,遍历模型中所有属性,根据模型的属性名,去字典中查找key,取出对应的值,给模型的属性赋值。步骤:...

  • Spring-属性赋值

    Spring属性赋值,是指给对象的基础类型属性赋值。 赋值方式 通过xml对属性赋值通过bean下的propert...

  • iOS开发:runtime实现字典转模型

    实现思路: 遍历模型中所有属性,根据模型的属性名去字典中查找key,取出对应的的值,给模型的属性赋值 使用到的ru...

  • iOS底层原理——Runtime

    实现思路: 遍历模型中所有属性,根据模型的属性名去字典中查找key,取出对应的的值,给模型的属性赋值 使用到的ru...

  • iOS KVC的几种情况简析

    kvc取值时,需注意的几点问题; 讲解一下kvc各种问题,包括基础属性赋值,属性对象的属性赋值,私有属性赋值 以及...

  • 防止tableview上拉加载跳跃,不能定位到上拉之前的cell

    tableview里有个属性,estimateRowHeight,这个属性置零,或者,在给model赋值,并且计算...

  • oc深拷贝与浅拷贝

    属性对应的所有权修饰符: assign __unsafe_unretained copy __strong(赋值...

  • transform

    简介 该属性是针对 UIView 及其子类的该属性只要被赋值,就可以将一个 view 平移、旋转或者缩放 常用赋值...

  • Python_getter和setter方法

    当给属性赋值的时候,使用实例.属性=属性值的方式显然把属性暴露出来了,并且也无法对属性值进行限制检查,java中提...

网友评论

      本文标题:018 - 把工程图的属性赋值到对应的零件或者装配体的属性

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