Skip to content

Commit

Permalink
Friction Data Export (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Jul 25, 2024
2 parents df36e28 + b32c9f5 commit d031348
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 13 deletions.
3 changes: 3 additions & 0 deletions exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Should contain Physical and Apperance materials ?
import json
import logging
import math
import traceback
Expand All @@ -7,22 +8,39 @@

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
from .Utilities import *

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,
materials: material_pb2.Materials,
options: ExporterOptions,
progressDialog: PDMessage,
) -> None:
setDefaultMaterial(materials.physicalMaterials["default"])
setDefaultMaterial(materials.physicalMaterials["default"], options)

for material in physicalMaterials:
progressDialog.addMaterial(material.name)
Expand All @@ -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


Expand All @@ -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"

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import os
import pathlib
import traceback
from enum import Enum

import adsk.core
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -887,6 +896,8 @@ def notify(self, args):
exportLocation=_location,
compressOutput=compress,
exportAsPart=export_as_part_boolean,
frictionOverride=frictionOverride,
frictionOverrideCoeff=frictionOverrideCoeff,
)

Parser(exporterOptions).export()
Expand Down
9 changes: 9 additions & 0 deletions fission/src/mirabuf/MirabufParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d031348

Please sign in to comment.