feat: integrate SimpleCADAPI 2.0.2 CAD workflows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Build, validate, replay, and export the integrated BLDC joint actuator."""
|
||||
"""Build and export the integrated BLDC joint actuator."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -8,19 +8,34 @@ from pathlib import Path
|
||||
|
||||
import simplecadapi as scad
|
||||
|
||||
from assembly import make_integrated_bldc_joint_actuator_rassembly
|
||||
from common import ground_compound
|
||||
from dimensions import (
|
||||
MOTOR_AIR_GAP,
|
||||
MOTOR_POLE_COUNT,
|
||||
MOTOR_SLOT_COUNT,
|
||||
PACKAGE_RADIUS,
|
||||
PACKAGE_STRUCTURAL_BOTTOM_Z,
|
||||
PACKAGE_TOP_Z,
|
||||
TOTAL_REDUCTION,
|
||||
validate_design_dimensions,
|
||||
)
|
||||
from materials import make_actuator_materials_rdict
|
||||
try:
|
||||
from .assembly import make_integrated_bldc_joint_actuator_rassembly
|
||||
from .common import ground_compound
|
||||
from .dimensions import (
|
||||
MOTOR_AIR_GAP,
|
||||
MOTOR_POLE_COUNT,
|
||||
MOTOR_SLOT_COUNT,
|
||||
PACKAGE_RADIUS,
|
||||
PACKAGE_STRUCTURAL_BOTTOM_Z,
|
||||
PACKAGE_TOP_Z,
|
||||
TOTAL_REDUCTION,
|
||||
validate_design_dimensions,
|
||||
)
|
||||
from .materials import make_actuator_materials_rdict
|
||||
except ImportError: # Support direct execution from this example directory.
|
||||
from assembly import make_integrated_bldc_joint_actuator_rassembly
|
||||
from common import ground_compound
|
||||
from dimensions import (
|
||||
MOTOR_AIR_GAP,
|
||||
MOTOR_POLE_COUNT,
|
||||
MOTOR_SLOT_COUNT,
|
||||
PACKAGE_RADIUS,
|
||||
PACKAGE_STRUCTURAL_BOTTOM_Z,
|
||||
PACKAGE_TOP_Z,
|
||||
TOTAL_REDUCTION,
|
||||
validate_design_dimensions,
|
||||
)
|
||||
from materials import make_actuator_materials_rdict
|
||||
|
||||
|
||||
sys.setrecursionlimit(30000)
|
||||
@@ -28,18 +43,21 @@ sys.setrecursionlimit(30000)
|
||||
OUT_DIR = Path("examples/out/integrated_bldc_joint_actuator")
|
||||
|
||||
|
||||
@scad.model(graph_id="integrated_50mm_bldc_joint_actuator")
|
||||
def build_integrated_bldc_joint_actuator():
|
||||
"""Build the replayable actuator and return product and interchange outputs."""
|
||||
|
||||
validate_design_dimensions()
|
||||
materials = make_actuator_materials_rdict()
|
||||
with scad.GraphSession(graph_id="integrated_50mm_bldc_joint_actuator") as session:
|
||||
assembly = make_integrated_bldc_joint_actuator_rassembly(materials=materials)
|
||||
preview = scad.make_compound_from_assembly_rcompound(assembly=assembly)
|
||||
ground_compound(label="integrated_actuator_preview", compound=preview)
|
||||
session_json = scad.export_session_json(session=session, indent=2)
|
||||
model_json = scad.export_model_json(session=session, indent=2)
|
||||
return assembly, preview, model_json, session_json
|
||||
assembly = make_integrated_bldc_joint_actuator_rassembly(materials=materials)
|
||||
preview = scad.make_compound_from_assembly_rcompound(assembly=assembly)
|
||||
preview = scad.apply_tag(
|
||||
shape=preview,
|
||||
tag="scene.integrated.bldc.joint.actuator.preview",
|
||||
)
|
||||
ground_compound(label="integrated_actuator_preview", compound=preview)
|
||||
scad.capture_result(value=(assembly, preview))
|
||||
return assembly, preview
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -53,19 +71,18 @@ def main() -> None:
|
||||
if fcstd_path.exists():
|
||||
fcstd_path.unlink()
|
||||
|
||||
assembly, preview, model_json, session_json = build_integrated_bldc_joint_actuator()
|
||||
model_path.write_text(model_json, encoding="utf-8")
|
||||
session_path.write_text(session_json, encoding="utf-8")
|
||||
result = build_integrated_bldc_joint_actuator()
|
||||
assembly, preview = result.value
|
||||
model_path.write_text(result.model_json, encoding="utf-8")
|
||||
session_path.write_text(result.session_json, encoding="utf-8")
|
||||
scad.export_step(shapes=preview, filename=str(step_path))
|
||||
|
||||
imported = scad.import_model_json(json_str=model_json)
|
||||
replayed = scad.replay_model_json(json_str=model_json, strict=True)
|
||||
payload = json.loads(model_json)
|
||||
payload = json.loads(result.model_json)
|
||||
|
||||
fcstd_status = "not attempted"
|
||||
try:
|
||||
scad.translator.freecad_translator.translate_model_json_to_fcstd(
|
||||
json_str=model_json,
|
||||
json_str=result.model_json,
|
||||
output_path=str(fcstd_path.resolve()),
|
||||
document_name="Integrated50mmBLDCJointActuator",
|
||||
freecad_cmd=None,
|
||||
@@ -84,9 +101,6 @@ def main() -> None:
|
||||
print(f"constraints={len(assembly.constraint_ids())}")
|
||||
print(f"preview_solids={len(preview.get_solids())}")
|
||||
print(f"preview_volume={preview.get_volume():.3f}")
|
||||
print(f"imported_keys={','.join(sorted(imported.keys()))}")
|
||||
print(f"replay_outputs={len(replayed)}")
|
||||
print("replay_types=" + ",".join(type(item).__name__ for item in replayed))
|
||||
print(f"graph_nodes={len(payload['graph']['nodes'])}")
|
||||
print(f"model={model_path}")
|
||||
print(f"session={session_path}")
|
||||
|
||||
Reference in New Issue
Block a user