diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 0f2ae670db..ce1fdc6ae6 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -7,7 +7,6 @@ from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm from .src.Logging import getLogger, logFailure, setupLogger -from .src.Types.OString import OString from .src.UI import ( HUI, Camera, diff --git a/exporter/SynthesisFusionAddin/src/FLAGS.py b/exporter/SynthesisFusionAddin/src/FLAGS.py deleted file mode 100644 index e8229e0733..0000000000 --- a/exporter/SynthesisFusionAddin/src/FLAGS.py +++ /dev/null @@ -1,38 +0,0 @@ -DEBUG = True # Is current Debug session active ? -""" ## DEBUG flag to determine if developer build. - - TODO: Should be built by some build system like cmake with a FLAGS.in file. -""" - -PROGRESS = True # Is showing the progress bar ? -""" ## PROGRESS flag to indicate if export progress bar shows up - - TODO: Should be built by some build system like cmake with a FLAGS.in file. -""" - -STAGING = False # Is in the Staging build for Fusion ? -""" ## STAGING flag to indicate if being used in fusion staging builds - - TODO: Should be built by some build system like cmake with a FLAGS.in file. -""" - -GENERATEDOCS = True -""" ## Generate the Code Documentation using pdoc3 to the docs folder using the fusion python instance - -""" - -PHYSICS = True # Is exporting Physics model information ? -""" ## PHYSICS flag to indicate if exporting physics model information - - COM (center of mass) - - x - - y - - z - - Density - - Mass - - Surface Area - - etc - - This is part of the ParserOptions structure now - but this is a manual override - - TODO: Should be built by some build system like cmake with a FLAGS.in file. -""" diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index c2fc91a12c..342b35f229 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -15,72 +15,17 @@ from ..Logging import logFailure, timed from ..strings import INTERNAL_ID - -# Not 100% sure what this is for - Brandon -JointParentType = Enum("JointParentType", ["ROOT", "END"]) - -WheelType = Enum("WheelType", ["STANDARD", "OMNI", "MECANUM"]) -SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"]) -ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export -PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"]) -ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"]) - - -@dataclass -class Wheel: - jointToken: str = field(default=None) - wheelType: WheelType = field(default=None) - signalType: SignalType = field(default=None) - - -@dataclass -class Joint: - jointToken: str = field(default=None) - parent: JointParentType = field(default=None) - signalType: SignalType = field(default=None) - speed: float = field(default=None) - force: float = field(default=None) - - # Transition: AARD-1865 - # Should consider changing how the parser handles wheels and joints as there is overlap between - # `Joint` and `Wheel` that should be avoided - # This overlap also presents itself in 'ConfigCommand.py' and 'JointConfigTab.py' - isWheel: bool = field(default=False) - - -@dataclass -class Gamepiece: - occurrenceToken: str = field(default=None) - weight: float = field(default=None) - friction: float = field(default=None) - - -class PhysicalDepth(Enum): - # No Physical Properties are generated - NoPhysical = 0 - - # Only Body Physical Objects are generated - Body = 1 - - # Only Occurrence that contain Bodies and Bodies have Physical Properties - SurfaceOccurrence = 2 - - # Every Single Occurrence has Physical Properties even if empty - AllOccurrence = 3 - - -class ModelHierarchy(Enum): - # Model exactly as it is shown in Fusion in the model view tree - FusionAssembly = 0 - - # Flattened Assembly with all bodies as children of the root object - FlatAssembly = 1 - - # A Model represented with parented objects that are part of a jointed tree - PhysicalAssembly = 2 - - # Generates the root assembly as a single mesh and stores the associated data - SingleMesh = 3 +from ..Types import ( + KG, + ExportLocation, + ExportMode, + Gamepiece, + Joint, + ModelHierarchy, + PhysicalDepth, + PreferredUnits, + Wheel, +) @dataclass @@ -101,7 +46,7 @@ class ExporterOptions: preferredUnits: PreferredUnits = field(default=PreferredUnits.IMPERIAL) # Always stored in kg regardless of 'preferredUnits' - robotWeight: float = field(default=0.0) + robotWeight: KG = field(default=0.0) compressOutput: bool = field(default=True) exportAsPart: bool = field(default=False) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index 88b25055c3..aa77cac500 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -10,7 +10,8 @@ from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2 from ...Logging import logFailure, timed -from ..ExporterOptions import ExporterOptions, ExportMode +from ...Types import ExportMode +from ..ExporterOptions import ExporterOptions from . import PhysicalProperties from .PDMessage import PDMessage from .Utilities import * diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index d2e3b81bc2..c79a0240d0 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -33,7 +33,8 @@ from ...general_imports import * from ...Logging import getLogger -from ..ExporterOptions import ExporterOptions, JointParentType, SignalType +from ...Types import JointParentType, SignalType +from ..ExporterOptions import ExporterOptions from .PDMessage import PDMessage from .Utilities import construct_info, fill_info, guid_occurrence diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index be20e373c6..a08506d1cc 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -9,7 +9,7 @@ from ...general_imports import INTERNAL_ID from ...Logging import logFailure, timed -from .. import ExporterOptions +from ..ExporterOptions import ExporterOptions from .PDMessage import PDMessage from .Utilities import * diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 2d7623b272..df7670ddf5 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -10,8 +10,9 @@ from ...APS.APS import upload_mirabuf # This line causes everything to break from ...general_imports import * from ...Logging import getLogger, logFailure, timed +from ...Types import ExportLocation, ExportMode from ...UI.Camera import captureThumbnail, clearIconCache -from ..ExporterOptions import ExporterOptions, ExportLocation, ExportMode +from ..ExporterOptions import ExporterOptions from . import Components, JointHierarchy, Joints, Materials, PDMessage from .Utilities import * diff --git a/exporter/SynthesisFusionAddin/src/Types/OString.py b/exporter/SynthesisFusionAddin/src/Types.py similarity index 71% rename from exporter/SynthesisFusionAddin/src/Types/OString.py rename to exporter/SynthesisFusionAddin/src/Types.py index ba547fe953..892fe6211b 100644 --- a/exporter/SynthesisFusionAddin/src/Types/OString.py +++ b/exporter/SynthesisFusionAddin/src/Types.py @@ -1,8 +1,92 @@ import os import pathlib import platform +from dataclasses import dataclass, field +from enum import Enum from typing import Union +# Not 100% sure what this is for - Brandon +JointParentType = Enum("JointParentType", ["ROOT", "END"]) + +WheelType = Enum("WheelType", ["STANDARD", "OMNI", "MECANUM"]) +SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"]) +ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export +PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"]) +ExportLocation = Enum("ExportLocation", ["UPLOAD", "DOWNLOAD"]) + + +@dataclass +class Wheel: + jointToken: str = field(default=None) + wheelType: WheelType = field(default=None) + signalType: SignalType = field(default=None) + + +@dataclass +class Joint: + jointToken: str = field(default=None) + parent: JointParentType = field(default=None) + signalType: SignalType = field(default=None) + speed: float = field(default=None) + force: float = field(default=None) + + # Transition: AARD-1865 + # Should consider changing how the parser handles wheels and joints as there is overlap between + # `Joint` and `Wheel` that should be avoided + # This overlap also presents itself in 'ConfigCommand.py' and 'JointConfigTab.py' + isWheel: bool = field(default=False) + + +@dataclass +class Gamepiece: + occurrenceToken: str = field(default=None) + weight: float = field(default=None) + friction: float = field(default=None) + + +class PhysicalDepth(Enum): + # No Physical Properties are generated + NoPhysical = 0 + + # Only Body Physical Objects are generated + Body = 1 + + # Only Occurrence that contain Bodies and Bodies have Physical Properties + SurfaceOccurrence = 2 + + # Every Single Occurrence has Physical Properties even if empty + AllOccurrence = 3 + + +class ModelHierarchy(Enum): + # Model exactly as it is shown in Fusion in the model view tree + FusionAssembly = 0 + + # Flattened Assembly with all bodies as children of the root object + FlatAssembly = 1 + + # A Model represented with parented objects that are part of a jointed tree + PhysicalAssembly = 2 + + # Generates the root assembly as a single mesh and stores the associated data + SingleMesh = 3 + + +class LBS(float): + """Mass Unit in Pounds.""" + + +class KG(float): + """Mass Unit in Kilograms.""" + + +def toLbs(kgs: float) -> LBS: + return LBS(round(kgs * 2.2062, 2)) + + +def toKg(pounds: float) -> KG: + return KG(round(pounds / 2.2062, 2)) + class OString: def __init__(self, path: object, fileName: str): @@ -62,7 +146,6 @@ def _os() -> str: return "Linux" else: raise OSError(2, "No Operating System Recognized", f"{osName}") - return None def AssertEquals(self, comparing: object): """Compares the two OString objects diff --git a/exporter/SynthesisFusionAddin/src/UI/Camera.py b/exporter/SynthesisFusionAddin/src/UI/Camera.py index 9fe68b7700..538968034d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Camera.py +++ b/exporter/SynthesisFusionAddin/src/UI/Camera.py @@ -4,7 +4,7 @@ from ..general_imports import * from ..Logging import logFailure, timed -from ..Types.OString import OString +from ..Types import OString from . import Helper diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 3429410ecd..e446b18909 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -12,15 +12,10 @@ from ..APS.APS import getAuth, getUserInfo, refreshAuthToken from ..general_imports import * from ..Logging import getLogger, logFailure -from ..Parser.ExporterOptions import ( - ExporterOptions, - ExportLocation, - ExportMode, - Gamepiece, - PreferredUnits, -) +from ..Parser.ExporterOptions import ExporterOptions from ..Parser.SynthesisParser.Parser import Parser from ..Parser.SynthesisParser.Utilities import guid_occurrence +from ..Types import ExportLocation, ExportMode, Gamepiece, PreferredUnits from . import CustomGraphics, FileDialogConfig, Helper, IconPaths from .Configuration.SerialCommand import SerialCommand diff --git a/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py b/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py index 7f03642fec..16084148c5 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py @@ -7,7 +7,7 @@ import json -from ...Types.OString import OString +from ...Types import OString def generateFilePath() -> str: diff --git a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py index 7af7a1e73a..6f6f764cd9 100644 --- a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py +++ b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py @@ -6,7 +6,7 @@ from ..general_imports import * # from ..proto_out import Configuration_pb2 -from ..Types.OString import OString +from ..Types import OString def saveFileDialog(defaultPath: str | None = None, defaultName: str | None = None) -> str | bool: diff --git a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py index 3e65056d4f..4f25ebfe01 100644 --- a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py @@ -6,13 +6,7 @@ from ..general_imports import INTERNAL_ID from ..Logging import logFailure -from ..Parser.ExporterOptions import ( - Joint, - JointParentType, - SignalType, - Wheel, - WheelType, -) +from ..Types import Joint, JointParentType, SignalType, Wheel, WheelType from . import IconPaths from .CreateCommandInputsHelper import ( createBooleanInput, diff --git a/exporter/SynthesisFusionAddin/src/configure.py b/exporter/SynthesisFusionAddin/src/configure.py index 20f64f4b8d..345cd9bc33 100644 --- a/exporter/SynthesisFusionAddin/src/configure.py +++ b/exporter/SynthesisFusionAddin/src/configure.py @@ -1,13 +1,11 @@ """ Stores data and fields from config.ini """ -import logging.handlers import traceback import uuid from configparser import ConfigParser from .Logging import getLogger -from .strings import INTERNAL_ID -from .Types.OString import OString +from .Types import OString logger = getLogger()