Initial commit.
This commit is contained in:
parent
68d9a17dd1
commit
29ffa13092
17 changed files with 224546 additions and 0 deletions
101
src/product_gen/generate_lamp.py
Normal file
101
src/product_gen/generate_lamp.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
# freecad setup
|
||||
FREECADPATH = "/usr/lib/freecad/lib/"
|
||||
sys.path.append(FREECADPATH)
|
||||
import numpy as np
|
||||
import FreeCAD
|
||||
import Part
|
||||
|
||||
# def generate_bulb(height, radius, thickness):
|
||||
#
|
||||
# light_angle = np.arcsin(0.25) + np.pi/2.0
|
||||
# light_arc_length = radius*light_angle+np.pi/2.0
|
||||
# num_divisions = 25
|
||||
# segment_length = light_arc_length/float(num_divisions)
|
||||
#
|
||||
# edges = []
|
||||
# for idx in range(1, num_divisions):
|
||||
# angle0 = float(idx-1)/float(num_divisions)*light_angle
|
||||
# angle1 = float(idx)/float(num_divisions)*light_angle
|
||||
# x0 = -radius*np.sin(angle0)
|
||||
# y0 = -radius*np.cos(angle0)
|
||||
# x1 = -radius*np.sin(angle1)
|
||||
# y1 = -radius*np.cos(angle1)
|
||||
# edges.append(Part.makeLine((x0, y0, 0),
|
||||
# (x1, y1, 0)))
|
||||
#
|
||||
# edge0 = Part.makeLine((0.0, height, 0),
|
||||
# (-radius, 0.0, 0))
|
||||
# edge1 = Part.makeLine((-radius, 0.0, 0),
|
||||
# (-radius -thickness, 0.0, 0))
|
||||
# edge2 = Part.makeLine((-radius -thickness, 0.0, 0),
|
||||
# (-radius -thickness, height, 0))
|
||||
# edge3 = Part.makeLine((-radius -thickness, height, 0),
|
||||
# (0.0, height, 0))
|
||||
# wire1 = Part.Wire([edge0, edge1, edge2, edge3])
|
||||
# face = Part.Face([wire1,])
|
||||
#
|
||||
# pos = FreeCAD.Vector(0.0, 0.0, 0.0)
|
||||
# vec = FreeCAD.Vector(0.0, 1.0, 0.0)
|
||||
# angle = 360
|
||||
# solid = face.revolve(pos, vec, angle)
|
||||
# return solid
|
||||
|
||||
def generate_chord(height, radius, thickness):
|
||||
|
||||
edge0 = Part.makeLine((0.0, height, 0),
|
||||
(-radius, 0.0, 0))
|
||||
edge1 = Part.makeLine((-radius, 0.0, 0),
|
||||
(-radius -thickness, 0.0, 0))
|
||||
edge2 = Part.makeLine((-radius -thickness, 0.0, 0),
|
||||
(-radius -thickness, height, 0))
|
||||
edge3 = Part.makeLine((-radius -thickness, height, 0),
|
||||
(0.0, height, 0))
|
||||
wire1 = Part.Wire([edge0, edge1, edge2, edge3])
|
||||
face = Part.Face([wire1,])
|
||||
|
||||
pos = FreeCAD.Vector(0.0, 0.0, 0.0)
|
||||
vec = FreeCAD.Vector(0.0, 1.0, 0.0)
|
||||
angle = 360
|
||||
solid = face.revolve(pos, vec, angle)
|
||||
return solid
|
||||
|
||||
def generate_base(height, radius, thickness):
|
||||
|
||||
edge0 = Part.makeLine((0.0, 0.0, 0),
|
||||
(-radius, -height, 0))
|
||||
edge1 = Part.makeLine((-radius, -height, 0),
|
||||
(-radius -thickness, -height, 0))
|
||||
edge2 = Part.makeLine((-radius -thickness, -height, 0),
|
||||
(-thickness, 0.0, 0))
|
||||
edge3 = Part.makeLine((-thickness, 0.0, 0),
|
||||
(0.0, 0.0, 0))
|
||||
wire1 = Part.Wire([edge0, edge1, edge2, edge3])
|
||||
face = Part.Face([wire1,])
|
||||
|
||||
pos = FreeCAD.Vector(0.0, 0.0, 0.0)
|
||||
vec = FreeCAD.Vector(0.0, 1.0, 0.0)
|
||||
angle = 360
|
||||
solid = face.revolve(pos, vec, angle)
|
||||
return solid
|
||||
|
||||
def generate_shade(height, radius, thickness):
|
||||
|
||||
edge0 = Part.makeLine((0.0, 0.0, 0),
|
||||
(-radius, -height, 0))
|
||||
edge1 = Part.makeLine((-radius, -height, 0),
|
||||
(-radius -thickness, -height, 0))
|
||||
edge2 = Part.makeLine((-radius -thickness, -height, 0),
|
||||
(-thickness, 0.0, 0))
|
||||
edge3 = Part.makeLine((-thickness, 0.0, 0),
|
||||
(0.0, 0.0, 0))
|
||||
wire1 = Part.Wire([edge0, edge1, edge2, edge3])
|
||||
face = Part.Face([wire1,])
|
||||
|
||||
pos = FreeCAD.Vector(0.0, 0.0, 0.0)
|
||||
vec = FreeCAD.Vector(0.0, 1.0, 0.0)
|
||||
angle = 360
|
||||
solid = face.revolve(pos, vec, angle)
|
||||
return solid
|
Loading…
Add table
Add a link
Reference in a new issue