Add json only input.
This commit is contained in:
parent
c9c98f91dc
commit
afbacca3f4
21 changed files with 89611 additions and 118 deletions
|
@ -1,66 +1,59 @@
|
|||
import os
|
||||
import os
|
||||
import product_gen.generate_lamp_base
|
||||
import product_gen.generate_shades
|
||||
import product_gen.render_lamp
|
||||
|
||||
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(shape, height, radius, color, output_prefix,
|
||||
is_final=False):
|
||||
thickness = 3.0
|
||||
|
||||
prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix
|
||||
|
||||
def generate_chord(height, radius, thickness):
|
||||
if shape == "cone":
|
||||
shade = product_gen.generate_shades.generate_cone_shade(height, radius, thickness)
|
||||
elif shape == "mesh":
|
||||
shade = product_gen.generate_shades.generate_mesh_shade(height, radius, thickness)
|
||||
elif shape == "bio":
|
||||
shade = product_gen.generate_shades.generate_bio_shade(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,])
|
||||
shade.exportStl(prefix + "_temp_shade.stl")
|
||||
|
||||
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):
|
||||
base_height = 20.0
|
||||
base_radius = 15.0
|
||||
thickness = 3.0
|
||||
base = product_gen.generate_lamp_base.generate_base(base_height,
|
||||
base_radius,
|
||||
thickness)
|
||||
base.exportStl(prefix + "_temp_base.stl")
|
||||
|
||||
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,])
|
||||
chord_height = 150.0
|
||||
chord_radius = 2.0
|
||||
thickness = 1.0
|
||||
chord = product_gen.generate_lamp_base.generate_chord(chord_height,
|
||||
chord_radius,
|
||||
thickness)
|
||||
chord.exportStl(prefix + "_temp_chord.stl")
|
||||
|
||||
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
|
||||
if not is_final:
|
||||
product_gen.render_lamp.render_lamp(prefix + "_temp_shade.stl",
|
||||
prefix + "_temp_base.stl",
|
||||
prefix + "_temp_chord.stl",
|
||||
prefix + ".png",
|
||||
color = color)
|
||||
else:
|
||||
product_gen.render_lamp.render_lamp(prefix + "_temp_shade.stl",
|
||||
prefix + "_temp_base.stl",
|
||||
prefix + "_temp_chord.stl",
|
||||
prefix + "_kitchen.png",
|
||||
color = color)
|
||||
product_gen.render_lamp.render_lamp(prefix + "_temp_shade.stl",
|
||||
prefix + "_temp_base.stl",
|
||||
prefix + "_temp_chord.stl",
|
||||
prefix + "_hall.png",
|
||||
color = color)
|
||||
product_gen.render_lamp.render_lamp(prefix + "_temp_shade.stl",
|
||||
prefix + "_temp_base.stl",
|
||||
prefix + "_temp_chord.stl",
|
||||
prefix + "_landing.png",
|
||||
color = color)
|
Loading…
Add table
Add a link
Reference in a new issue