Hi,
I'm using Visual Basic 2010 Express and Inventor 2013...
I can get the properties such as PartName, Description informations of the all sub parts using below code:
Dim invDocs As Documents
invDocs = inv_App.Documents
Dim i As Integer
Dim invDocument As Document
For i = 1 To invDocs.Count
' Get a specific item from the Documents collection.
invDocument = invDocs.Item(i)
invPartNumberProperty = invDocument.PropertySets.Item("Design Tracking Properties").Item("Description")
MsgBox(invPartNumberProperty.Value)
Next
Above code works perfect. But I want to get or change iproperty values of the selected part or assembly in the biggest assembly. I got below information:
Dim selSet As SelectSet
selSet = asmDoc.SelectSet
Dim compOcc As ComponentOccurrence
Dim obj As Object
For Each obj In selSet
compOcc = obj
'Debug.Print(compOcc.Name)
compOcc.Visible = False
Next
But I do not know how can I get the properties of the selected part or sub-asm . How can I walk from "compOcc" to "invDocument.PropertySets.Item("Design Tracking Properties").Item("Description") "
P.S. I will check the selected part quantity. It must be only ONE! Control Code below:
Dim asmDoc As AssemblyDocument
asmDoc = inv_App.ActiveDocument
If asmDoc.SelectSet.Count <> 1 Then
MsgBox("You need to select only one part or sub-asm to change properties...!")
Return
End If
Regards,
Mucip:)
Solved! Go to Solution.
Solved by Ralf_Krieg. Go to Solution.
Hello
Try this.
If inv_App.ActiveDocument.SelectSet.Count = 1 Then If TypeOf inv_App.ActiveDocument.SelectSet.Item(1) Is ComponentOccurrence Then
Dim oOcc As ComponentOccurrence
oOcc = inv_App.ActiveDocument.SelectSet.Item(1)
Dim oDoc As Document oDoc = oOcc.Definition.Document Dim oProp As Property oProp = oDoc.PropertySets.Item("Design Tracking Properties").Item("Description") MsgBox (oProp.Value) End If End If