Inventor geometry exporter add-in

Inventor geometry exporter add-in

Anonymous
Not applicable
493 Views
2 Replies
Message 1 of 3

Inventor geometry exporter add-in

Anonymous
Not applicable

Hello, I'm creating Inventor add-in using C# and Inventor API.
I'm trying to export inventor geometry in a modular way, so I can later assemble the same model in same structure as it was structured in inventor. Each part has its own coordinate system and it’s different relatively to when it’s in assembly. So, I need to make a translation to each part when assembling it back to assembly. I am thinking that I could have a configuration file which would hold translation and rotation information along with the parts. I have an idea but I struggle a bit whit what could be a good way of doing this.
So far I was able to extract geometry data (vertices, indices, normals) and translation of each part in an assembly, but I'm struggling with getting the rotation of the part. 
Here is the code snippet I'm using to extract geometry data of part (I'm leaving out things like handling the data and opening/writing files for brevity):

 Capture.PNG

And here is the code snippet I'm using to get translation of part:

Capture2.PNG

Accepted solutions (1)
494 Views
2 Replies
Replies (2)
Message 2 of 3

JamieVJohnson2
Collaborator
Collaborator

Look at and study the 4x4 Matrix definition information on the Transient Geometry page of the API manual under General Concepts.

https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-1695423A-6BD4-41DB-8771-45DEE8F64D85

The values in the matrix define the rotation as well as position.  I'm assuming you have familiarity with 3D Vector math (or Multivariable Calculus) if your going to write this level of code.  If not, then brush up on your trig, and dive right in!

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 3

JamieVJohnson2
Collaborator
Collaborator
Accepted solution

This experiment of mine (vb.net) may be of interest to you:

    Public Sub TestRoutine()
        Try
            GetInventorApplication()
            Dim mat1 As Matrix = tg.CreateMatrix()
            ReadoutMatrixData(mat1)
            mat1.SetCoordinateSystem(tg.CreatePoint(1, 1, 1), tg.CreateVector(1, 0, 0), tg.CreateVector(0, 1, 0), tg.CreateVector(0, 0, 1))
            ReadoutMatrixData(mat1)
            mat1.SetToRotation(Math.PI / 4, tg.CreateVector(0, 0, 1), tg.CreatePoint(0, 0, 0))
            ReadoutMatrixData(mat1)
            mat1.SetToRotation(3 * Math.PI / 4, tg.CreateVector(0, 0, 1), tg.CreatePoint(0, 0, 0))
            ReadoutMatrixData(mat1)
            mat1.SetTranslation(tg.CreateVector(1, 2, 3), False)
            ReadoutMatrixData(mat1)
            mat1.SetToIdentity()
            ReadoutMatrixData(mat1)
            mat1.Cell(4, 1) = 1
            ReadoutMatrixData(mat1)
            Debug.Print(mat1.Determinant)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub ReadoutMatrixData(mat1 As Matrix)
        Debug.Print("--------------------")
        Dim strOutput As String = String.Empty
        For i As Integer = 1 To 4
            For j As Integer = 1 To 4
                strOutput += CStr(mat1.Cell(i, j))
                If j < 4 Then
                    strOutput += ","
                End If
            Next
            strOutput += vbCrLf
        Next
        Debug.Print(strOutput)
        Debug.Print("--------------------")
    End Sub
Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes