Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic rule - Get point coordinates referring to custom origin

Anonymous

iLogic rule - Get point coordinates referring to custom origin

Anonymous
Not applicable

Hi all,

I'm getting point coordinates referred to the main origin with the following code:

punto = ThisApplication.ActiveDocument.ComponentDefinition.WorkPoints("Punto1")

x = punto.point.x

y = punto.point.y

z = punto.point.z

I can make the same with measure tool (see Position.jpg)

I would like to obtain (with code) the position of the point (x, y, z), but referring to a secondary origin (already set in the part), as I can do with measure tool (see Position other origin.jpg).

 

Many thanks to all for the cooperation!

0 Likes
Reply
Accepted solutions (1)
3,162 Views
4 Replies
Replies (4)

clutsa
Collaborator
Collaborator

Can you just subtract the UCS offsets from the workpoints?

Dim punto As WorkPoint = ThisApplication.ActiveDocument.ComponentDefinition.WorkPoints("Work Point1")
Dim ucs As UserCoordinateSystem = ThisApplication.ActiveDocument.ComponentDefinition.UserCoordinateSystems(1)
Dim x As Double = punto.Point.X - ucs.XOffset.Value

Dim y As Double = punto.Point.Y - ucs.YOffset.Value

Dim z As Double = punto.Point.Z - ucs.ZOffset. Value

MessageBox.Show("X: " & x & " Y: " & y & " Z: " & z, "Title")

 The ucs offsets are in cm so you may need to convert to mm but that's a simple enough conversion Smiley Very Happy

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes

Anonymous
Not applicable

The new origin it is not a point, but as an origin it have 3 planes, 3 axis and a central point (see origin.jpg).

So, the point X, Y, Z i need is not a distance or offset, but a point position with the 3 coordinates completely different because central point and axis directions are different.

When you use the measuring tool, if you click only a point the windows gives you the position referred to an origin (see position.jpg). In the same windows you can select from a list box a different origin, and you get the coordinates rererred to another "triade".

So I can't do it measuring a distance between two point (or offset), due to different axis direction too.

0 Likes

clutsa
Collaborator
Collaborator
Accepted solution

I see what you mean... try this...

Dim app As Inventor.Application = ThisApplication
Dim doc As Document = app.ActiveDocument
Dim compDef As PartComponentDefinition = doc.ComponentDefinition


Dim wp1 As WorkPoint = compDef.WorkPoints("Work Point1")
Dim ucs As UserCoordinateSystem = compDef.UserCoordinateSystems(1)
'copy workpoint so it can be manipulated
Dim testPoint As Point = wp1.Point.Copy
'get the transform matrix for ucs
Dim invertMatrix As Matrix = ucs.Transformation
'invert matrix to find origin
invertMatrix.Invert
'transform point by inverted matrix to get desired point
testPoint.TransformBy(invertMatrix)

'you won't need to convert from metric to imperial but i'm leaving that in for me =P
MessageBox.Show("X: " & testPoint.X / 2.54 & " Y: " & testPoint.Y / 2.54 & " Z: " & testPoint.Z / 2.54 , "Title")
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes

Anonymous
Not applicable

It works EXACTLY as I need! Fantastic!

Many thanks to you and Autodesk Forum!!!

0 Likes