How to data from occurence.getMatrixData ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm using c# for inventor 2013 to write an application but I'm having difficulties with getting the matrix data.
An extraction of the code is :
foreach (ComponentOccurrence oCompOcc in oCompDef.Occurrences.get_AllLeafOccurrences()) { if ((oCompOcc.Enabled) && (oCompOcc.Suppressed == false) && (oCompOcc.Visible)) { if (oCompOcc.DefinitionDocumentType == DocumentTypeEnum.kPartDocumentObject) { PartDocument oPartDoc = (PartDocument)oCompOcc.Definition.Document; double [] dMatrix = new double [16]; oCompOcc.Transformation.GetMatrixData(dMatrix); // Writing the matrix-data to a textfile to visualise : oCon.writeLine("Matrix data :"); oCon.writeLine(dMatrix[0].ToString() + " " + dMatrix[1].ToString() + " " + dMatrix[2].ToString()); } // Einde if } // Einde if } // Einde foreach
The problem is that I only get zero's for the matrixdata in the array dMatrix.
(The oCon object in the code above only writes tekstlines to a file on the HD)
Before I started to write the application I wrote a bunch of testprograms in VBA and overthere it works well.
The following code was one of the testing programs :
Sub getMatrixData() If (ThisApplication.ActiveDocumentType = kAssemblyDocumentObject) Then Dim oAsmDoc2 As AssemblyDocument Set oAsmDoc2 = ThisApplication.ActiveDocument Dim oAsmDef As AssemblyComponentDefinition Set oAsmDef = oAsmDoc2.ComponentDefinition Dim oLeafOccs As ComponentOccurrencesEnumerator Set oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences Dim oOcc As ComponentOccurrence Dim iOcc As Integer iOcc = 0 'Teller voor aantal occurences For Each oOcc In oLeafOccs If (oOcc.DefinitionDocumentType = kPartDocumentObject) And (oOcc.Visible) Then 'Er is een part gevonden Dim oMatrix As Matrix Set oMatrix = oOcc.Transformation iOcc = iOcc + 1 Debug.Print CStr(iOcc) & " " & oOcc.Name & ">" Dim dCells() As Double Debug.Print "Matrix-data : " oMatrix.getMatrixData dCells Debug.Print CStr(dCells(0)) & " , " & CStr(dCells(1)) & " , " & CStr(dCells(2)) & " , " & CStr(dCells(3)) Debug.Print CStr(dCells(4)) & " , " & CStr(dCells(5)) & " , " & CStr(dCells(6)) & " , " & CStr(dCells(7)) Debug.Print CStr(dCells(8)) & " , " & CStr(dCells(9)) & " , " & CStr(dCells(10)) & " , " & CStr(dCells(11)) Debug.Print CStr(dCells(12)) & " , " & CStr(dCells(13)) & " , " & CStr(dCells(14)) & " , " & CStr(dCells(15)) End If Next End If End Sub
I don't understand why all matrix-data is zero in the c# code while in VBA I get the output as here below with the same assembly, I must be overlooking something.
Output of VBA :
1 Part2:2> Matrix-data : 0,612372435695793 , -0,499999999999999 , -0,612372435695794 , -8,88178419700125E-16 0,353553390593274 , 0,866025403784437 , -0,353553390593274 , 0 0,707106781186547 , -4,9297745912803E-16 , 0,707106781186543 , 0 0 , 0 , 0 , 1
Output of c# :
Matrix data : 0 0 0
Any idea what I'm doing wrong here?
Thanks in advance.
Best regards,
Willy Poelmans