Skip to content

Instantly share code, notes, and snippets.

@silicontrip
Last active January 15, 2019 07:03
Show Gist options
  • Select an option

  • Save silicontrip/740ec68ee124a567bdd6e0aad6476d3e to your computer and use it in GitHub Desktop.

Select an option

Save silicontrip/740ec68ee124a567bdd6e0aad6476d3e to your computer and use it in GitHub Desktop.
Freecad python Dalek shoulders
from FreeCAD import Base
import Part
import Sketcher
def xsection(obj,height):
wires=[]
for i in obj.slice(Base.Vector(0,0,1),height):
wires.append(i)
return Part.Wire(wires)
def make_frame(size):
return Part.makeLoft([make_base(size),make_top(size)])
def make_top(size):
return Part.Wire(Part.Shape([Part.Circle(App.Vector(0,0,345),App.Vector(0,0,1),313.5-size)]).Edges)
def make_base(size):
a1 = Part.ArcOfEllipse(Part.Ellipse(App.Vector(-430.5+size,0,0),App.Vector(0,-349+size,0),App.Vector(0.000000,0.000000,0)),-1.57079632679489661922,1.57079632679489661922)
l1 = Part.Line(App.Vector(0.000000,349.000000-size,0),App.Vector(141.368,349.0000000-size,0))
a2 = Part.ArcOfCircle(Part.Circle(App.Vector(141.368,145.868,0),App.Vector(0,0,1),203.132-size),0,1.57079632679489661922)
l2 = Part.Line(App.Vector(344.500000-size,145.868,0),App.Vector(344.500000-size,-145.868,0))
a3 = Part.ArcOfCircle(Part.Circle(App.Vector(141.368,-145.868,0),App.Vector(0,0,1),203.132-size),-1.57079632679489661922,0)
l3 = Part.Line(App.Vector(-0.000000,-349.000000+size,0),App.Vector(141.368,-349.000000+size,0))
return Part.Wire(Part.Shape([a1,l1,a2,l2,a3,l3]).Edges)
shoulder = App.newDocument("Dalek")
collar_frame = shoulder.addObject('Part::Loft', 'Collar_frame').Shape=make_frame(0)
shoulder_frame = shoulder.addObject('Part::Loft', 'Shoulder_frame').Shape=make_frame(26)
inner_frame = shoulder.addObject('Part::Loft', 'Inner_frame').Shape=make_frame(39)
print "Frames Complete"
collar_cs=[]
for h in [0,90]:
collar_cs.append(xsection(collar_frame,h))
shoulder_cs = []
for h in [90,146,213,291,345]:
shoulder_cs.append(xsection(shoulder_frame,h))
inner_cs=[]
for h in [158,225,278]:
inner_cs.append(xsection(inner_frame,h))
print "Cross Sections Complete"
collar = shoulder.addObject('Part::Loft', 'Collar').Shape=Part.makeLoft([collar_cs[0],collar_cs[1]],True,False)
lowerrear = shoulder.addObject('Part::Loft', 'LowerRear').Shape=Part.makeLoft([shoulder_cs[0],shoulder_cs[1]])
lowerfront = shoulder.addObject('Part::Loft', 'LowerFront').Shape=Part.makeLoft([shoulder_cs[0],shoulder_cs[2]])
innerrear = shoulder.addObject('Part::Loft', 'InnerRear').Shape=Part.makeLoft([inner_cs[0],inner_cs[2]])
innerfront = shoulder.addObject('Part::Loft', 'InnerFront').Shape=Part.makeLoft([inner_cs[1],inner_cs[2]])
top = shoulder.addObject('Part::Loft', 'Top').Shape=Part.makeLoft([shoulder_cs[3],shoulder_cs[4]])
topinnerjoin = shoulder.addObject('Part::Loft','TopInnerJoin').Shape=Part.makeLoft([inner_cs[2],shoulder_cs[3]])
frontinnerjoin = shoulder.addObject('Part::Loft','FrontInnerJoin').Shape=Part.makeLoft([inner_cs[1],shoulder_cs[2]])
rearinnerjoin = shoulder.addObject('Part::Loft','RearInnerJoin').Shape=Part.makeLoft([inner_cs[0],shoulder_cs[1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment