Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
mucip
Posts: 117
Registered: ‎08-17-2006
Message 1 of 3 (298 Views)
Accepted Solution

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

298 Views, 2 Replies
01-19-2013 02:51 PM

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

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 2 of 3 (285 Views)

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

01-20-2013 01:43 AM 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

 

Distinguished Contributor
mucip
Posts: 117
Registered: ‎08-17-2006
Message 3 of 3 (277 Views)

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

01-20-2013 03:47 AM in reply to: krieg

Dear Krieg,

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

 

Rgeards,

Mucip:smileyhappy:

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.