Measure/Measure Angular in python

Need help, or want to share a macro? Post here!
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Measure/Measure Angular in python

Postby more11 » Tue Oct 10, 2017 7:48 pm

I need some help scripting measurements. Three is nothing in documentation or in the forum. There is no output in Python console when doing it in the gui.

The Draft.makeAngularMeasurement doesn't work for me as I am doing my stuff in 3D using Part.
Point taken :-)
User avatar
easyw-fc
Posts: 2668
Joined: Thu Jul 09, 2015 9:34 am

Re: Measure/Measure Angular in python

Postby easyw-fc » Tue Oct 10, 2017 8:45 pm

more11 wrote:
Tue Oct 10, 2017 7:48 pm
I need some help scripting measurements. Three is nothing in documentation or in the forum. There is no output in Python console when doing it in the gui.

The Draft.makeAngularMeasurement doesn't work for me as I am doing my stuff in 3D using Part.
Hi @more11
I've started to work at my Manipulator workbench exactly for that reason...
I have an Aligner, a Mover and a Caliper that are working with Part objects
https://forum.freecadweb.org/viewtopic.php?f=9&t=24742
https://forum.freecadweb.org/viewtopic. ... 61#p194777

Image

ATM I've not finished yet the part related to angular measurement... I think it will be available in few days
Please have a try with the WB and give me some feedback :D

Maurice
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Measure/Measure Angular in python

Postby more11 » Wed Oct 11, 2017 3:43 am

Thanks Maurice! Link to your source code?
Point taken :-)
User avatar
Kunda1
Posts: 5781
Joined: Thu Jan 05, 2017 9:03 pm

Re: Measure/Measure Angular in python

Postby Kunda1 » Wed Oct 11, 2017 3:49 am

more11 wrote:
Wed Oct 11, 2017 3:43 am
Thanks Maurice! Link to your source code?
https://github.com/easyw/Manipulator
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
easyw-fc
Posts: 2668
Joined: Thu Jul 09, 2015 9:34 am

Re: Measure/Measure Angular in python

Postby easyw-fc » Wed Oct 11, 2017 9:29 pm

more11 wrote:
Tue Oct 10, 2017 7:48 pm
The Draft.makeAngularMeasurement doesn't work for me as I am doing my stuff in 3D using Part.
I made some improvement with the Caliper

Angles-wip.gif
Angles-wip.gif (698.5 KiB) Viewed 993 times
I have some issue on some angles ... but it is quite near :D

Maurice
User avatar
Kunda1
Posts: 5781
Joined: Thu Jan 05, 2017 9:03 pm

Re: Measure/Measure Angular in python

Postby Kunda1 » Thu Oct 12, 2017 3:10 am

:o
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Leatherman
Posts: 155
Joined: Thu Feb 02, 2017 2:49 pm

Re: Measure/Measure Angular in python

Postby Leatherman » Thu Oct 12, 2017 11:38 am

indeed a very helpful wb and an impressive work. Thanks :D
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Measure/Measure Angular in python

Postby more11 » Thu Oct 12, 2017 8:00 pm

I have tried the WB. It doesn't work properly for me. I want to measure angles on wires. This is how I make wires:

Code: Select all

def makeWire(points, closed=True):
    lines = []
    for i in range(0, len(points)-1):
        lines.append(Part.makeLine(points[i], points[i+1]))
    if closed:
        lines.append(Part.makeLine(points[len(points)-1], points[0]))
    wire = Part.Wire(lines)
    return wire
The I create faces with Part.Face(), which I then extrude() the face.

I can upload a drawing if you would like something to work on.

The "Measure/Measure Angle" works as it should.

Mårten
Point taken :-)
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Measure/Measure Angular in python

Postby more11 » Thu Oct 12, 2017 8:03 pm

Since I want to make the measurements in my python code generating the drawing, it would be fantastic if you could print the calls with its parameters to the python console. With this output maybe I can figure out how to call the workbench code from python.
Point taken :-)
User avatar
easyw-fc
Posts: 2668
Joined: Thu Jul 09, 2015 9:34 am

Re: Measure/Measure Angular in python

Postby easyw-fc » Thu Oct 12, 2017 8:21 pm

more11 wrote:
Thu Oct 12, 2017 8:00 pm
I have tried the WB. It doesn't work properly for me. I want to measure angles on wires. This is how I make wires:
I can upload a drawing if you would like something to work on.
....

The "Measure/Measure Angle" works as it should.

Mårten
Hi,
the Caliper is aimed to work as a friendly Gui, not as a library to be called...
Anyway your issue is due to the fact that my routines work with 3D objects, getting Edges from those, and not with Wires ...

A reference library for getting Angles in python is there
https://www.freecadweb.org/wiki/FreeCAD ... th_library

If you need to consider Part/Body recursive placement you can have a look at Caliper.py or Mover.py to see how I did it

Maurice