Inventor Vb.Net Propert

Inventor Vb.Net Propert

isocam
Collaborator Collaborator
448 Views
3 Replies
Message 1 of 4

Inventor Vb.Net Propert

isocam
Collaborator
Collaborator

Can anybody help?

 

I am using the following Vb.Net code to get the values of certain values using PropertySets....

 

Sub GetPartTypeProperty(oDoc)
   PartType = oDoc.PropertySets.Item(3).Item(17).Value
End Sub

Sub GetPartNumberProperty(oDoc)
   PartNumber = oDoc.PropertySets.Item(3).Item(2).Value
End Sub

Sub GetPartDescriptionProperty(oDoc)
   PartDescription = oDoc.PropertySets.Item(3).Item(14).Value
End Sub

Sub GetPartMaterialProperty(oDoc)
   PartMaterial = oDoc.PropertySets.Item(3).Item(10).Value
End Sub

 

Does anybody know how I can set the property sets for "Part Type", "Part Number", "Part Description" and "Part Material"

 

Many thanks in advance!

 

Darren

0 Likes
Accepted solutions (1)
449 Views
3 Replies
Replies (3)
Message 2 of 4

Frederick_Law
Mentor
Mentor

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-E789B421-6231-486F-ACAB-BEE31A8E9454

 

This iLogic will list all the names.  Some of them has different display and internal name.  Internal name is the the one use for program.

 

Sub Main()
Dim oPropsets As PropertySets
Dim oPropset As PropertySet
Dim oProp As Inventor.Property
Dim oDoc As Document

oDoc = ThisDoc.Document
oPropsets = oDoc.PropertySets

For Each oPropset In oPropsets
	Logger.Info("+" & oPropset.DisplayName)
	Logger.Info("-" & oPropset.Name)
	For Each oProp In oPropset
		Logger.Info(" +" & oProp.DisplayName)
		Logger.Info(" -" & oProp.Name)
	Next
Next
End Sub

 

 

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Hi @isocam.  The Part Number and Description properties are ReadWrite, but I believe the other two are ReadOnly.  Many of the properties in those first 3 PropertySet objects are ReadOnly, and their values are set internally.

You can review the following Enum documentation for more details about PropertySets.Item(3) (aka Design Tracking Properties)

PropertiesForDesignTrackingPropertiesEnum 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor
Accepted solution

You might want to have a look at this page: "Accessing iProperties". Apart from that I would do this:

Sub Main()
    Document = ThisDoc.Document

    ' Set propertie
    PartNumber = DateTime.Now().ToString()
    Description = "www.hjalte.nl"

    ' Get properties
    MsgBox(PartType)
    MsgBox(Description)
    MsgBox(PartNumber)
    MsgBox(Material)
End Sub


Public Property PartType() As String
    Get
        Return GetProperty("Design Tracking Properties", "Document SubType Name")
    End Get
    Set(ByVal value As String)
        SetProperty("Design Tracking Properties", "Document SubType Name", value)
    End Set
End Property

Public Property PartNumber() As String
    Get
        Return GetProperty("Design Tracking Properties", "Part Number")
    End Get
    Set(ByVal value As String)
        SetProperty("Design Tracking Properties", "Part Number", value)
    End Set
End Property

Public Property Description() As String
    Get
        Return GetProperty("Design Tracking Properties", "Description")
    End Get
    Set(ByVal value As String)
        SetProperty("Design Tracking Properties", "Description", value)
    End Set
End Property

Public Property Material() As String
    Get
        Return GetProperty("Design Tracking Properties", "Material")
    End Get
    Set(ByVal value As String)
        SetProperty("Design Tracking Properties", "Material", value)
    End Set
End Property


Public Property Document As Document

Public Function GetProperty(setName As String, name As String) As String
    Return Document.PropertySets.Item(setName).Item(name).Value
End Function
Public Sub SetProperty(setName As String, name As String, value As String)
    Dim propertySet = Document.PropertySets.Item(setName)
    Try
        propertySet.Item(name).Value = value
    Catch ex As Exception
        propertySet.Add(value, name)
    End Try
End Sub

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes