Inventor Customization

Inventor Customization

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

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

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

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

 

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 2 of 3 (310 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: 127
Registered: ‎08-17-2006
Message 3 of 3 (302 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:

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.