Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get iproperties of the selected part or sub-assembly using VB.NET

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mucip
756 Views, 2 Replies

How to get iproperties of the selected part or sub-assembly using VB.NET

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:)

2 REPLIES 2
Message 2 of 3
Ralf_Krieg
in reply to: mucip

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

 


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 3 of 3
mucip
in reply to: Ralf_Krieg

Dear Krieg,

Thanks... It worked like a charm...

 

Rgeards,

Mucip:)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report