-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonPlungers.py
80 lines (76 loc) · 2.68 KB
/
ButtonPlungers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#*****************************************************************************
#
# System :
# Module :
# Object Name : $RCSfile$
# Revision : $Revision$
# Date : $Date$
# Author : $Author$
# Created By : Robert Heller
# Created : Wed Dec 23 10:39:56 2020
# Last Modified : <221221.1416>
#
# Description
#
# Notes
#
# History
#
#*****************************************************************************
#
# Copyright (C) 2020 Robert Heller D/B/A Deepwoods Software
# 51 Locke Hill Road
# Wendell, MA 01379-9728
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#*****************************************************************************
import Part
from FreeCAD import Base
import FreeCAD as App
import os
import sys
sys.path.append(os.path.dirname(__file__))
import Mesh
import datetime
class ButtonPlunger(object):
_bodyDiameter = 5.08
_bottomDiameter = 7.62
_bottomHeight = 2.54
def __init__(self,name,origin,bodyheight=10.16):
self.name = name
if not isinstance(origin,Base.Vector):
raise RuntimeError("origin is not a Vector!")
self.origin = origin
self._body = Part.Face(Part.Wire(Part.makeCircle(self._bodyDiameter/2.0,
self.origin)))\
.extrude(Base.Vector(0,0,bodyheight))
bottom = Part.Face(Part.Wire(Part.makeCircle(self._bottomDiameter/2.0,\
self.origin)))\
.extrude(Base.Vector(0,0,-self._bottomHeight))
self._body = self._body.fuse(bottom)
def show(self):
doc = App.activeDocument()
obj = doc.addObject("Part::Feature",self.name)
obj.Shape=self._body
obj.Label=self.name
obj.ViewObject.ShapeColor=tuple([.5,.5,.5])
def MakeSTL(self,filename):
doc = App.activeDocument()
objs = list()
objs.append(doc.getObject(self.name))
Mesh.export(objs,filename)