Message 1 of 2
MeasureManager discrepancy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi TF360,
Just a small problem,... not life threatening though.
As per documentation:
MeasureResults = measureManager_var.measureMinimumDistance(geometryOne, geometryTwo) |
MeasureResults object has two ((relevant in the discussion) properties.
positionOne | For a distance measurement, this is the point on the first entity where the measurement was made from. For an angle measurement this is one of the three points defining the angle. |
positionTwo | For a distance measurement, this is the point on the second entity where the measurement was made to. For an angle measurement this is one of the three points defining the angle. |
As per the descriptions, one would expect that positionOne refers to the first argument of measureMinimumDistance() function. It seems to be not the case.
Please find attached basic test files.
#Author-MT
#Description-MeasureManager problem
'''
MeasureResults A MeasureResults object that contains the distance and the two points on the geometry that the distance that was measured between them in centimeters.
Name Type Description
geometryOne Base The first geometry to measure from. This can be an Occurrence, any B-Rep entity (BRepBody, BRepFace, BRepEdge, BRepVertex, etc.), any construction geometry, any sketch entities, and any temporary 3D geometry (Cylinder, Plane, Line3D, etc.).
geometryTwo Base The second geometry to measure to. This can be an Occurrence, any B-Rep entity (BRepBody, BRepFace, BRepEdge, BRepVertex, etc.), any construction geometry, any sketch entities, and any temporary 3D geometry (Cylinder, Plane, Line3D, etc.).
MeasureResults Object
positionOne For a distance measurement, this is the point on the first entity where the measurement was made from. For an angle measurement this is one of the three points defining the angle.
positionThree This point is only used for angle measurements and is one of the three points defining the angle.
positionTwo For a distance measurement, this is the point on the second entity where the measurement was made to. For an angle measurement this is one of the three points defining the angle.
value The measurement value. If the measurement is a distance this value will be in centimeters. If it's an angle then it will be in radians.
'''
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
root = des.rootComponent
testPoint = root.originConstructionPoint.geometry
testFace = root.bRepBodies.item(0)
measureResu = app.measureManager.measureMinimumDistance( testPoint, testFace )
minDistance = measureResu.value
positionOne = measureResu.positionOne
positionTwo = measureResu.positionTwo
msg = 'minDistance = {:g}\n'.format(minDistance)
msg += 'testPoint = <{:g},{:g},{:g}>\n'.format(testPoint.x, testPoint.y, testPoint.y)
msg += 'positionOne = <{:g},{:g},{:g}>\n'.format(positionOne.x, positionOne.y, positionOne.y)
msg += 'positionTwo = <{:g},{:g},{:g}>\n'.format(positionTwo.x, positionTwo.y, positionTwo.y)
msg += '\n'
msg += 'testPoint.isEqualTo(positionOne) = {:s}\n' .format(str(testPoint.isEqualTo(positionOne)))
msg += 'testPoint.isEqualTo(positionTwo) = {:s}\n' .format(str(testPoint.isEqualTo(positionTwo)))
ui.messageBox(msg)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Regards
MichaelT
MichaelT