Skip to content

Instantly share code, notes, and snippets.

@mario52a
Last active August 12, 2021 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mario52a/2455d9c3317a74c80e7b98b65cf1b1ef to your computer and use it in GitHub Desktop.
Save mario52a/2455d9c3317a74c80e7b98b65cf1b1ef to your computer and use it in GitHub Desktop.
Creates a arc from 3 selected points
# -*- coding: utf-8 -*-
from FreeCAD import Base
__title__ = "Macro_Make_Arc_3_points"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.01"
__date__ = "14/07/2016"
global selected; selected = []
App = FreeCAD
class SelObserver:
print "Create Arc to 3 points ..."
def addSelection(self,doc,obj,sub,pnt): # Selection
global selected
selected.append(pnt)
if len(selected) == 1:
print "Point 1 : ",FreeCAD.Vector(selected[0])
elif len(selected) == 2:
print "Point 2 : ",FreeCAD.Vector(selected[1])
elif len(selected) == 3:
print "Point 3 : ",FreeCAD.Vector(selected[2])
try:
C1 = Part.Arc(FreeCAD.Vector(selected[0]),FreeCAD.Vector(selected[1]),FreeCAD.Vector(selected[2]))
S1 = Part.Shape([C1])
W = Part.Wire(S1.Edges)
Part.show(W)
App.ActiveDocument.ActiveObject.Label = "Arc_3_Points"
print "Length : ",W.Length
except Exception:
print "Three points are collinear or bad selection"
del selected[:]
FreeCADGui.Selection.removeObserver(s)
print "End Make_Arc_3_Points"
print "_____________________"
s=SelObserver()
FreeCADGui.Selection.addObserver(s)
@mario52a
Copy link
Author

This macro utility is intended for the use of the program FreeCAD http://www.freecadweb.org/
The icon for your toolbar, it is to place in your macros directory (in the same location of the macro)

macro_make_arc_3_points rename the image in Macro_Make_Arc_3_Points.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment