Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MeasureManager discrepancy

1 REPLY 1
Reply
Message 1 of 2
MichaelT_123
109 Views, 1 Reply

MeasureManager discrepancy

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. 

positionOneFor 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.
positionTwoFor 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
1 REPLY 1
Message 2 of 2
kandennti
in reply to: MichaelT_123

Hi @MichaelT_123 .

 

I tried it here, and the result was the same.

        measureResu = app.measureManager.measureMinimumDistance(testFace, testPoint)

 

I will remember that "the order of positionOne and positionTwo is not guaranteed”.
Thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report