0

I am new in Inventor api programming.I want to get the properties of a active document.I am using vb.net for coding.I tried some code but no help. here I use some code for open an inventor document ,it is working fine

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

any one know how to get the part1.ipt document's properties.?

Arun
  • 1,402
  • 10
  • 32
  • 59

2 Answers2

2

First try to understand the object model

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

Now, you can access the info you require ...

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
rags
  • 2,580
  • 19
  • 37
  • Thanks sir..here it print the file name of the document.I need to print the properties that object used mean length,width, etc.... – Arun Jun 28 '13 at 09:40
  • Check tutorials: http://download.autodesk.com/us/community/mfg/Part_1.pdf http://download.autodesk.com/us/community/mfg/Part_2.pdf http://download.autodesk.com/us/community/mfg/Part_3.pdf http://download.autodesk.com/us/community/mfg/Part_4.pdf – rags Jun 28 '13 at 12:05
0

Since you already got the document, you can just iterate through the PropertySets and the Properties therein with two For-Each-Loops like this for example:

    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
gsus
  • 131
  • 2
  • 6