Measure Tools - Using it wrong or just unreliable?

Measure Tools - Using it wrong or just unreliable?

llorden4
Collaborator Collaborator
461 Views
2 Replies
Message 1 of 3

Measure Tools - Using it wrong or just unreliable?

llorden4
Collaborator
Collaborator

In running down bad values I'm getting returned to me by using the Measure Tools within the API, I'm either not using the tool correctly or the values it returns are just wrong.

 

I'm in a planar sketch projecting some points from edges of a face into my sketch and doing some polar calculations for some decision making.  Since the values being returned made no sense, I went old school and applied a trig formula to calculate the distance myself.  Here's the code snippet of what I'm testing...

Dim oMT As MeasureTools = ThisApplication.MeasureTools
Dim FLP(NoSides / NoSections, 4) As Point2d
oSketch.Solve
MsgBox(oMT.GetMinimumDistance(oSKP(1), FLP(i, j)) / 2.54)
MsgBox(Sqrt(Pow(oSKP(1).Geometry.X - FLP(i, j).X, 2) + Pow(oSKP(1).Geometry.Y - FLP(i, j).Y, 2)) / 2.54)

Now I get this isn't everything, but you can see how I'm looking up results.

The measure tool is returning a bad value (19.230792 in my test) while the trig formula returns a correct value (18.60058).  I get you can't test this yourself unless I share what I have in front of me with you, but my primary question is am I using the measure tool correctly and if so then any idea why would I be getting a bad result?

 

Currently in Inv 2022.1.1

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
462 Views
2 Replies
Replies (2)
Message 2 of 3

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

If there is only the distance between two sketch points, simply use the point2d.distanceto method.

Private Sub point2Ddistance()

Dim oSketch As Sketch
Set oSketch = ThisApplication.ActiveEditObject

Dim oSP1 As Point2d
Set oSP1 = oSketch.SketchPoints(2).Geometry

Dim oSP2 As Point2d
Set oSP2 = oSketch.SketchPoints(3).Geometry

Dim dDistance As Double
dDistance = oSP1.DistanceTo(oSP2) 'distance in database units (cm)
End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 3

llorden4
Collaborator
Collaborator

Thanks, that did work.

    So is the pro-tip here not to use 3D measuring tools in a 2D environment?

 

I'd hate to miss an opportunity to report a bug if this should have worked.

 

(Guess I'll let someone else figure out if this is a bug or not, flagging as accepted just to close this thread)

Autodesk Inventor Certified Professional
0 Likes