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: 

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

1 REPLY 1
Reply
Message 1 of 2
mucip
212 Views, 1 Reply

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

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

 

1 REPLY 1
Message 2 of 2
mucip
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

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

Post to forums  

Autodesk Design & Make Report