Insert part into assembly vb.net

Insert part into assembly vb.net

Anonymous
Not applicable
463 Views
0 Replies
Message 1 of 1

Insert part into assembly vb.net

Anonymous
Not applicable

Hi,

 

I'm not an overly experianced vb.net programer but handel most small programming scripts fairly. Now I have an idea where by the user can click on a vb.net form button and insert a part into the cative assembly (the assembly that is currently opened by the user). these type of functions are quite easy with most other programs but it remains hard to find info in regards to inventor maby someone out there knows how I can do this?

 

what I did manage to find and actually leaves a bad taste in my mouth is the following code...

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim oApp As Inventor.Application

        System.Diagnostics.Process.Start("C:\Program Files\Autodesk\Inventor 2016\Bin\Inventor.exe")

        '- Sleep for 10 seconds so Inventor can load -'
        System.Threading.Thread.Sleep(10000)
        oApp = GetObject(, "Inventor.Application")
        oApp.Documents.Open("C:\test.ipt", True)
end sub

because the following old school code works just as well, and has a lot less coding and as an added bonus no "create new" dialogue box

 

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        System.Diagnostics.Process.Start("C:\test.ipt", True)
    End Sub

but niether do what I want and that is to insert the part into the already active assembly???

 

the closest of anything that I have been able to workout is the following...

 

Imports Inventor

Public Class Form1

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim oApp As Inventor.Application
        Dim oAsmDef As AssemblyComponentDefinition = oApp.ActiveDocument.ComponentDefinition
        Dim oTG As TransientGeometry = oApp.TransientGeometry
        Dim oMatrix As Matrix = oTG.CreateMatrix

        Dim oOcc As ComponentOccurrence
        oOcc = oAsmDef.Occurrences.AddiPartMember("C:\test.ipt", oMatrix, 1)

end class
0 Likes
464 Views
0 Replies
Replies (0)