FreeCAD-macros
41 строка · 1.1 Кб
1__Name__ = 'Ellipse Center + 2 Points'
2__Comment__ = ''
3__Author__ = 'Eriossoltero'
4__Version__ = ''
5__Date__ = ''
6__License__ = 'LGPL-2.0-or-later'
7__Web__ = 'http://freecad-tutorial.blogspot.com/2011/12/engine-9-poly-v-belt.html'
8__Wiki__ = ''
9__Icon__ = ''
10__Help__ = ''
11__Status__ = ''
12__Requires__ = ''
13__Communication__ = ''
14__Files__ = ''
15
16import FreeCAD as app
17import FreeCADGui as gui
18import Part, PartGui
19from FreeCAD import Base
20
21# get the selected objects, with first selection for the trajectory and second for the section
22# Adapted from:
23# http://freecad-tutorial.blogspot.com/2011/12/engine-9-poly-v-belt.html
24s = gui.Selection.getSelection()
25try:
26sel1 = s[0].Shape
27sel2 = s[1].Shape
28sel3 = s[2].Shape
29except:
30app.Console.PrintError('Wrong selection')
31
32pt_center = sel1.Point
33pt_radmay = sel2.Point
34pt_radmen = sel3.Point
35
36# create Part object in the current document
37myObject = app.ActiveDocument.addObject('Part::Feature', 'Ellipse')
38
39# create a shape and assign it to the current document
40ellipse = Part.Ellipse(pt_radmay, pt_radmen, pt_center)
41myObject.Shape = ellipse.toShape()
42