diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index ba9f064e0b..52ccd255bf 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -48,6 +48,9 @@ class ExporterOptions: # Always stored in kg regardless of 'preferredUnits' robotWeight: KG = field(default=0.0) + frictionOverride: bool = field(default=False) + frictionOverrideCoeff: float | None = field(default=None) + compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index a08506d1cc..97d8d47f57 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -1,4 +1,5 @@ # Should contain Physical and Apperance materials ? +import json import logging import math import traceback @@ -7,7 +8,7 @@ from proto.proto_out import material_pb2 -from ...general_imports import INTERNAL_ID +from ...general_imports import * from ...Logging import logFailure, timed from ..ExporterOptions import ExporterOptions from .PDMessage import PDMessage @@ -15,6 +16,23 @@ OPACITY_RAMPING_CONSTANT = 14.0 +# Update tables as needed for UX and needed materials +STATIC_FRICTION_COEFFS = { + "Aluminum": 1.1, + "Steel, Cast": 0.75, + "Steel, Mild": 0.75, + "Rubber, Nitrile": 1.0, + "ABS Plastic": 0.7, +} + +DYNAMIC_FRICTION_COEFFS = { + "Aluminum": 1.1, + "Steel, Cast": 0.75, + "Steel, Mild": 0.75, + "Rubber, Nitrile": 1.0, + "ABS Plastic": 0.7, +} + def _MapAllPhysicalMaterials( physicalMaterials: list, @@ -22,7 +40,7 @@ def _MapAllPhysicalMaterials( options: ExporterOptions, progressDialog: PDMessage, ) -> None: - setDefaultMaterial(materials.physicalMaterials["default"]) + setDefaultMaterial(materials.physicalMaterials["default"], options) for material in physicalMaterials: progressDialog.addMaterial(material.name) @@ -34,15 +52,19 @@ def _MapAllPhysicalMaterials( getPhysicalMaterialData(material, newmaterial, options) -def setDefaultMaterial(physical_material: material_pb2.PhysicalMaterial): +def setDefaultMaterial(physical_material: material_pb2.PhysicalMaterial, options: ExporterOptions): construct_info("default", physical_material) physical_material.description = "A default physical material" - physical_material.dynamic_friction = 0.5 - physical_material.static_friction = 0.5 + if options.frictionOverride: + physical_material.dynamic_friction = options.frictionOverrideCoeff + physical_material.static_friction = options.frictionOverrideCoeff + else: + physical_material.dynamic_friction = 0.5 + physical_material.static_friction = 0.5 + physical_material.restitution = 0.5 physical_material.deformable = False - physical_material.matType = 0 @@ -66,10 +88,14 @@ def getPhysicalMaterialData(fusion_material, proto_material, options): mechanicalProperties = proto_material.mechanical strengthProperties = proto_material.strength - proto_material.dynamic_friction = 0.5 - proto_material.static_friction = 0.5 - proto_material.restitution = 0.5 + if options.frictionOverride: + proto_material.dynamic_friction = options.frictionOverrideCoeff + proto_material.static_friction = options.frictionOverrideCoeff + else: + proto_material.dynamic_friction = DYNAMIC_FRICTION_COEFFS.get(fusion_material.name, 0.5) + proto_material.static_friction = STATIC_FRICTION_COEFFS.get(fusion_material.name, 0.5) + proto_material.restitution = 0.5 proto_material.description = f"{fusion_material.name} exported from FUSION" """ diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 692b21cab2..b59f391f0b 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -50,8 +50,6 @@ def export(self) -> None: # Physical Props here when ready - # ts = time() - progressDialog = app.userInterface.createProgressDialog() progressDialog.cancelButtonText = "Cancel" progressDialog.isBackgroundTranslucent = False diff --git a/exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png b/exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png new file mode 100644 index 0000000000..34f6b927a4 Binary files /dev/null and b/exporter/SynthesisFusionAddin/src/Resources/FrictionOverride_icon/32x32-normal.png differ diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 038ca3e19e..4a501b1319 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -3,7 +3,7 @@ """ import os -import pathlib +import traceback from enum import Enum import adsk.core @@ -461,7 +461,7 @@ def notify(self, args): "friction_override", "Friction Override", physics_settings, - checked=True, # object is missing attribute + checked=True, tooltip="Manually override the default friction values on the bodies in the assembly.", enabled=True, isCheckBox=False, @@ -873,6 +873,15 @@ def notify(self, args): .children.itemById("export_as_part") ).value + frictionOverrideSlider = ( + eventArgs.command.commandInputs.itemById("advanced_settings") + .children.itemById("physics_settings") + .children.itemById("friction_override_coeff") + ) + + frictionOverride = frictionOverrideSlider.isVisible + frictionOverrideCoeff = frictionOverrideSlider.valueOne + exporterOptions = ExporterOptions( savepath, name, @@ -887,6 +896,8 @@ def notify(self, args): exportLocation=_location, compressOutput=compress, exportAsPart=export_as_part_boolean, + frictionOverride=frictionOverride, + frictionOverrideCoeff=frictionOverrideCoeff, ) Parser(exporterOptions).export() diff --git a/fission/src/mirabuf/MirabufParser.ts b/fission/src/mirabuf/MirabufParser.ts index 4c4e18060f..dd7df1e7cf 100644 --- a/fission/src/mirabuf/MirabufParser.ts +++ b/fission/src/mirabuf/MirabufParser.ts @@ -232,6 +232,15 @@ class MirabufParser { directedRecursive(this._rigidNodes[0].id) } this._directedGraph = directedGraph + + // Transition: GH-1014 + const partDefinitions: { [k: string]: mirabuf.IPartDefinition } | null | undefined = + this.assembly.data?.parts?.partDefinitions + if (!partDefinitions) { + console.log("Failed to get part definitions") + return + } + console.log(partDefinitions) } private NewRigidNode(suffix?: string): RigidNode {