Inventor Customization

Reply
Distinguished Contributor
mucip
Posts: 112
Registered: ‎08-17-2006
Message 1 of 2 (89 Views)

To know if the main branch of the part or assemly selected?

89 Views, 1 Replies
02-03-2013 03:14 AM

Hi,

I'm using VB Express 2010...

 

I can get information if the part or sub part of the assembly selected below code:

 

Dim asmDoc As Document 'AssemblyDocument
asmDoc = inv_App.ActiveDocument
Dim invDocument As Document = Nothing
Dim compOcc As ComponentOccurrence = Nothing

 

 If TypeOf inv_App.ActiveDocument.SelectSet.Item(1) Is ComponentOccurrence Then
            compOcc = inv_App.ActiveDocument.SelectSet.Item(1)
            invDocument = compOcc.Definition.Document
            invDocumentTakas = invDocument
           TextBoxWeight.Text = compOcc.MassProperties.Mass

end if

 

But I need to get information main bruch of the file also. For instance: I opened an assebmly and I can select the main branch in model browser. Or I open single file and I want to select top branch (opened part) in model browser.

 

But in this case CompanentOccurence is not working unfortunatelly... How can I know/check if the main (top) branch of the single opened part or assembly?...

 

regards,

Mucip:smileyhappy:

 

Distinguished Contributor
mucip
Posts: 112
Registered: ‎08-17-2006
Message 2 of 2 (84 Views)

Re: To know if the main branch of the part or assemly selected?

02-03-2013 12:36 PM in reply to: mucip

Hi,

I found the solution and wanted to share with you...

 

Dim invDocument As Document = Nothing
Dim compOcc As ComponentOccurrence = Nothing
Dim PartOcc As PartComponentDefinition = Nothing
Dim AsmOcc As AssemblyComponentDefinition = Nothing

 

 If TypeOf inv_App.ActiveDocument.SelectSet.Item(1) Is ComponentOccurrence Then
            compOcc = inv_App.ActiveDocument.SelectSet.Item(1)
            invDocument = compOcc.Definition.Document
            invDocumentTakas = invDocument
            FormOzellikGuncelle.TextBoxAgirlik.Text = compOcc.MassProperties.Mass
        ElseIf TypeOf inv_App.ActiveDocument.SelectSet.Item(1) Is PartComponentDefinition Then
            PartOcc = inv_App.ActiveDocument.SelectSet.Item(1)
            invDocument = PartOcc.Document
            invDocumentTakas = invDocument
            FormOzellikGuncelle.TextBoxAgirlik.Text = PartOcc.MassProperties.Mass          
        ElseIf TypeOf inv_App.ActiveDocument.SelectSet.Item(1) Is AssemblyComponentDefinition Then
            AsmOcc = inv_App.ActiveDocument.SelectSet.Item(1)
            invDocument = AsmOcc.Document
            invDocumentTakas = invDocument
            FormOzellikGuncelle.TextBoxAgirlik.Text = AsmOcc.MassProperties.Mass         
        Else
            MsgBox("Selected is not part or asm!")
            Return
        End If

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube