def __init__(self, obj, opt): super(FCSpecial, self).__init__(obj) obj.Shape = mirrorShape(opt) obj.addProperty("App::PropertyString", "Wedge", "Special", "Wedge of the optic").Wedge = str(opt.Wedge/deg) + ' deg' obj.addProperty("App::PropertyString", "HRK", "Special", "HR curvature").HRK = str(opt.HRK) + ' m^-1' obj.addProperty("App::PropertyString", "ARK", "Special", "AR curvature").ARK = str(opt.ARK) + ' m^-1' obj.addProperty("App::PropertyDistance", "Thick", "Special", "Thickness of optic").Thick = opt.Thick/self.fact obj.addProperty("App::PropertyString", "N", "Special", "Optical index").N = str(opt.N) obj.addProperty("App::PropertyDistance", "Dia", "Special", "Diameter").Dia = opt.Dia/.001 obj.addProperty("App::PropertyString", "TonHR", "Action", "Action for T on HR").TonHR = '+' + str(opt.TonHR) obj.addProperty("App::PropertyString", "RonHR", "Action", "Action for R on HR").RonHR = '+' + str(opt.RonHR) obj.addProperty("App::PropertyString", "TonAR", "Action", "Action for T on AR").TonAR = '+' + str(opt.TonAR) obj.addProperty("App::PropertyString", "RonAR", "Action", "Action for R on AR").RonAR = '+' + str(opt.RonAR) obj.Placement.Base = Base.Vector(tuple(opt.HRCenter/self.fact))
def __init__(self, name, origin): self.name = name if not isinstance(origin, Base.Vector): raise RuntimeError("origin is not a Vector") self.origin = origin ox = origin.x oy = origin.y oz = origin.z self.body = Part.makePlane(TB007_508_xxBE._3belength, TB007_508_xxBE._termwidth, origin).extrude( Base.Vector(0, 0, TB007_508_xxBE._termheight)) self.pin1 = Part.Face( Part.Wire( Part.makeCircle( TB007_508_xxBE._termpindia / 2.0, Base.Vector(ox + TB007_508_xxBE._termhyoff, oy + TB007_508_xxBE._termhxoff, oz)))).extrude( Base.Vector(0, 0, -TB007_508_xxBE._termpinlen)) self.pin2 = Part.Face( Part.Wire( Part.makeCircle( TB007_508_xxBE._termpindia / 2.0, Base.Vector( ox + TB007_508_xxBE._termhyoff + TB007_508_xxBE._termpitch, oy + TB007_508_xxBE._termhxoff, oz)))).extrude( Base.Vector(0, 0, -TB007_508_xxBE._termpinlen)) self.pin3 = Part.Face( Part.Wire( Part.makeCircle( TB007_508_xxBE._termpindia / 2.0, Base.Vector( ox + TB007_508_xxBE._termhyoff + (2 * TB007_508_xxBE._termpitch), oy + TB007_508_xxBE._termhxoff, oz)))).extrude( Base.Vector(0, 0, -TB007_508_xxBE._termpinlen))
def makeSpiderLegSegment(baseDiamX=1.0, baseDiamY=0.8, tipDiamX=0.8, tipDiamY=0.6, segLength=5.0, skinThick=0.25, name="segment"): # outer shell is a tapered ellipsoid loft ellipse1 = Part.Ellipse(Base.Vector(0, 0, 0), baseDiamX, baseDiamY) base1 = Part.Wire(Part.Edge(ellipse1)) ellipse2 = Part.Ellipse(Base.Vector(0, 0, 0), tipDiamX, tipDiamY) ellipse2.translate(Base.Vector(0, 0, segLength)) tip1 = Part.Wire(Part.Edge(ellipse2)) shell = App.ActiveDocument.addObject("Part::Feature", "shell") shell.Shape = Part.makeLoft([base1, tip1], True) # hollow core is a tapered ellipsoid loft ellipse3 = Part.Ellipse(Base.Vector(0, 0, 0), baseDiamX - skinThick, baseDiamY - skinThick) base2 = Part.Wire(Part.Edge(ellipse3)) ellipse4 = Part.Ellipse(Base.Vector(0, 0, 0), tipDiamX - skinThick, tipDiamY - skinThick) ellipse4.translate(Base.Vector(0, 0, segLength)) tip2 = Part.Wire(Part.Edge(ellipse4)) core = App.ActiveDocument.addObject("Part::Feature", "core") core.Shape = Part.makeLoft([base2, tip2], True) # Make tube by cutting core from shell legSegment = App.ActiveDocument.addObject("Part::Cut", name) App.ActiveDocument.ActiveObject.Base = shell App.ActiveDocument.ActiveObject.Tool = core # core.Document.removeObject("core") # shell.Document.removeObject("shell") return legSegment
def __init__(self, name, origin): self.name = name if not isinstance(origin, Base.Vector): raise RuntimeError("origin is not a Vector!") self.origin = origin self.body = Part.makePlane(Disk25_2H._Width, Disk25_2H._Length, origin).extrude( Base.Vector(0, 0, Disk25_2H._Height)) self.mh = dict() self.mh[1] = origin.add( Base.Vector(Disk25_2H._MH1X, Disk25_2H._MH1Y, 0)) self.mh[2] = origin.add( Base.Vector(Disk25_2H._MH2X, Disk25_2H._MH2Y, 0)) self.mh[3] = origin.add( Base.Vector(Disk25_2H._MH3X, Disk25_2H._MH3Y, 0)) self.mh[4] = origin.add( Base.Vector(Disk25_2H._MH4X, Disk25_2H._MH4Y, 0)) mrad = Disk25_2H._MHDia / 2.0 mdeep = Base.Vector(0, 0, Disk25_2H._MHDepth) for i in [1, 2, 3, 4]: mhface = Part.Face(Part.Wire(Part.makeCircle(mrad, self.mh[i]))) self.body = self.body.cut(mhface.extrude(mdeep))
def make_arched_corner_cutout_aperture(aperture_height, aperture_width, arc_radius): """Creates a wire outline of a rectangle with an arc removed from one corner. Args: arc_radius (float): Radius of the arc. aperture_height (float): Total height of the aperture aperture_width (float): Total width of the aperture Returns: wire1 (FreeCAD wire definition): An outline description of the shape. face1 (FreeCAD face definition): A surface description of the shape. """ # Create the initial four vertices where line meets curve. v1 = Base.Vector(0, aperture_height, 0) v2 = Base.Vector(0, aperture_height, aperture_width) v3 = Base.Vector(0, -aperture_height, aperture_width) v4 = Base.Vector(0, -aperture_height, arc_radius) v5 = Base.Vector(0, -aperture_height + arc_radius, 0) cv1 = Base.Vector( 0, -float(aperture_height) + sqrt(arc_radius / 2.0), sqrt(arc_radius / 2.0), ) # Create lines line1 = Part.LineSegment(v5, v1) line2 = Part.LineSegment(v1, v2) line3 = Part.LineSegment(v2, v3) line4 = Part.LineSegment(v3, v4) # Create curves arc1 = Part.Arc(v4, cv1, v5) # Make a shape shape1 = Part.Shape([line1, line2, line3, line4, arc1]) # Make a wire outline. wire1 = Part.Wire(shape1.Edges) # Make a face. face1 = Part.Face(wire1) return wire1, face1
def design_key(span_length, base_length, base_width, key_depth, wall_width, wall_t): x = span_length / 2 y2 = (base_width - wall_t) y2 = y2 / 3.8 y = (wall_width / 2) + y2 points = [] points.append(Base.Vector(x, y, 0)) points.append(Base.Vector(x + (base_length), y, 0)) points.append(Base.Vector(x + (base_length), y - wall_width, 0)) points.append(Base.Vector(x, y - wall_width, 0)) edges = [] for i in range(0, 3): edges.append(Part.makeLine(points[i], points[i + 1])) edges.append(Part.makeLine(points[3], points[0])) w = Part.Wire(edges) f = Part.Face(w) key = f.extrude(FreeCAD.Vector(0, 0, -key_depth)) keys = [] keys.append(key) key = key.mirror(Base.Vector(0, 0, 0), Base.Vector(1, 0, 0)) keys.append(key) return keys
def __init__(self, name, origin): self.name = name if not isinstance(origin, Base.Vector): raise RuntimeError("origin is not a Vector!") self.origin = origin X = self.origin.x Y = self.origin.y Z = self.origin.z self._body = Part.Face(Part.Wire(\ Part.makeCircle(self._bodyDiameter/2.0,\ self.origin)))\ .extrude(Base.Vector(0,0,-self._bodyDepth)) self._terminals = Part.Face(Part.Wire(\ Part.makeCircle(self._terminalDiameter/2.0,\ Base.Vector(X,Y,Z-self._bodyDepth))))\ .extrude(Base.Vector(0,0,-self._terminalDepth)) self._bushing = Part.Face(Part.Wire(\ Part.makeCircle(self._bushingDiameter/2.0,\ self.origin)))\ .extrude(Base.Vector(0,0,self._bushingLength)) self._shaft = Part.Face(Part.Wire(\ Part.makeCircle(self._shaftDiameter/2.0,\ Base.Vector(X,Y,Z+self._bushingLength))))\ .extrude(Base.Vector(0,0,self._shaftLength))
import winsound LL0 = 29. LL1 = 7.14 LL2 = 2.4 LL3 = LL0 - LL2 - LL1 LL4 = LL0 - LL2 HH0 = 5.6 HH1 = 3. HH2 = HH0 - HH1 W0 = 3.6 W1 = 1. v0 = Base.Vector( 0., 0., 0. ) v1 = Base.Vector( -10, -10., -10. ) v00 = Base.Vector( 0., 0., 0. ) v01 = Base.Vector( -W1, 0., 0. ) v02 = Base.Vector( -W1, LL3, 0. ) v03 = Base.Vector( 0., LL3, 0. ) v04 = Base.Vector( -W0, 0., HH2 ) v05 = Base.Vector( -W0, LL4, HH2 ) v06 = Base.Vector( 0., LL4, HH2 ) v07 = Base.Vector( 0., 0., HH2 ) def PL0( ): ls00 = Part.LineSegment() ls00.StartPoint = v00
def coffetable_assy(d): ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) x = ccx / 2.0 + math.sqrt((d["cx"]**2) / 2.0) y = ccy / 2.0 + math.sqrt((d["cx"]**2) / 2.0) # The upper oak tabletop #tt1 = upper_tabletop_2(d) #tt1.translate(Base.Vector(0, 0, d["height"])) # The upper oak tabletop 2nd version tt4 = upper_tabletop_3(d) tt4.translate(Base.Vector(0, 0, d["height"])) # The lower oak tabletop #tt2 = lower_tabletop_2(d) #tt2.rotate(Base.Vector(0,0,0), Base.Vector(1,0,0), 180) #tt2.translate(Base.Vector(0, 0, d["height_1"] - d["lower_tabletop_t"])) # The lower oak tabletop 2nd version tt3 = lower_tabletop_3(d) tt3.rotate(Base.Vector(0, 0, 0), Base.Vector(1, 0, 0), 180) tt3.translate(Base.Vector(0, 0, d["height_1"] - d["lower_tabletop_t"])) # The first leg leg1 = leg(d) leg1.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), 225) leg1.translate(Base.Vector(x, y, 0)) # The second leg leg2 = leg(d) leg2.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), 315) leg2.translate(Base.Vector(-x, y, 0)) # The third leg leg3 = leg(d) leg3.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), 45) leg3.translate(Base.Vector(-x, -y, 0)) # The fourth leg leg4 = leg(d) leg4.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), 135) leg4.translate(Base.Vector(x, -y, 0)) doc = dc.common.create_doc() #dc.common.add_model(doc, tt1, "upper_tabletop") dc.common.add_model(doc, tt4, "upper_tabletop_3") #dc.common.add_model(doc, tt2, "lower_tabletop") dc.common.add_model(doc, tt3, "lower_tabletop_3") dc.common.add_model(doc, leg1, "leg1") dc.common.add_model(doc, leg2, "leg2") dc.common.add_model(doc, leg3, "leg3") dc.common.add_model(doc, leg4, "leg4") doc.saveAs(dc.common.fn(d, "assy") + ".fcstd")
def lower_tabletop_3(d, dressup=True): ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) length = ccx + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) width = ccy + (2 * d["leg_distance_from_corner"] + d["insertion_width_3"]) / math.sqrt(2.0) print("Lower tabletop length: ", length) print("Lower tabletop width: ", width) x1 = length / 2.0 y1 = width / 2.0 x2 = x1 - 25 y2 = y1 - 25 p = [None] * 12 p[0] = Base.Vector(-x1, y2, 0) p[1] = Base.Vector(-x2, y1, 0) p[3] = Base.Vector(x2, y1, 0) p[4] = Base.Vector(x1, y2, 0) p[6] = Base.Vector(x1, -y2, 0) p[7] = Base.Vector(x2, -y1, 0) p[9] = Base.Vector(-x2, -y1, 0) p[10] = Base.Vector(-x1, -y2, 0) p[2] = dc.model.sagpoint(p[1], p[3], -45) p[5] = dc.model.sagpoint(p[4], p[6], -45) p[8] = dc.model.sagpoint(p[7], p[9], -45) p[11] = dc.model.sagpoint(p[10], p[0], -45) wire = [ Part.makeLine(p[0], p[1]), dc.model.makeArc(p[1:4]), Part.makeLine(p[3], p[4]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), dc.model.makeArc(p[7:10]), Part.makeLine(p[9], p[10]), dc.model.makeArc([p[10], p[11], p[0]]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["lower_tabletop_t"])) m = dc.model.fillet_edges_by_length(m, 20, d["lower_tabletop_t"]) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 45 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["lower_tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert = Part.makeBox(d["leg_t"], d["insertion_width_3"], d["insertion_length"]) insert = dc.model.fillet_edges_by_length(insert, d["leg_edge_radii"], d["insertion_length"]) insert.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2, 0)) insert.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), -a) insert.translate(p) m = m.cut(hole).cut(insert) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 150) m.translate(Base.Vector(0, 0, -d["lower_tabletop_t"])) return m
def USBJackCutout(self,xPanel): cutoutOrig = self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5)) cutoutOrig = Base.Vector(xPanel,cutoutOrig.y+220,cutoutOrig.z) return Part.makePlane(110,220,cutoutOrig,Base.Vector(1,0,0))
class ReflowToasterOven2Board(object): _boardWidth = MM2Mils(45.76) @staticmethod def BoardWidth(): return ReflowToasterOven2Board._boardWidth _boardLength = MM2Mils(114.30) @staticmethod def BoardLength(): return ReflowToasterOven2Board._boardLength _holes = { 1 : Base.Vector(4400,500,0), \ 2 : Base.Vector(4400,1300,0), \ 3 : Base.Vector(150,150,0), \ 4 : Base.Vector(150,1650.0) } _FeatherWidth = 900 _FeatherLength = 2000 _FeatherYUSB_Offset = 450-110 _FeatherYBoardOffset = 500 def StandOff(self,index,heightMM,above=False): boardbase = self.origin if above: boardbase = self.origin.add(Base.Vector(0,0,62.5)) else: heightMM *= -1 p = self._holes[index] return Part.Face(Part.Wire(Part.makeCircle(125,boardbase.add(p)))\ ).extrude(Base.Vector(0,0,MM2Mils(heightMM))) def mountingHole(self,index,height=62.5,standoffMM=0): #print("*** ReflowToasterOven2Board.mountingHole(%d,%g,%g)"%(index,height,standoffMM),file=sys.__stderr__) p = self._holes[index] #print("*** ReflowToasterOven2Board.mountingHole(): p is (%g,%g,%g)"%(p.x,p.y,p.z),file=sys.__stderr__) p = p.add(Base.Vector(0,0,MM2Mils(standoffMM))) #print("*** ReflowToasterOven2Board.mountingHole(): p (add standoffMM) is (%g,%g,%g)"%(p.x,p.y,p.z),file=sys.__stderr__) holeorig = self.origin.add(p) #print("*** ReflowToasterOven2Board.mountingHole(): holeorig is (%g,%g,%g)"%(holeorig.x,holeorig.y,holeorig.z),file=sys.__stderr__) return Part.Face(Part.Wire(Part.makeCircle(62.5,holeorig))\ ).extrude(Base.Vector(0,0,height)) def USBJack(self): return Part.makePlane(300,220,\ self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5))\ ).extrude(Base.Vector(0,0,110)) def USBJackCutout(self,xPanel): cutoutOrig = self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5)) cutoutOrig = Base.Vector(xPanel,cutoutOrig.y+220,cutoutOrig.z) return Part.makePlane(110,220,cutoutOrig,Base.Vector(1,0,0)) def USBJackCutoutHole(self,xPanel): cutoutOrig = self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5)) cutoutOrig = Base.Vector(xPanel,cutoutOrig.y+110,cutoutOrig.z+55) return Part.Face(Part.Wire(Part.makeCircle(175,cutoutOrig,Base.Vector(1,0,0)))) def show(self): doc = App.activeDocument() obj = doc.addObject("Part::Feature",self.name+"_board") obj.Shape = self.board obj.Label=self.name+"_board" obj.ViewObject.ShapeColor=tuple([210/255.0,180/255.0,140/255.0]) obj = doc.addObject("Part::Feature",self.name+"_h1") obj.Shape = self.h1 obj.Label=self.name+"_h1" obj.ViewObject.ShapeColor=tuple([0.0,0.0,0.0]) obj = doc.addObject("Part::Feature",self.name+"_h2") obj.Shape = self.h2 obj.Label=self.name+"_h2" obj.ViewObject.ShapeColor=tuple([0.0,0.0,0.0]) obj = doc.addObject("Part::Feature",self.name+"_feather") obj.Shape = self.feather obj.Label=self.name+"_feather" obj.ViewObject.ShapeColor=tuple([0.0,0.0,0.0]) obj = doc.addObject("Part::Feature",self.name+"_usbjack") obj.Shape = self.usbjack obj.Label=self.name+"_usbjack" obj.ViewObject.ShapeColor=tuple([.85,.85,.85]) def __init__(self,name,origin): self.name = name if not isinstance(origin,Base.Vector): raise RuntimeError("origin is not a Vector!") self.origin = origin self.board = Part.makePlane(self._boardLength,self._boardWidth,self.origin).extrude(Base.Vector(0,0,62.5)) self.h1 = Part.makePlane(1600,100,self.origin.add(Base.Vector(200,500,62.5))).extrude(Base.Vector(0,0,296.5)) self.h2 = Part.makePlane(1200,100,self.origin.add(Base.Vector(600,1300,62.5))).extrude(Base.Vector(0,0,296.5)) self.feather = Part.makePlane(self._FeatherLength,self._FeatherWidth,\ self.origin.add(Base.Vector(0,self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100))).extrude(Base.Vector(0,0,62.5)) self.usbjack = self.USBJack() self.board = self.board.cut(self.mountingHole(1)) self.board = self.board.cut(self.mountingHole(2)) self.board = self.board.cut(self.mountingHole(3)) self.board = self.board.cut(self.mountingHole(4))
obj.Shape = self.usbjack obj.Label=self.name+"_usbjack" obj.ViewObject.ShapeColor=tuple([.85,.85,.85]) def __init__(self,name,origin): self.name = name if not isinstance(origin,Base.Vector): raise RuntimeError("origin is not a Vector!") self.origin = origin self.board = Part.makePlane(self._boardLength,self._boardWidth,self.origin).extrude(Base.Vector(0,0,62.5)) self.h1 = Part.makePlane(1600,100,self.origin.add(Base.Vector(200,500,62.5))).extrude(Base.Vector(0,0,296.5)) self.h2 = Part.makePlane(1200,100,self.origin.add(Base.Vector(600,1300,62.5))).extrude(Base.Vector(0,0,296.5)) self.feather = Part.makePlane(self._FeatherLength,self._FeatherWidth,\ self.origin.add(Base.Vector(0,self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100))).extrude(Base.Vector(0,0,62.5)) self.usbjack = self.USBJack() self.board = self.board.cut(self.mountingHole(1)) self.board = self.board.cut(self.mountingHole(2)) self.board = self.board.cut(self.mountingHole(3)) self.board = self.board.cut(self.mountingHole(4)) if __name__ == '__main__': if "ReflowToasterOven2Board" in App.listDocuments().keys(): App.closeDocument("ReflowToasterOven2Board") App.ActiveDocument=App.newDocument("ReflowToasterOven2Board") doc = App.activeDocument() board = ReflowToasterOven2Board("b",Base.Vector(0,0,0)) board.show() Gui.SendMsgToActiveView("ViewFit") Gui.activeDocument().activeView().viewIsometric()
def testReverseOrientation(self): self.face.reverse() self.assertEqual(self.face.normalAt(0, 0), Base.Vector(0, 0, -1)) self.assertEqual(self.face.Surface.normal(0, 0), Base.Vector(0, 0, 1))
def testFaceNormal(self): self.assertEqual(self.face.normalAt(0, 0), Base.Vector(0, 0, 1)) self.assertEqual(self.face.Surface.normal(0, 0), Base.Vector(0, 0, 1))
def move(self, p): """set current position""" self.pos = Base.Vector(*p)
def line(self, p): """Add a segment between self.pos and p""" p = rotate(p, self.theta) end = Base.Vector(*p) self.wire.append(Part.LineSegment(self.pos, end)) self.pos = end
o2))).extrude(len1)) def show(self): doc = App.activeDocument() obj = doc.addObject("Part::Feature", self.name) obj.Shape = self.plunger obj.Label = self.name obj.ViewObject.ShapeColor = tuple([0.0, 0.0, 0.0]) if __name__ == '__main__': if "TeensyThumbStickCoverTechDrawing" in App.listDocuments().keys(): App.closeDocument("TeensyThumbStickCoverTechDrawing") App.ActiveDocument = App.newDocument("TeensyThumbStickCoverTechDrawing") doc = App.activeDocument() orig = Base.Vector(0, 0, 0) thick = .125 * 25.4 thickness = Base.Vector(0, 0, thick) teensyThumbStickDrop = .25 * 25.4 panel = Part.makePlane(150, 150, orig).extrude(thickness) teensythumborig = orig.add( Base.Vector(25, 25, -(teensyThumbStickDrop + TeensyThumbStick_._BoardThick))) teensythumbstick = TeensyThumbStick("teensythumbstick", teensythumborig) panel = panel.cut(teensythumbstick.MountingHole(1, 0, thick)) panel = panel.cut(teensythumbstick.MountingHole(2, 0, thick)) panel = panel.cut(teensythumbstick.MountingHole(3, 0, thick)) panel = panel.cut(teensythumbstick.MountingHole(4, 0, thick)) standoff1 = teensythumbstick.Standoff(1, 0, -teensyThumbStickDrop, .25 * 25.4) standoff2 = teensythumbstick.Standoff(2, 0, -teensyThumbStickDrop,
def USBJackCutoutHole(self,xPanel): cutoutOrig = self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5)) cutoutOrig = Base.Vector(xPanel,cutoutOrig.y+110,cutoutOrig.z+55) return Part.Face(Part.Wire(Part.makeCircle(175,cutoutOrig,Base.Vector(1,0,0))))
def Cutout(self, zBase, panelThick): cutouto = self.cutoutorigin cutouto = Base.Vector(cutouto.x, cutouto.y, zBase) thick = Base.Vector(0, 0, panelThick) return Part.makePlane(self._CoverCutoutWidth, self._CoverCutoutHeight, cutouto).extrude(thick)
def USBJack(self): return Part.makePlane(300,220,\ self.origin.add(Base.Vector(-40,\ self._FeatherYUSB_Offset+self._FeatherYBoardOffset,\ 62.5 + 196.5 + 100 + 62.5))\ ).extrude(Base.Vector(0,0,110))
soff = self.mh[i] soff = Base.Vector(soff.x,soff.y,zBase) stall = Base.Vector(0,0,height) srad = diameter/2.0 return Part.Face(Part.Wire(Part.makeCircle(srad,soff))).extrude(stall) if __name__ == '__main__': if "HDMIMainBoardMountingBracket" in App.listDocuments().keys(): App.closeDocument("HDMIMainBoardMountingBracket") App.ActiveDocument=App.newDocument("HDMIMainBoardMountingBracket") doc = App.activeDocument() _insulatedWasherThick = .065*25.4 _insulatedWasherDiameter = .250*25.4 hmiconvertermainboardorig = Base.Vector(0,0,0) hdmiconvertermainboard = HDMIConverterMainBoard("mainboard",hmiconvertermainboardorig) hdmiconvertermainboard_washer1 = hdmiconvertermainboard.Standoff(1,hmiconvertermainboardorig.z,-_insulatedWasherThick,_insulatedWasherDiameter) hdmiconvertermainboard_washer2 = hdmiconvertermainboard.Standoff(2,hmiconvertermainboardorig.z,-_insulatedWasherThick,_insulatedWasherDiameter) hdmiconvertermainboard_washer3 = hdmiconvertermainboard.Standoff(3,hmiconvertermainboardorig.z,-_insulatedWasherThick,_insulatedWasherDiameter) hdmiconvertermainboard_washer4 = hdmiconvertermainboard.Standoff(4,hmiconvertermainboardorig.z,-_insulatedWasherThick,_insulatedWasherDiameter) c1 = (hdmiconvertermainboard.mh[1].x+hdmiconvertermainboard.mh[2].x)/2.0 b1x = c1 - (hdmiconvertermainboard.bracketwidth()/2.0) c2 = (hdmiconvertermainboard.mh[3].x+hdmiconvertermainboard.mh[4].x)/2.0 b2x = c2 - (hdmiconvertermainboard.bracketwidth()/2.0) by = hmiconvertermainboardorig.y bz = hmiconvertermainboardorig.z - _insulatedWasherThick hdmiconvertermainboardRightBracket = HDMIConverterMainBoardBracket("_hdmiconvertermainboardRightBracket",Base.Vector(b1x,by,bz)) hdmiconvertermainboardRightBracket.cutFrom(hdmiconvertermainboard.MountingHole(1,bz,-hdmiconvertermainboard.bracketthinkness())) hdmiconvertermainboardRightBracket.cutFrom(hdmiconvertermainboard.MountingHole(2,bz,-hdmiconvertermainboard.bracketthinkness())) hdmiconvertermainboardLeftBracket = HDMIConverterMainBoardBracket("_hdmiconvertermainboardLeftBracket",Base.Vector(b2x,by,bz))
def upper_tabletop_2(d, dressup=True): m = Part.makeBox(d["length"], d["width"], d["upper_tabletop_t"]) m.translate(Base.Vector(-d["length"] / 2, -d["width"] / 2, 0)) m = dc.model.fillet_edges_by_length(m, 35, d["upper_tabletop_t"]) print("Upper tabletop length: ", d["length"]) print("Upper tabletop width: ", d["width"]) ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 135 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["upper_tabletop_t"], p, Base.Vector(0, 0, 1), 360) insert_1 = Part.makeBox(d["leg_t"], d["insertion_width_1"], d["insertion_length"]) insert_1 = dc.model.fillet_edges_by_length(insert_1, d["leg_edge_radii"], d["insertion_length"]) insert_1.translate(Base.Vector(-d["leg_t"] / 2, -d["cx"], 0)) insert_1.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_1.translate(p) insert_2 = Part.makeBox(d["leg_t"], d["insertion_width_2"], d["insertion_length"]) insert_2 = dc.model.fillet_edges_by_length(insert_2, d["leg_edge_radii"], d["insertion_length"]) insert_2.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2.0, 0)) insert_2.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_2.translate(p) m = m.cut(insert_1).cut(insert_2).cut(hole) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 300) m.translate(Base.Vector(0, 0, -d["upper_tabletop_t"])) return m
def MountingHole(self,yBase,yHeight): mhorig = Base.Vector(self.holeorig.x,yBase,self.holeorig.z) vthick = Base.Vector(0,yHeight,0) YNorm = Base.Vector(0,1,0) hole = Part.Face(Part.Wire(Part.makeCircle(self.bracketholedia()/2,mhorig,YNorm))).extrude(vthick) return hole
def leg(d, dressup=True): s1 = d["leg_s1"] s2 = d["leg_s2"] s3 = d["leg_s3"] s4 = d["leg_s4"] s5 = d["leg_s5"] x0 = d["insertion_width_1"] x1 = 105 x2 = d["cx"] - d["insertion_width_3"] / 2.0 x3 = x2 + d["insertion_width_2"] x4 = d["cx"] + d["insertion_width_3"] / 2.0 x5 = x2 - 20 x6 = 100 x7 = x6 - 50 y0 = d["height"] - d["upper_tabletop_t"] + d["insertion_length"] y1 = d["height"] - d["upper_tabletop_t"] - 5 y2 = y0 - 10 y3 = d["height_1"] + 100 y4 = d["height_1"] - d["insertion_length"] y5 = y4 + 15 print("Leg length: ", y0) print("Leg width: ", x3) p = [None] * 21 p[0] = Base.Vector(0, y0, 0) p[1] = Base.Vector(x0, y0, 0) p[2] = Base.Vector(x0, y1, 0) p[4] = Base.Vector(x1, y3, 0) p[6] = Base.Vector(x2, y1, 0) p[7] = Base.Vector(x2, y0, 0) p[8] = Base.Vector(x3, y0, 0) p[9] = Base.Vector(x3, y1, 0) p[11] = Base.Vector(x4, y5, 0) p[12] = Base.Vector(x4, y4, 0) p[13] = Base.Vector(x2, y4, 0) p[14] = Base.Vector(x2, y5, 0) p[15] = Base.Vector(x5, y5, 0) p[17] = Base.Vector(x6, 0, 0) p[18] = Base.Vector(x7, 0, 0) p[20] = Base.Vector(0, y2, 0) p[3] = dc.model.sagpoint(p[2], p[4], s1) p[5] = dc.model.sagpoint(p[4], p[6], s2) p[10] = dc.model.sagpoint(p[9], p[11], s3) p[16] = dc.model.sagpoint(p[15], p[17], s4) p[19] = dc.model.sagpoint(p[18], p[20], s5) wire = [ Part.makeLine(p[0], p[1]), Part.makeLine(p[1], p[2]), dc.model.makeArc(p[2:5]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), Part.makeLine(p[7], p[8]), Part.makeLine(p[8], p[9]), dc.model.makeArc(p[9:12]), Part.makeLine(p[11], p[12]), Part.makeLine(p[12], p[13]), Part.makeLine(p[13], p[14]), Part.makeLine(p[14], p[15]), dc.model.makeArc(p[15:18]), Part.makeLine(p[17], p[18]), dc.model.makeArc(p[18:]), Part.makeLine(p[20], p[0]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["leg_t"])) m = dc.model.fillet_edge_xy(m, 7, p[2]) m = dc.model.fillet_edge_xy(m, 12, p[4]) m = dc.model.fillet_edge_xy(m, 7, p[6]) m = dc.model.fillet_edge_xy(m, 7, p[9]) m = dc.model.fillet_edge_xy(m, 7, p[14]) m = dc.model.fillet_edge_xy(m, 12, p[15]) m = dc.model.fillet_edge_xy(m, 30, p[20]) m.rotate(Base.Vector(0, 0, 0), Base.Vector(1, 0, 0), 90) m.translate(Base.Vector(0, d["leg_t"] / 2.0, 0)) hole = Part.makeCylinder( d["hole_dia_leg"] / 2.0, d["height"], Base.Vector(d["cx"], 0, d["height_1"] - d["insertion_length"]), Base.Vector(0, 0, 1), 360) m = m.cut(hole) if dressup: m = dc.model.fillet_edges_longer_than(m, d["leg_edge_radii"], 95) return m
def MountingHole(self,i,zBase,panelThick): mh = self.mh[i] mh = Base.Vector(mh.x,mh.y,zBase) thick = Base.Vector(0,0,panelThick) mrad = self.hvpowerboardMHDia()/2.0 return Part.Face(Part.Wire(Part.makeCircle(mrad,mh))).extrude(thick)
def upper_tabletop_3(d, dressup=True): s = 35 x1 = d["length"] / 2.0 y1 = d["width"] / 2.0 x2 = x1 - 25 y2 = y1 - 25 p = [None] * 12 p[0] = Base.Vector(-x1, y2, 0) p[1] = Base.Vector(-x2, y1, 0) p[3] = Base.Vector(x2, y1, 0) p[4] = Base.Vector(x1, y2, 0) p[6] = Base.Vector(x1, -y2, 0) p[7] = Base.Vector(x2, -y1, 0) p[9] = Base.Vector(-x2, -y1, 0) p[10] = Base.Vector(-x1, -y2, 0) p[2] = dc.model.sagpoint(p[1], p[3], s) p[5] = dc.model.sagpoint(p[4], p[6], s) p[8] = dc.model.sagpoint(p[7], p[9], s) p[11] = dc.model.sagpoint(p[10], p[0], s) wire = [ Part.makeLine(p[0], p[1]), dc.model.makeArc(p[1:4]), Part.makeLine(p[3], p[4]), dc.model.makeArc(p[4:7]), Part.makeLine(p[6], p[7]), dc.model.makeArc(p[7:10]), Part.makeLine(p[9], p[10]), dc.model.makeArc([p[10], p[11], p[0]]) ] face = Part.Face(Part.Wire(wire)) m = face.extrude(Base.Vector(0, 0, d["upper_tabletop_t"])) m = dc.model.fillet_edges_by_length(m, 60, d["upper_tabletop_t"]) print("Upper tabletop length: ", d["length"]) print("Upper tabletop width: ", d["width"]) ccx = d["length"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) ccy = d["width"] - 2 * math.sqrt( ((d["cx"] + d["leg_distance_from_corner"])**2) / 2.0) hx = ccx / 2.0 hy = ccy / 2.0 hole_points = [ Base.Vector(hx, hy, 0), Base.Vector(-hx, hy, 0), Base.Vector(-hx, -hy, 0), Base.Vector(hx, -hy, 0) ] a = 135 for p in hole_points: hole = Part.makeCylinder(d["hole_dia_tabletop"] / 2.0, d["upper_tabletop_t"] / 2.0, p, Base.Vector(0, 0, 1), 360) insert_1 = Part.makeBox(d["leg_t"], d["insertion_width_1"], d["insertion_length"]) insert_1 = dc.model.fillet_edges_by_length(insert_1, d["leg_edge_radii"], d["insertion_length"]) insert_1.translate(Base.Vector(-d["leg_t"] / 2, -d["cx"], 0)) insert_1.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_1.translate(p) insert_2 = Part.makeBox(d["leg_t"], d["insertion_width_2"], d["insertion_length"]) insert_2 = dc.model.fillet_edges_by_length(insert_2, d["leg_edge_radii"], d["insertion_length"]) insert_2.translate( Base.Vector(-d["leg_t"] / 2, -d["insertion_width_3"] / 2.0, 0)) insert_2.rotate(Base.Vector(0, 0, 0), Base.Vector(0, 0, 1), a) insert_2.translate(p) m = m.cut(insert_1).cut(insert_2).cut(hole) a = a + 90 if dressup: m = dc.model.fillet_edges_longer_than(m, d["tabletop_edge_radii"], 300) m.translate(Base.Vector(0, 0, -d["upper_tabletop_t"])) return m
def Standoff(self,i,zBase,height,diameter): soff = self.mh[i] soff = Base.Vector(soff.x,soff.y,zBase) stall = Base.Vector(0,0,height) srad = diameter/2.0 return Part.Face(Part.Wire(Part.makeCircle(srad,soff))).extrude(stall)
def __init__(self, name, origin): self.name = name if not isinstance(origin, Base.Vector): raise RuntimeError("origin is not a Vector") self.origin = origin xc = origin.x yc = origin.y zc = origin.z l2 = DO_15_bendedLeads_400_under._bodylen / 2.0 brad = DO_15_bendedLeads_400_under._bodydia / 2.0 leadhlen = (DO_15_bendedLeads_400_under._leadspacing - DO_15_bendedLeads_400_under._bodylen) / 2.0 availleadvlen = DO_15_bendedLeads_400_under._totalleadLength - leadhlen leadvlen = brad + ((1.0 / 16.0) * 25.4) if leadvlen > availleadvlen: leadvlen = availleadvlen self.body = Part.Face( Part.Wire( Part.makeCircle(brad, Base.Vector(xc - l2, yc, zc - brad), Base.Vector(1.0, 0, 0)))).extrude( Base.Vector( DO_15_bendedLeads_400_under._bodylen, 0, 0)) leadrad = DO_15_bendedLeads_400_under._leaddia / 2.0 lead1 = Part.Face( Part.Wire( Part.makeCircle(leadrad, Base.Vector(xc - l2, yc, zc - brad), Base.Vector(1.0, 0, 0)))).extrude( Base.Vector(-(leadhlen + leadrad), 0, 0)) lead2 = Part.Face( Part.Wire( Part.makeCircle(leadrad, Base.Vector(xc + l2, yc, zc - brad), Base.Vector(1.0, 0, 0)))).extrude( Base.Vector(leadhlen + leadrad, 0, 0)) halfleadspacing = DO_15_bendedLeads_400_under._leadspacing / 2.0 self.lead1 = lead1.fuse( Part.Face( Part.Wire( Part.makeCircle( leadrad, Base.Vector(xc - halfleadspacing, yc, zc - brad)))).extrude( Base.Vector(0, 0, leadvlen))) self.lead2 = lead2.fuse( Part.Face( Part.Wire( Part.makeCircle( leadrad, Base.Vector(xc + halfleadspacing, yc, zc - brad)))).extrude( Base.Vector(0, 0, leadvlen)))
def smgetSubface(face, obj, edge, thk): # Project thickness side edge to get one side rectangle normal = face.normalAt(0, 0) faceVert = face.Vertexes[0].Point pt1 = edge.Vertexes[0].Point.projectToPlane(faceVert, normal) pt2 = edge.Vertexes[1].Point.projectToPlane(faceVert, normal) vec1 = (pt2 - pt1) # find min & max point of cut shape wallsolidlist = [] for solid in obj.Solids: pt_list = [] for vertex in solid.Vertexes: poi = vertex.Point pt = poi.projectToPlane(faceVert, normal) pt_list.append(pt) p1 = Base.Vector(min([pts.x for pts in pt_list]), min([pts.y for pts in pt_list]), min([pts.z for pts in pt_list])) p2 = Base.Vector(max([pts.x for pts in pt_list]), max([pts.y for pts in pt_list]), max([pts.z for pts in pt_list])) #print([p1, p2]) # Find angle between diagnoal & thickness side edge vec2 = (p2 - p1) angle1 = vec2.getAngle(vec1) angle = math.degrees(angle1) #print(angle) # Check & correct orientation of diagnoal edge rotation e = Part.makeLine(p1, p2) e.rotate(p1, normal, -angle) vec2 = (e.valueAt(e.LastParameter) - e.valueAt(e.FirstParameter)).normalize() coeff = vec2.dot(vec1.normalize()) #print(coeff) if coeff != 1.0: angle = 90 - angle # Create Cut Rectangle Face from min/max points & angle e = Part.Line(p1, p2).toShape() e1 = e.copy() e1.rotate(p1, normal, -angle) e2 = e.copy() e2.rotate(p2, normal, 90 - angle) section1 = e1.section(e2) #Part.show(section1,'section1') p3 = section1.Vertexes[0].Point e3 = e.copy() e3.rotate(p1, normal, 90 - angle) e4 = e.copy() e4.rotate(p2, normal, -angle) section2 = e3.section(e4) #Part.show(section2,'section2') p4 = section2.Vertexes[0].Point w = Part.makePolygon([p1, p3, p2, p4, p1]) #Part.show(w, "wire") face = Part.Face(w) wallSolid = face.extrude(normal * -thk) wallsolidlist.append(wallSolid) return wallsolidlist