Distance tool prints to report view, how is this queried with python?

Need help, or want to share a macro? Post here!
Post Reply
llll
Posts: 167
Joined: Fri Nov 12, 2021 1:56 am

Distance tool prints to report view, how is this queried with python?

Post by llll »

Only used measure a few times. It seems that in 0.20 there is no distance object appearing in tree, with properties. Rather: it prints to report view.

How to access distance variable shown here with python?
FreeCAD_sqFlXKZiRh.png
FreeCAD_sqFlXKZiRh.png (13.46 KiB) Viewed 291 times
Thanks in advance
vm4dim
Posts: 83
Joined: Tue Nov 23, 2021 1:05 am

Re: Distance tool prints to report view, how is this queried with python?

Post by vm4dim »

In FreeCAD is three Measure systems

App::MeasureDistance
This draws white line, object is saved in Tree and have access from Python.
Call from: MainMenu > Tools > Measure Distance

Part_Measure
This draws colored lines, object is NOT saved in Tree and NOT have access from Python. It prints in the report view.
Call from: MainMenu > Measure ( If Part WB is active )

Measure.Measurement()
Call from Python. It not draw
llll
Posts: 167
Joined: Fri Nov 12, 2021 1:56 am

Re: Distance tool prints to report view, how is this queried with python?

Post by llll »

vm4dim wrote: Sun Jun 26, 2022 8:47 am In FreeCAD is three Measure systems
Measure.Measurement()
where does one read up on Measurement() methods?

Part_Measure was going to use this for its orthogonal measure... If any GUI experts reading, how to save the report view as text, with python

App::MeasureDistance this doesn't have orthogonality it seems, but I'll try make a FPO to use it... :/

How do I make a FPO which allows user to select two points in GUI?

Code: Select all

def create(obj_name):
    obj = App.ActiveDocument.addObject('App::MeasureDistance', obj_name)      #  Creates a new FreeCAD FeaturePython 
    measure(obj)            
    return obj             
    
class measure():
    def __init__(self, obj):      
        self.Type = 'measure'          
        obj.Proxy = self           
     def execute(v1,v2):
        v1 = Gui.userinput
        v2 = Gui.userinput
vm4dim
Posts: 83
Joined: Tue Nov 23, 2021 1:05 am

Re: Distance tool prints to report view, how is this queried with python?

Post by vm4dim »

llll wrote: Sun Jun 26, 2022 10:30 am Measure.Measurement()
where does one read up on Measurement() methods?
In Source Code
https://github.com/FreeCAD/FreeCAD/blob ... asure/App/ Measurement.cpp
Post Reply