Last active
August 12, 2021 23:50
-
-
Save mario52a/2455d9c3317a74c80e7b98b65cf1b1ef to your computer and use it in GitHub Desktop.
Creates a arc from 3 selected points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)