How to measure the transformation matrix between two UCS coordinate systems?

How to measure the transformation matrix between two UCS coordinate systems?

Anonymous
Not applicable
2,432 Views
13 Replies
Message 1 of 14

How to measure the transformation matrix between two UCS coordinate systems?

Anonymous
Not applicable

Hi,

I am new to Inventor and trying to define the rotation matrix between two UCS's.

In both SolidWorks and Creo it can be done with the integrated Measure feature - no big deal. But it seems to be a bit more complicated with Inventor. Is it possible with iLogic and Inventor API code? if so, I would be happy if someone could provide a script/code since I don't have any experience with it - yet. 

 

matrix.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I need the matrix for input to my robot to defining the new TCP coordinate when I attach a different end tool.

 

Any help?

0 Likes
2,433 Views
13 Replies
Replies (13)
Message 2 of 14

imajar
Advisor
Advisor

As far as I know, the rotation matrix is not available in the measure tool and is only available in the API as the matrix object.  If you go into the API, be careful that the rotation matrix of each object is relative to the sub-assembly that it is inserted into - so if the part is nested a couple layers deep, you will need to multiply the rotation matrices.

 

However, there may be a workaround - in the mass properties you can look up the Inertial properties of a body, and that includes some transformation information from the principle axes to the coordinate system.  You may be able to exploit that to determine the rotation matrix.

 

Otherwise, there is information available online on how to compute the rotation matrix on your own a few different ways.

 

 


Aaron Jarrett, PE
Inventor 2019 | i7-6700K 64GB NVidia M4000
LinkedIn

Life is Good.
0 Likes
Message 3 of 14

Anonymous
Not applicable

Hi

It look pretty complex with the API and "Matrix object" - Perhaps I can get you to make a script I can use/look at?

I doesn't look like I can use the Inertial properties to determine the matrix.

If I somehow simply can get each UCS coordinate and orientation I can calculate it my self. Is it possible to get any pieces of information according to the inserted UCS?

0 Likes
Message 4 of 14

JhoelForshav
Mentor
Mentor

Hi @Anonymous 

 

I don't know how you want the Transformation Matrix presented, but try this iLogic rule.

It'll have you pick the User coordinate systems and then it will return the Transformation in a messagebox 🙂

 

Dim oUCS1 As UserCoordinateSystem = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kUserCoordinateSystemFilter, "Select UCS1")
Dim oUCS2 As UserCoordinateSystem = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kUserCoordinateSystemFilter, "Select UCS2")

If oUCS1 Is Nothing Or oUCS2 Is Nothing Then Exit Sub 

Dim oUCS1Transformation As Matrix = oUCS1.Transformation
Dim oUCS2Transformation As Matrix = oUCS2.Transformation


If TypeOf (oUCS1) Is UserCoordinateSystemProxy Then oUCS1Transformation.TransformBy(oUCS1.ContainingOccurrence.Transformation)

If TypeOf (oUCS2) Is UserCoordinateSystemProxy Then oUCS2Transformation.TransformBy(oUCS2.ContainingOccurrence.Transformation)


Dim oOrigin1 As Point
Dim oXAxis1 As Vector
Dim oYAxis1 As Vector
Dim oZAxis1 As Vector

Dim oOrigin2 As Point
Dim oXAxis2 As Vector
Dim oYAxis2 As Vector
Dim oZAxis2 As Vector

oUCS1Transformation.GetCoordinateSystem(oOrigin1, oXAxis1, oYAxis1, oZAxis1)
oUCS2Transformation.GetCoordinateSystem(oOrigin2, oXAxis2, oYAxis2, oZAxis2)



Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

oMatrix.SetToAlignCoordinateSystems(oOrigin1, oXAxis1, oYAxis1, oZAxis1, _
oOrigin2, oXAxis2, oYAxis2, oZAxis2)

Dim cells(15) As Double
oMatrix.GetMatrixData(cells)

Dim oReturn As String
For i = 0 To 3
	oReturn = oReturn & Math.Round(cells(i), 10) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 4 To 7
	oReturn = oReturn & Math.Round(cells(i), 10) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 8 To 11
	oReturn = oReturn & Math.Round(cells(i), 10) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 12 To 15
	oReturn = oReturn & Math.Round(cells(i), 10) & " ; "
Next

MsgBox(oReturn)
Message 5 of 14

Anonymous
Not applicable

hi @JhoelForshav 

 

Thanks a lot for your rule. It is something like this I am looking for. It is nearly perfect.

 

If I positioned the robot like this:

1.png

Run your rule and get the output:

2.png

The result is nearly correct. I was expecting something like this (last result(5)):

3.png

 

Do you know how to get an output like this instead with rounded values and the displacement vector in document units (mm not cm)?

Also it would be great if am able to copy the output

 

0 Likes
Message 6 of 14

JhoelForshav
Mentor
Mentor

@Anonymous 

You must have copied the rule before i edited the post to round off the values to 10 decimals...

How does it look if you copy it as it's written now? 🙂

0 Likes
Message 7 of 14

Anonymous
Not applicable

😄it seems to still have the same output. 4 decimals is accepted.

0 Likes
Message 8 of 14

JhoelForshav
Mentor
Mentor

How about this?

Dim oUCS1 As UserCoordinateSystem = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kUserCoordinateSystemFilter, "Select UCS1")
Dim oUCS2 As UserCoordinateSystem = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kUserCoordinateSystemFilter, "Select UCS2")

If oUCS1 Is Nothing Or oUCS2 Is Nothing Then Exit Sub 

Dim oUCS1Transformation As Matrix = oUCS1.Transformation
Dim oUCS2Transformation As Matrix = oUCS2.Transformation


If TypeOf (oUCS1) Is UserCoordinateSystemProxy Then oUCS1Transformation.TransformBy(oUCS1.ContainingOccurrence.Transformation)

If TypeOf (oUCS2) Is UserCoordinateSystemProxy Then oUCS2Transformation.TransformBy(oUCS2.ContainingOccurrence.Transformation)


Dim oOrigin1 As Point
Dim oXAxis1 As Vector
Dim oYAxis1 As Vector
Dim oZAxis1 As Vector

Dim oOrigin2 As Point
Dim oXAxis2 As Vector
Dim oYAxis2 As Vector
Dim oZAxis2 As Vector

oUCS1Transformation.GetCoordinateSystem(oOrigin1, oXAxis1, oYAxis1, oZAxis1)
oUCS2Transformation.GetCoordinateSystem(oOrigin2, oXAxis2, oYAxis2, oZAxis2)



Dim oMatrix As Matrix = ThisApplication.TransientGeometry.CreateMatrix()

oMatrix.SetToAlignCoordinateSystems(oOrigin1, oXAxis1, oYAxis1, oZAxis1, _
oOrigin2, oXAxis2, oYAxis2, oZAxis2)

Dim cells(15) As Double
oMatrix.GetMatrixData(cells)

Dim oReturn As String
For i = 0 To 3
	oReturn = oReturn & Math.Round(cells(i), 4, MidpointRounding.AwayFromZero) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 4 To 7
	oReturn = oReturn & Math.Round(cells(i), 4, MidpointRounding.AwayFromZero) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 8 To 11
	oReturn = oReturn & Math.Round(cells(i), 4, MidpointRounding.AwayFromZero) & " ; "
Next
oReturn = oReturn & vbCrLf
For i = 12 To 15
	oReturn = oReturn & Math.Round(cells(i), 4, MidpointRounding.AwayFromZero) & " ; "
Next

MsgBox(oReturn)
0 Likes
Message 9 of 14

Anonymous
Not applicable

Now it looks like this:

4.png

Pretty close 🙂 thanks

what about the unit?  The 40,62 should be 406,2

0 Likes
Message 10 of 14

Anonymous
Not applicable

I tested the rule when I have attached an end tool to the robot with the values:

5.png'

6.png

I expect the result to be:

8.png

 

But gets:

7.png

It seems to be a problem defining the x- and y- vector.

when i measure between the two UCS point I get this result:

9.png

Which doesn't look right? isn't it possible to use measure feature between two UCS's? The two coordinate systems are collinear in Z-direction.

0 Likes
Message 11 of 14

JhoelForshav
Mentor
Mentor

@Anonymous 

This turned out to be more complex than I thought... I can only get the values from these matrices as double and when you need exact data floating point numbers are terrible. It seems to add to the error both when transforming to the assembly coordinate system and transforming to match each other...  When it comes to measuring between the coordinate systems, do you use the centerpoint (workpoint) in the UCS? That should work fine.

0 Likes
Message 12 of 14

Anonymous
Not applicable

I am sorry to hear that it causes trouble. But I really appreciate your help @JhoelForshav 

Must say I am really close to just uninstalling Inventor and use SolidWorks or Creo instead. This is a very important feature and is essential for me to work with my robot.

I hope a solution comes up?

0 Likes
Message 13 of 14

Anonymous
Not applicable

When I measure between the two UCS's I have tried both between the general coordinate systems and the center points in both. -> Same result as pictured earlier. Doesn't make sense.

0 Likes
Message 14 of 14

Anonymous
Not applicable

@JhoelForshav thanks very much for this!  I think it was already very practical and easy to use, much more than what we can ask for free 😄

0 Likes