Line tangent to arc or circle in draft mode

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Line tangent to arc or circle in draft mode

Post by jfc4120 »

Can someone please do a macro that does that?
Workshop_Notes
Posts: 614
Joined: Wed Sep 29, 2021 8:35 am

Re: Line tangent to arc or circle in draft mode

Post by Workshop_Notes »

Are you aware of the geometric construction that can do this? That might be a work around for you. Clearly, if you need it a hundred times, it will be very slow, but once or twice, it is not so bad.

This is how to draw a line tangent to a circle from a point in space. Note that the point has to be outside the circle. Draw a line from the point to the centre of the circle. At the midpoint of that line, draw a circle with diameter the length of the line. Where that circle intersects the original circle is the point of tangency.

I have Python code for this, which takes the external point, the centre and radius of the circle and a selected point* as inputs and outputs the tangent point but I do not know how to make it interact with FC. I think it would be fairly easy to modify this for a tangent from a point to an ellipse. Also, if it is of interest, I have code to draw the common tangent between two circles.

* because there are generally two possible tangents to a circle from any external point. The selected point determines which 'side' of the circle the tangent is wanted.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Line tangent to arc or circle in draft mode

Post by jfc4120 »

I am new to freecad and python. And yes I know how to find tangent. It would work except for another thing:

Freecad doesn't have a snap for the intersection of two arcs or circles, but does for lines. I was hoping a "veteran" python person could write a macro to do both.

I have experience it other languages, but not python, at least yet. For example see this post:
https://forum.freecadweb.org/viewtopic.php?f=22&t=70341
edwilliams16
Veteran
Posts: 3180
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Line tangent to arc or circle in draft mode

Post by edwilliams16 »

If you want to make more complicated 2D objects with arcs and lines and various dimensions, you should use the sketcher.
See https://owncloud.gwdg.de/index.php/s/eZ ... 9/download and https://owncloud.gwdg.de/index.php/s/eZ ... 9/download

It is of course possible to do all your geometry by hand, but as it gets more complicated, the trade-off is to use the more powerful tool.
Post Reply