Inventor Customization

Inventor Customization

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

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

320 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 (307 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: 124
Registered: ‎08-17-2006
Message 3 of 3 (299 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
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!