cosplay: Touhou/Houjuu Nue #4
|
@ -54,16 +54,18 @@ ROLE_COLOR_MAP = {
|
||||||
class Material(Enum):
|
class Material(Enum):
|
||||||
"""
|
"""
|
||||||
A catalog of common material properties
|
A catalog of common material properties
|
||||||
|
|
||||||
|
Density listed is in g/cm^3 or mg/mm^3
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WOOD_BIRCH = 0.8, _color('bisque', 0.9)
|
WOOD_BIRCH = 0.71, _color('bisque', 0.9)
|
||||||
PLASTIC_PLA = 0.5, _color('mistyrose', 0.8)
|
PLASTIC_PLA = 1.2, _color('mistyrose', 0.8)
|
||||||
RESIN_TRANSPERENT = 1.1, _color('cadetblue2', 0.6)
|
RESIN_TRANSPERENT = 1.17, _color('cadetblue2', 0.6)
|
||||||
RESIN_TOUGH_1500 = 1.1, _color('seashell3', 0.7)
|
RESIN_TOUGH_1500 = 1.17, _color('seashell3', 0.7)
|
||||||
ACRYLIC_BLACK = 0.5, _color('gray5', 0.8)
|
ACRYLIC_BLACK = 1.18, _color('gray5', 0.8)
|
||||||
ACRYLIC_TRANSLUSCENT = 0.5, _color('ivory2', 0.8)
|
ACRYLIC_TRANSLUSCENT = 1.18, _color('ivory2', 0.8)
|
||||||
ACRYLIC_TRANSPARENT = 0.5, _color('ghostwhite', 0.5)
|
ACRYLIC_TRANSPARENT = 1.18, _color('ghostwhite', 0.5)
|
||||||
STEEL_SPRING = 1.0, _color('gray', 0.8)
|
STEEL_SPRING = 7.8, _color('gray', 0.8)
|
||||||
|
|
||||||
def __init__(self, density: float, color: Cq.Color):
|
def __init__(self, density: float, color: Cq.Color):
|
||||||
self.density = density
|
self.density = density
|
||||||
|
@ -110,3 +112,16 @@ def color_by_role(self: Cq.Assembly, avg: bool = True) -> Cq.Assembly:
|
||||||
a.color = role.color_avg() if avg else role.color_head()
|
a.color = role.color_avg() if avg else role.color_head()
|
||||||
return self
|
return self
|
||||||
Cq.Assembly.color_by_role = color_by_role
|
Cq.Assembly.color_by_role = color_by_role
|
||||||
|
|
||||||
|
def total_mass(self: Cq.Assembly) -> float:
|
||||||
|
"""
|
||||||
|
Calculates the total mass in units of g
|
||||||
|
"""
|
||||||
|
total = 0.0
|
||||||
|
for _, a in self.traverse():
|
||||||
|
if 'material' not in a.metadata:
|
||||||
|
continue
|
||||||
|
vol = a.toCompound().Volume()
|
||||||
|
total += vol * a.metadata['material'].density
|
||||||
|
return total / 1000.0
|
||||||
|
Cq.Assembly.total_mass = total_mass
|
||||||
|
|
|
@ -146,11 +146,19 @@ class Parameters(Model):
|
||||||
bbox = a.toCompound().BoundingBox()
|
bbox = a.toCompound().BoundingBox()
|
||||||
return {
|
return {
|
||||||
"wing-span": bbox.xlen,
|
"wing-span": bbox.xlen,
|
||||||
"wing-thickness": bbox.ylen,
|
"wing-depth": bbox.ylen,
|
||||||
"wing-height": bbox.zlen,
|
"wing-height": bbox.zlen,
|
||||||
|
"wing-mass": a.total_mass(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
|
||||||
p = Parameters()
|
p = Parameters()
|
||||||
|
if len(sys.argv) == 1:
|
||||||
p.build_all()
|
p.build_all()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if sys.argv[1] == 'stat':
|
||||||
|
print(p.stat())
|
||||||
|
|
Loading…
Reference in New Issue