Extracting iProperties

Extracting iProperties

Anonymous
Not applicable
1,003 Views
9 Replies
Message 1 of 10

Extracting iProperties

Anonymous
Not applicable
I'm using the Inventor View API in VB.NET, how do I GET/SET the iProperties for a specified file?

(I'm not a programming pro, so dumbing it down might be needed)

David
0 Likes
1,004 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
> {quote:title=dvandoren wrote:}{quote}
> I'm using the Inventor View API in VB.NET, how do I GET/SET the iProperties for a specified file?
>
> (I'm not a programming pro, so dumbing it down might be needed)
>
> David


Public Function GetPartNumber(ByVal sFullFileName As String) As String
Dim oApprentice As New Inventor.ApprenticeServerComponent
Dim oDoc As Inventor.ApprenticeServerDocument = Nothing
Dim sPartNumber As String = ""
Try
oDoc = oApprentice.Open(sFullFileName)
sPartNumber = oDoc.PropertySets.Item(3).Item(2).Value.ToString ' Part Number
Catch ex As Exception
'''''
End Try
oDoc.Close()
oApprentice.Close()
Return sPartNumber
End Function
'
Public Function SetPartNumber(ByVal sFullFileName As String, ByVal sPartNumber As String) As Boolean
Dim oApprentice As New Inventor.ApprenticeServerComponent
Dim oDoc As Inventor.ApprenticeServerDocument = Nothing
SetPartNumber = False
Try
oDoc = oApprentice.Open(sFullFileName)
With oDoc
With .PropertySets
.Item(3).Item(2).Value = sPartNumber
.FlushToFile()
End With
End With
SetPartNumber = True
Catch ex As Exception
''''''
End Try
oDoc.Close()
oApprentice.Close()
Return SetPartNumber
End Function
0 Likes
Message 3 of 10

Anonymous
Not applicable
PERFECT!!! Thankyou so much....


I did have to make these changes to get it to work correctly though...

Public Function GetPartNumber(ByVal sFullFileName As String) As String
Dim oApprentice As New InventorApprentice.ApprenticeServerComponentClass
Dim oDoc As InventorApprentice.ApprenticeServerDocument = Nothing
Dim sPartNumber As String = ""
Try
oDoc = oApprentice.Open(sFullFileName)
sPartNumber = oDoc.PropertySets.Item(3).Item(2).Value.ToString ' Part Number
Catch ex As Exception
'''''
End Try
'oDoc.Close()
'oApprentice.Close()
Return sPartNumber
End Function

'
Public Function SetPartNumber(ByVal sFullFileName As String, ByVal sPartNumber As String) As Boolean
Dim oApprentice As New InventorApprentice.ApprenticeServerComponentClass
Dim oDoc As InventorApprentice.ApprenticeServerDocument = Nothing
SetPartNumber = False
Try
oDoc = oApprentice.Open(sFullFileName)
With oDoc
With .PropertySets
.Item(3).Item(2).Value = sPartNumber
.FlushToFile()
End With
End With
SetPartNumber = True
Catch ex As Exception
''''''
End Try
'oDoc.Close()
'oApprentice.Close()
Return SetPartNumber
End Function
0 Likes
Message 4 of 10

Anonymous
Not applicable
Also, how do your know what Item Index is for which property field?

example, you have Item(3).Item(2) for "part number"

Is there a list defining these items, or do I just need to run through them all myself to figure out whats what?
0 Likes
Message 5 of 10

Anonymous
Not applicable
> {quote:title=dvandoren wrote:}{quote}
> Also, how do your know what Item Index is for which property field?
>
> example, you have Item(3).Item(2) for "part number"
>
> Is there a list defining these items, or do I just need to run through them all myself to figure out whats what?

It is one of ways to get/set Part Number.
0 Likes
Message 6 of 10

Anonymous
Not applicable
Not fully understanding your response. But I see that to set the "Part Number" you use Item(2) in Item(3), hence Item(3).Item(2), what are the items numbers for the other fields? Like "Company Name", "Engineer", etc.
0 Likes
Message 7 of 10

Anonymous
Not applicable
> {quote:title=dvandoren wrote:}{quote}
> Not fully understanding your response. But I see that to set the "Part Number" you use Item(2) in Item(3), hence Item(3).Item(2), what are the items numbers for the other fields? Like "Company Name", "Engineer", etc.

Sorry, I not the professional programmer. I find the necessary indexes in Watch Window. When it is necessary for me.
0 Likes
Message 8 of 10

Anonymous
Not applicable
For what it's worth, I found out a good part of which Items go to which property values. There were 9 that I couldn't figure out what they are for. I think it was for License number of Inventor used, or something like that.

Here they are, they all return as strings....

Title = Item(1).Item(1)
Subject = Item(1).Item(2)
Author = Item(1).Item(3)
Keywords = Item(1).Item(4)
Comments = Item(1).Item(5)
Revision Number = Item(1).Item(7)
Category = Item(2).Item(1)
Manager = Item(2).Item(2)
Company = Item(2).Item(3)
Creation Date = Item(3).Item(1)
Part Number = Item(3).Item(2)
Project = Item(3).Item(3)
Cost Center = Item(3).Item(4)
Checked By = Item(3).Item(5)
Checked Date = Item(3).Item(6)
Eng. Approved By = Item(3).Item(7)
Eng. Approved Date = Item(3).Item(8)
Status = Item(3).Item(9)
Material = Item(3).Item(10)
WEB Link = Item(3).Item(12)
Description = Item(3).Item(14)
Vendor = Item(3).Item(15)
File Subtype = Item(3).Item(17)
Mfg. Approved By = Item(3).Item(19)
Mfg. Approved Date = Item(3).Item(20)
Designer = Item(3).Item(24)
Engineer = Item(3).Item(25)
Authority = Item(3).Item(26)
Stock Number = Item(3).Item(37)
0 Likes
Message 9 of 10

Anonymous
Not applicable
It is better to use names for PropertySets and iProperties rather than numbers.

' Get a reference to the "Design Tracking Properties" PropertySet
Dim oPropSet As PropertySet
Set oPropSet = oPropsets.Item("Design Tracking Properties")

It is safe to use internal names which are the same for any Inventor localization.

Summary Information, {F29F85E0-4FF9-1068-AB91-08002B27B3D9}
Document Summary Information, {D5CDD502-2E9C-101B-9397-08002B2CF9AE}
Design Tracking Properties, {32853F0F-3444-11D1-9E93-0060B03C1CA6}
User Defined Properties, {D5CDD505-2E9C-101B-9397-08002B2CF9AE}


Property.ItemByPropId method provides access to iProperies by named constants

E.g., to get Part Number:
Set oPartNumberProperty = oPropsets.Item("Design Tracking Properties").ItemByPropId(PropertiesForDesignTrackingPropertiesEnum.kPartNumberDesignTrackingProperties)

See also
1) overview “Document Properties” in Programming Help
2) help for PropertiesForDesignTrackingPropertiesEnum Enumeration
3) Autodesk University papers on iProps
0 Likes
Message 10 of 10

Anonymous
Not applicable

Take a look at the paper "Inventor API: Exploring
iProperties and Parameters" that's linked to from this blog posting.  I
believe it answers all of the questions that have been asked here.

 


0 Likes