0

我是 Inventor api 编程的新手。我想获取活动文档的属性。我正在使用 vb.net 进行编码。我尝试了一些代码但没有帮助。在这里,我使用一些代码来打开发明者文档,它工作正常

Public Sub OpenDoc()
    Dim oDoc As Document
    oDoc = _InvApplication.Documents.Open _
                             ("C:\Temp\Part1.ipt")
End Sub

任何人都知道如何获取 part1.ipt 文档的属性。?

4

2 回答 2

2

首先尝试了解对象模型

Application
   |
   -------- Documents
               |
               ---------- Document
                              |
                              ------------- PropertySet
                                                |
                                                ------------ Property

现在,您可以访问所需的信息...

Public Sub ShowDocuments()
     ' Get the Documents collection object.
     Dim invDocs As Documents
     Set invDocs = ThisApplication.Documents
     ' Iterate through the contents of the Documents collection.
     Dim i As Integer
     For i = 1 To invDocs.Count
         ' Get a specific item from the Documents collection.
         Dim invDocument As Document
         Set invDocument = invDocs.Item(i)
         ' Display the full filename of the document in the Immediate window.
         Debug.Print invDocument.FullFileName
     Next
End Sub
于 2013-06-28T07:14:24.020 回答
0

由于您已经获得了文档,因此您可以使用两个 For-Each-Loops 来遍历 PropertySets 和其中的 Properties,例如:

    Dim oPropSets As PropertySets
    oPropSets = oDoc.PropertySets
    Dim oPropSet As PropertySet
    For Each oPropSet In oPropSets
        Dim oPartProp As Inventor.Property
        For Each oPartProp In oPropSet
            Dim oPropertyValue As Object
            If oPartProp.Value Is Nothing Then
                'NullValue-Properties are ignored
            ElseIf oPartProp Is Nothing Then
                   'Null-Properties are ignored too
            ElseIf System.String.Equals(oPartProp.Value.ToString.Trim, "") Then
            'Properties with empty values are also ignored
            Else
                'And here you have your Property:
                Debug.Print(oPartProp.Name & "=" & oPartProp.Value.ToS5tring & vbLf)
            End If
        Next
    Next
于 2015-06-23T09:23:06.483 回答