API - place file in assembly, user defined position.

API - place file in assembly, user defined position.

Jef_E
Collaborator Collaborator
341 Views
0 Replies
Message 1 of 1

API - place file in assembly, user defined position.

Jef_E
Collaborator
Collaborator

Hi there,

 

I'm trying to create a method that will place a file into an assembly, and I want it to be like when you choose place file in Inventor.

 

The file is been chosen by it's path. And now it needs to be placed. I know a way how to place the file at coordinates, but I want the file to be on the cursor and the user be able to choose where to drop it.

 

How do you do achieve this? I tried a programming help search but I can only find thing about the event and dialog.

FileDialog.InsertMode() As Boolean

normally I just place and ground, but that not good now 😞

    Public Function Place_and_Ground_Part(ByVal oDef As AssemblyComponentDefinition,
                                       ByVal path As String) As ComponentOccurrence

        ' Set a reference to the assembly component definintion.
        ' This assumes an assembly document is open.

        ' Set a reference to the transient geometry object.
        Dim oTG As TransientGeometry
        oTG = oInvApp.TransientGeometry

        ' Create a matrix.  A new matrix is initialized with an identity matrix.
        Dim oMatrix As Matrix
        oMatrix = oTG.CreateMatrix

        ' Set the translation portion of the matrix so the part will be positioned
        ' at (3,2,1).
        oMatrix.SetTranslation(oTG.CreateVector(0, 0, 0))

        ' Add the occurrence.
        Dim oOcc As ComponentOccurrence
        oOcc = oDef.Occurrences.Add(path, oMatrix)

        ' Make sure the master part is grounded
        oOcc.Grounded = True
        Return oOcc

    End Function


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
342 Views
0 Replies
Replies (0)