From ec2eda0684fccd37439676bf69681bcd3f17e333 Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Wed, 3 Jul 2024 15:50:06 -0700 Subject: [PATCH 01/11] Updates easy absolute imports --- exporter/SynthesisFusionAddin/Synthesis.py | 16 +++++++++------- exporter/SynthesisFusionAddin/proto/deps.py | 2 +- .../SynthesisFusionAddin/src/GlobalManager.py | 7 +++---- .../src/Parser/ExporterOptions.py | 2 +- .../src/Parser/SynthesisParser/Components.py | 17 +++++++++-------- .../Parser/SynthesisParser/JointHierarchy.py | 7 ++++--- .../src/Parser/SynthesisParser/Joints.py | 15 ++++++++++----- .../src/Parser/SynthesisParser/Materials.py | 7 ++++--- .../src/Parser/SynthesisParser/Parser.py | 17 ++++++++++++----- .../SynthesisParser/PhysicalProperties.py | 3 ++- .../src/Parser/SynthesisParser/RigidGroup.py | 2 +- .../src/Parser/SynthesisParser/Utilities.py | 4 +--- .../SynthesisFusionAddin/src/UI/Camera.py | 6 ++++-- .../src/UI/ConfigCommand.py | 19 ++++++++++--------- .../src/UI/Configuration/SerialCommand.py | 2 +- .../src/UI/CustomGraphics.py | 1 + .../SynthesisFusionAddin/src/UI/Events.py | 3 ++- .../src/UI/FileDialogConfig.py | 6 +++--- exporter/SynthesisFusionAddin/src/UI/HUI.py | 4 +++- .../SynthesisFusionAddin/src/UI/Handlers.py | 1 + .../SynthesisFusionAddin/src/UI/Helper.py | 5 +++-- .../SynthesisFusionAddin/src/UI/IconPaths.py | 2 +- .../SynthesisFusionAddin/src/UI/Toolbar.py | 4 +++- exporter/SynthesisFusionAddin/src/__init__.py | 6 ++++++ .../SynthesisFusionAddin/src/configure.py | 4 ++-- exporter/SynthesisFusionAddin/src/logging.py | 4 ++-- 26 files changed, 99 insertions(+), 67 deletions(-) create mode 100644 exporter/SynthesisFusionAddin/src/__init__.py diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 335a2416ce..aeb2f6d06a 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -1,16 +1,18 @@ -import importlib.util import logging.handlers import os +import sys import traceback -from shutil import rmtree import adsk.core -from .src.configure import setAnalytics, unload_config -from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm, root_logger -from .src.Types.OString import OString -from .src.UI import HUI, Camera, ConfigCommand, Handlers, Helper, MarkingMenu -from .src.UI.Toolbar import Toolbar +# Required for absolute imports +fileDir = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(os.path.abspath(os.path.join(fileDir))) + +from src.configure import unload_config +from src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm, root_logger +from src.UI import HUI, Camera, ConfigCommand, Helper, MarkingMenu +from src.UI.Toolbar import Toolbar def run(_): diff --git a/exporter/SynthesisFusionAddin/proto/deps.py b/exporter/SynthesisFusionAddin/proto/deps.py index ea6da5a406..02fae64b36 100644 --- a/exporter/SynthesisFusionAddin/proto/deps.py +++ b/exporter/SynthesisFusionAddin/proto/deps.py @@ -6,7 +6,7 @@ import adsk.core import adsk.fusion -from src.general_imports import INTERNAL_ID +from src import INTERNAL_ID system = platform.system() diff --git a/exporter/SynthesisFusionAddin/src/GlobalManager.py b/exporter/SynthesisFusionAddin/src/GlobalManager.py index b438a2eb23..9fb6d44b12 100644 --- a/exporter/SynthesisFusionAddin/src/GlobalManager.py +++ b/exporter/SynthesisFusionAddin/src/GlobalManager.py @@ -1,13 +1,12 @@ """ Initializes the global variables that are set in the run method to reduce hanging commands. """ -import inspect -import traceback - import adsk.core import adsk.fusion +from src import INTERNAL_ID + +# Transition: AARD-1737 from .general_imports import * -from .strings import * class GlobalManager(object): diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 31ed4cd0c4..0cf0ce59af 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -13,7 +13,7 @@ import adsk.core from adsk.fusion import CalculationAccuracy, TriangleMeshQualityOptions -from ..strings import INTERNAL_ID +from src import INTERNAL_ID # Not 100% sure what this is for - Brandon JointParentType = Enum("JointParentType", ["ROOT", "END"]) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index c6c741b0b2..efc8bf5298 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -1,19 +1,20 @@ # Contains all of the logic for mapping the Components / Occurrences import logging import traceback -import uuid -from typing import * import adsk.core import adsk.fusion from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2 - -from ...Analyzer.timer import TimeThis -from ..ExporterOptions import ExporterOptions, ExportMode -from . import PhysicalProperties -from .PDMessage import PDMessage -from .Utilities import * +from src.Analyzer.timer import TimeThis +from src.Parser.ExporterOptions import ExporterOptions, ExportMode +from src.Parser.SynthesisParser import PhysicalProperties +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import ( + fill_info, + guid_component, + guid_occurrence, +) # TODO: Impelement Material overrides diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 93d320b987..d42c20b69e 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -7,11 +7,12 @@ import adsk.fusion from proto.proto_out import joint_pb2, types_pb2 +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import guid_component, guid_occurrence +# Transition: AARD-1737 from ...general_imports import * -from ..ExporterOptions import ExporterOptions -from .PDMessage import PDMessage -from .Utilities import guid_component, guid_occurrence # ____________________________ DATA TYPES __________________ diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index 7ba62c1f5e..8921f7c9ee 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -29,12 +29,17 @@ import adsk.core import adsk.fusion -from proto.proto_out import assembly_pb2, joint_pb2, motor_pb2, signal_pb2, types_pb2 - +from proto.proto_out import assembly_pb2, joint_pb2, signal_pb2, types_pb2 +from src.Parser.ExporterOptions import ExporterOptions, JointParentType, SignalType +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import ( + construct_info, + fill_info, + guid_occurrence, +) + +# Transition: AARD-1737 from ...general_imports import * -from ..ExporterOptions import ExporterOptions, JointParentType, SignalType -from .PDMessage import PDMessage -from .Utilities import construct_info, fill_info, guid_occurrence # Need to take in a graphcontainer # Need to create a new base node for each Joint Instance diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index b3199a1f9d..77faff62d4 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -6,11 +6,12 @@ import adsk from proto.proto_out import material_pb2 +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import construct_info, fill_info +# Transition: AARD-1737 from ...general_imports import INTERNAL_ID -from .. import ExporterOptions -from .PDMessage import PDMessage -from .Utilities import * OPACITY_RAMPING_CONSTANT = 14.0 diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index a925f5b119..5dfca273ad 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -6,12 +6,19 @@ from google.protobuf.json_format import MessageToJson from proto.proto_out import assembly_pb2, types_pb2 - +from src.Parser.ExporterOptions import ExporterOptions, ExportMode +from src.Parser.SynthesisParser import ( + Components, + JointHierarchy, + Joints, + Materials, + PDMessage, +) +from src.Parser.SynthesisParser.Utilities import fill_info +from src.UI.Camera import captureThumbnail, clearIconCache + +# Transition: AARD-1737 from ...general_imports import * -from ...UI.Camera import captureThumbnail, clearIconCache -from ..ExporterOptions import ExporterOptions, ExportMode -from . import Components, JointHierarchy, Joints, Materials, PDMessage -from .Utilities import * class Parser: diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py index afd9489909..3d8967268c 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py @@ -24,7 +24,8 @@ from proto.proto_out import types_pb2 -from ...general_imports import INTERNAL_ID +# Transition: AARD-1737 +from src import INTERNAL_ID def GetPhysicalProperties( diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py index 7e8f592466..6ca28d999a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py @@ -13,7 +13,7 @@ """ import logging -from typing import * +from typing import Union import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Utilities.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Utilities.py index 7169cd4085..418ee152d8 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Utilities.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Utilities.py @@ -1,11 +1,9 @@ import math import uuid -from adsk.core import Base, Vector3D +from adsk.core import Vector3D from adsk.fusion import Component, Occurrence -# from proto.proto_out import types_pb2 - def guid_component(comp: Component) -> str: return f"{comp.entityToken}_{comp.id}" diff --git a/exporter/SynthesisFusionAddin/src/UI/Camera.py b/exporter/SynthesisFusionAddin/src/UI/Camera.py index a7076fdfd2..618971bbc7 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Camera.py +++ b/exporter/SynthesisFusionAddin/src/UI/Camera.py @@ -2,9 +2,11 @@ from adsk.core import SaveImageFileOptions +from src.Types.OString import OString +from src.UI import Helper + +# Transition: AARD-1737 from ..general_imports import * -from ..Types.OString import OString -from . import Helper def captureThumbnail(size=250): diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 6ea4e0b702..f27132616a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,17 +4,15 @@ import logging import os -import platform import traceback from enum import Enum import adsk.core import adsk.fusion -from ..Analytics.alert import showAnalyticsAlert -from ..configure import NOTIFIED, write_configuration -from ..general_imports import * -from ..Parser.ExporterOptions import ( +from src.Analytics.alert import showAnalyticsAlert +from src.configure import NOTIFIED, write_configuration +from src.Parser.ExporterOptions import ( ExporterOptions, ExportMode, Gamepiece, @@ -25,10 +23,13 @@ Wheel, WheelType, ) -from ..Parser.SynthesisParser.Parser import Parser -from ..Parser.SynthesisParser.Utilities import guid_occurrence -from . import CustomGraphics, FileDialogConfig, Helper, IconPaths, OsHelper -from .Configuration.SerialCommand import SerialCommand +from src.Parser.SynthesisParser.Parser import Parser +from src.Parser.SynthesisParser.Utilities import guid_occurrence +from src.UI import CustomGraphics, FileDialogConfig, Helper, IconPaths, OsHelper +from src.UI.Configuration.SerialCommand import SerialCommand + +# Transition: AARD-1737 +from ..general_imports import * # ====================================== CONFIG COMMAND ====================================== diff --git a/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py b/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py index 7f03642fec..d2d5e3ac6f 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 src.Types.OString import OString def generateFilePath() -> str: diff --git a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py index 17b63c8222..1f0a06fc0f 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py +++ b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py @@ -4,6 +4,7 @@ import adsk.core import adsk.fusion +# Transition: AARD-1737 from ..general_imports import * diff --git a/exporter/SynthesisFusionAddin/src/UI/Events.py b/exporter/SynthesisFusionAddin/src/UI/Events.py index 60e2af032f..5e817d5746 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Events.py +++ b/exporter/SynthesisFusionAddin/src/UI/Events.py @@ -1,6 +1,7 @@ import logging.handlers -from typing import Sequence, Tuple +from typing import Sequence +# Transition: AARD-1737 from ..general_imports import * """ # This file is Special diff --git a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py index e49cf240b7..b738eb463d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py +++ b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py @@ -3,10 +3,10 @@ import adsk.core import adsk.fusion -from ..general_imports import * +from src.Types.OString import OString -# from ..proto_out import Configuration_pb2 -from ..Types.OString import OString +# Transition: AARD-1737 +from ..general_imports import * def SaveFileDialog(defaultPath="", defaultName="", ext="MiraBuf Package (*.mira)") -> Union[str, bool]: diff --git a/exporter/SynthesisFusionAddin/src/UI/HUI.py b/exporter/SynthesisFusionAddin/src/UI/HUI.py index b17ba6ea96..0be5a0bddd 100644 --- a/exporter/SynthesisFusionAddin/src/UI/HUI.py +++ b/exporter/SynthesisFusionAddin/src/UI/HUI.py @@ -1,5 +1,7 @@ +# Transition: AARD-1737 +from src.UI import Handlers, OsHelper + from ..general_imports import * -from . import Handlers, OsHelper # no longer used diff --git a/exporter/SynthesisFusionAddin/src/UI/Handlers.py b/exporter/SynthesisFusionAddin/src/UI/Handlers.py index 710f61e8c8..5b1e6aa97d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Handlers.py +++ b/exporter/SynthesisFusionAddin/src/UI/Handlers.py @@ -1,3 +1,4 @@ +# Transition: AARD-1737 from ..general_imports import * diff --git a/exporter/SynthesisFusionAddin/src/UI/Helper.py b/exporter/SynthesisFusionAddin/src/UI/Helper.py index 8f88240247..5f796d087f 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Helper.py +++ b/exporter/SynthesisFusionAddin/src/UI/Helper.py @@ -1,8 +1,9 @@ from inspect import getmembers, isfunction -from typing import Union +from src.UI import HUI, Events + +# Transition: AARD-1737 from ..general_imports import * -from . import HUI, Events def check_solid_open() -> bool: diff --git a/exporter/SynthesisFusionAddin/src/UI/IconPaths.py b/exporter/SynthesisFusionAddin/src/UI/IconPaths.py index 261720494c..2804af221a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/IconPaths.py +++ b/exporter/SynthesisFusionAddin/src/UI/IconPaths.py @@ -1,6 +1,6 @@ import os -from . import OsHelper +from src.UI import OsHelper """ Dictionaries that store all the icon paths in ConfigCommand. All path strings are OS-independent diff --git a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py index e0b8f26f19..f5ae186d0c 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py +++ b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py @@ -1,5 +1,7 @@ +# Transition: AARD-1737 +from src import INTERNAL_ID + from ..general_imports import * -from ..strings import INTERNAL_ID class Toolbar: diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py new file mode 100644 index 0000000000..cb8ec64c64 --- /dev/null +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -0,0 +1,6 @@ +APP_NAME = "Synthesis" +APP_TITLE = "Synthesis Robot Exporter" +DESCRIPTION = "Exports files from Fusion into the Synthesis Format" +INTERNAL_ID = "synthesis" + +__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID"] diff --git a/exporter/SynthesisFusionAddin/src/configure.py b/exporter/SynthesisFusionAddin/src/configure.py index e121e7ae6e..f986963465 100644 --- a/exporter/SynthesisFusionAddin/src/configure.py +++ b/exporter/SynthesisFusionAddin/src/configure.py @@ -5,8 +5,8 @@ import uuid from configparser import ConfigParser -from .strings import INTERNAL_ID -from .Types.OString import OString +from src import INTERNAL_ID +from src.Types.OString import OString try: config = ConfigParser() diff --git a/exporter/SynthesisFusionAddin/src/logging.py b/exporter/SynthesisFusionAddin/src/logging.py index 2a0233ae5a..455f0b9157 100644 --- a/exporter/SynthesisFusionAddin/src/logging.py +++ b/exporter/SynthesisFusionAddin/src/logging.py @@ -6,8 +6,8 @@ import pathlib from datetime import datetime -from .strings import * -from .UI.OsHelper import getOSPath +from src import INTERNAL_ID +from src.UI.OsHelper import getOSPath def setupLogger(): From 324c598b06db669061dbdbecc78ecb1a51ff15a3 Mon Sep 17 00:00:00 2001 From: BrandonPacewic Date: Tue, 9 Jul 2024 09:02:34 -0700 Subject: [PATCH 02/11] Fixed all the harder imports --- exporter/SynthesisFusionAddin/Synthesis.py | 33 +++-------- .../src/Analytics/alert.py | 4 +- .../src/Analyzer/timer.py | 3 +- .../SynthesisFusionAddin/src/GlobalManager.py | 16 ++---- .../Parser/SynthesisParser/JointHierarchy.py | 4 +- .../src/Parser/SynthesisParser/Joints.py | 5 +- .../src/Parser/SynthesisParser/Materials.py | 4 +- .../src/Parser/SynthesisParser/Parser.py | 6 +- .../SynthesisParser/PhysicalProperties.py | 2 - .../SynthesisFusionAddin/src/UI/Camera.py | 7 ++- .../src/UI/ConfigCommand.py | 5 +- .../src/UI/CustomGraphics.py | 3 +- .../SynthesisFusionAddin/src/UI/Events.py | 7 ++- .../src/UI/FileDialogConfig.py | 4 +- exporter/SynthesisFusionAddin/src/UI/HUI.py | 8 ++- .../SynthesisFusionAddin/src/UI/Handlers.py | 3 +- .../SynthesisFusionAddin/src/UI/Helper.py | 11 ++-- .../src/UI/MarkingMenu.py | 3 + .../SynthesisFusionAddin/src/UI/Toolbar.py | 10 ++-- exporter/SynthesisFusionAddin/src/__init__.py | 17 +++++- .../src/general_imports.py | 55 ------------------- exporter/SynthesisFusionAddin/src/strings.py | 4 -- 22 files changed, 73 insertions(+), 141 deletions(-) delete mode 100644 exporter/SynthesisFusionAddin/src/general_imports.py delete mode 100644 exporter/SynthesisFusionAddin/src/strings.py diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index aeb2f6d06a..9389070088 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -6,14 +6,16 @@ import adsk.core # Required for absolute imports -fileDir = os.path.dirname(os.path.abspath(__file__)) -sys.path.append(os.path.abspath(os.path.join(fileDir))) +sys.path.append(os.path.dirname(os.path.abspath(__file__))) +from src import APP_NAME, DESCRIPTION, INTERNAL_ID, gm from src.configure import unload_config -from src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm, root_logger +from src.logging import setupLogger from src.UI import HUI, Camera, ConfigCommand, Helper, MarkingMenu from src.UI.Toolbar import Toolbar +root_logger: logging.Logger # TODO: Will need to be updated after GH-1010 + def run(_): """## Entry point to application from Fusion. @@ -23,8 +25,8 @@ def run(_): """ try: - # Remove all items prior to start just to make sure - unregister_all() + global root_logger + root_logger, _ = setupLogger() # TODO: Will need to be updated after GH-1010 # creates the UI elements register_ui() @@ -63,26 +65,7 @@ def stop(_): unload_config() - for file in gm.files: - try: - os.remove(file) - except OSError: - pass - - # removes path so that proto files don't get confused - - import sys - - path = os.path.abspath(os.path.dirname(__file__)) - - path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out")) - - if path in sys.path: - sys.path.remove(path) - - if path_proto_files in sys.path: - sys.path.remove(path_proto_files) - + gm.clear() except: logging.getLogger(f"{INTERNAL_ID}").error("Failed:\n{}".format(traceback.format_exc())) diff --git a/exporter/SynthesisFusionAddin/src/Analytics/alert.py b/exporter/SynthesisFusionAddin/src/Analytics/alert.py index c134f1906b..3633b03c86 100644 --- a/exporter/SynthesisFusionAddin/src/Analytics/alert.py +++ b/exporter/SynthesisFusionAddin/src/Analytics/alert.py @@ -1,5 +1,5 @@ -from ..configure import setAnalytics -from ..general_imports import gm +from src import gm +from src.configure import setAnalytics def showAnalyticsAlert(): diff --git a/exporter/SynthesisFusionAddin/src/Analyzer/timer.py b/exporter/SynthesisFusionAddin/src/Analyzer/timer.py index 41bb86135f..961af83fd7 100644 --- a/exporter/SynthesisFusionAddin/src/Analyzer/timer.py +++ b/exporter/SynthesisFusionAddin/src/Analyzer/timer.py @@ -2,10 +2,11 @@ """ import inspect +import logging import os from time import time -from ..general_imports import * +from src import DEBUG, INTERNAL_ID class Timer: diff --git a/exporter/SynthesisFusionAddin/src/GlobalManager.py b/exporter/SynthesisFusionAddin/src/GlobalManager.py index 9fb6d44b12..287052fc90 100644 --- a/exporter/SynthesisFusionAddin/src/GlobalManager.py +++ b/exporter/SynthesisFusionAddin/src/GlobalManager.py @@ -3,11 +3,6 @@ import adsk.core import adsk.fusion -from src import INTERNAL_ID - -# Transition: AARD-1737 -from .general_imports import * - class GlobalManager(object): """Global Manager instance""" @@ -15,14 +10,10 @@ class GlobalManager(object): class __GlobalManager: def __init__(self): self.app = adsk.core.Application.get() - self.logger = logging.getLogger(f"{INTERNAL_ID}.{self.__class__.__name__}") if self.app: self.ui = self.app.userInterface - self.connected = False - """ Is unity currently connected """ - self.uniqueIds = [] """ Collection of unique ID values to not overlap """ @@ -43,11 +34,14 @@ def __init__(self): - this is the list of objects being sent """ - self.files = [] - def __str__(self): return "GlobalManager" + def clear(self): + for attr, value in self.__dict__.items(): + if isinstance(value, list): + setattr(self, attr, []) + instance = None def __new__(cls): diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index d42c20b69e..55302f9aec 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -7,13 +7,11 @@ import adsk.fusion from proto.proto_out import joint_pb2, types_pb2 +from src import INTERNAL_ID, gm from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage from src.Parser.SynthesisParser.Utilities import guid_component, guid_occurrence -# Transition: AARD-1737 -from ...general_imports import * - # ____________________________ DATA TYPES __________________ diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index 8921f7c9ee..d5566f329f 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -22,6 +22,7 @@ """ +import logging import traceback import uuid from typing import Union @@ -30,6 +31,7 @@ import adsk.fusion from proto.proto_out import assembly_pb2, joint_pb2, signal_pb2, types_pb2 +from src import DEBUG, INTERNAL_ID, gm from src.Parser.ExporterOptions import ExporterOptions, JointParentType, SignalType from src.Parser.SynthesisParser.PDMessage import PDMessage from src.Parser.SynthesisParser.Utilities import ( @@ -38,9 +40,6 @@ guid_occurrence, ) -# Transition: AARD-1737 -from ...general_imports import * - # Need to take in a graphcontainer # Need to create a new base node for each Joint Instance # Need to create at least one grounded Node diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 77faff62d4..e2f8c42283 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -6,13 +6,11 @@ import adsk from proto.proto_out import material_pb2 +from src import INTERNAL_ID from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage from src.Parser.SynthesisParser.Utilities import construct_info, fill_info -# Transition: AARD-1737 -from ...general_imports import INTERNAL_ID - OPACITY_RAMPING_CONSTANT = 14.0 diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 5dfca273ad..9866c18d4d 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -1,4 +1,6 @@ import gzip +import logging +import pathlib import traceback import adsk.core @@ -6,6 +8,7 @@ from google.protobuf.json_format import MessageToJson from proto.proto_out import assembly_pb2, types_pb2 +from src import DEBUG, INTERNAL_ID, gm from src.Parser.ExporterOptions import ExporterOptions, ExportMode from src.Parser.SynthesisParser import ( Components, @@ -17,9 +20,6 @@ from src.Parser.SynthesisParser.Utilities import fill_info from src.UI.Camera import captureThumbnail, clearIconCache -# Transition: AARD-1737 -from ...general_imports import * - class Parser: def __init__(self, options: ExporterOptions): diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py index 3d8967268c..7fbe822bac 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py @@ -23,8 +23,6 @@ import adsk from proto.proto_out import types_pb2 - -# Transition: AARD-1737 from src import INTERNAL_ID diff --git a/exporter/SynthesisFusionAddin/src/UI/Camera.py b/exporter/SynthesisFusionAddin/src/UI/Camera.py index 618971bbc7..5142762e57 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Camera.py +++ b/exporter/SynthesisFusionAddin/src/UI/Camera.py @@ -1,13 +1,14 @@ +import logging import os +import traceback +import adsk.core from adsk.core import SaveImageFileOptions +from src import A_EP from src.Types.OString import OString from src.UI import Helper -# Transition: AARD-1737 -from ..general_imports import * - def captureThumbnail(size=250): """ diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index f27132616a..01917aec6a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -4,12 +4,14 @@ import logging import os +import pathlib import traceback from enum import Enum import adsk.core import adsk.fusion +from src import A_EP, INTERNAL_ID, gm from src.Analytics.alert import showAnalyticsAlert from src.configure import NOTIFIED, write_configuration from src.Parser.ExporterOptions import ( @@ -28,9 +30,6 @@ from src.UI import CustomGraphics, FileDialogConfig, Helper, IconPaths, OsHelper from src.UI.Configuration.SerialCommand import SerialCommand -# Transition: AARD-1737 -from ..general_imports import * - # ====================================== CONFIG COMMAND ====================================== """ diff --git a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py index 1f0a06fc0f..97935b6827 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py +++ b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py @@ -4,8 +4,7 @@ import adsk.core import adsk.fusion -# Transition: AARD-1737 -from ..general_imports import * +from src import gm def createTextGraphics(wheel: adsk.fusion.Occurrence, _wheels) -> None: diff --git a/exporter/SynthesisFusionAddin/src/UI/Events.py b/exporter/SynthesisFusionAddin/src/UI/Events.py index 5e817d5746..4189d6b174 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Events.py +++ b/exporter/SynthesisFusionAddin/src/UI/Events.py @@ -1,8 +1,11 @@ +import json import logging.handlers from typing import Sequence -# Transition: AARD-1737 -from ..general_imports import * +import adsk.core + +from src import INTERNAL_ID, gm +from src.UI import Helper """ # This file is Special It links all function names to command requests that palletes can make automatically diff --git a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py index b738eb463d..a68809d676 100644 --- a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py +++ b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py @@ -3,11 +3,9 @@ import adsk.core import adsk.fusion +from src import gm from src.Types.OString import OString -# Transition: AARD-1737 -from ..general_imports import * - def SaveFileDialog(defaultPath="", defaultName="", ext="MiraBuf Package (*.mira)") -> Union[str, bool]: """Function to generate the Save File Dialog for the Hellion Data files diff --git a/exporter/SynthesisFusionAddin/src/UI/HUI.py b/exporter/SynthesisFusionAddin/src/UI/HUI.py index 0be5a0bddd..f044fa7d9b 100644 --- a/exporter/SynthesisFusionAddin/src/UI/HUI.py +++ b/exporter/SynthesisFusionAddin/src/UI/HUI.py @@ -1,7 +1,9 @@ -# Transition: AARD-1737 -from src.UI import Handlers, OsHelper +import logging + +import adsk.core -from ..general_imports import * +from src import INTERNAL_ID, gm +from src.UI import Handlers, OsHelper # no longer used diff --git a/exporter/SynthesisFusionAddin/src/UI/Handlers.py b/exporter/SynthesisFusionAddin/src/UI/Handlers.py index 5b1e6aa97d..4529b861db 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Handlers.py +++ b/exporter/SynthesisFusionAddin/src/UI/Handlers.py @@ -1,5 +1,4 @@ -# Transition: AARD-1737 -from ..general_imports import * +import adsk.core class HButtonCommandCreatedEvent(adsk.core.CommandCreatedEventHandler): diff --git a/exporter/SynthesisFusionAddin/src/UI/Helper.py b/exporter/SynthesisFusionAddin/src/UI/Helper.py index 5f796d087f..ad7346fd46 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Helper.py +++ b/exporter/SynthesisFusionAddin/src/UI/Helper.py @@ -1,9 +1,10 @@ +import traceback from inspect import getmembers, isfunction -from src.UI import HUI, Events +import adsk.core -# Transition: AARD-1737 -from ..general_imports import * +from src import APP_NAME, APP_TITLE, INTERNAL_ID, gm +from src.UI import HUI, Events def check_solid_open() -> bool: @@ -14,7 +15,7 @@ def check_solid_open() -> bool: return True -def getDocName() -> str or None: +def getDocName() -> str | None: """### Gets the active Document Name - If it can't find one then it will return None """ @@ -38,7 +39,7 @@ def checkAttribute() -> bool: return False -def addUnityAttribute() -> bool or None: +def addUnityAttribute() -> bool | None: """#### Adds an attribute to the Fusion File - Initially intended to be used to add a marker for in use untiy files - No longer necessary diff --git a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py index 5c68d2c79a..9b894127d9 100644 --- a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py +++ b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py @@ -4,6 +4,8 @@ import adsk.core import adsk.fusion +from src import INTERNAL_ID + # Ripped all the boiler plate from the example code: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-c90ce6a2-c282-11e6-a365-3417ebc87622 # global mapping list of event handlers to keep them referenced for the duration of the command @@ -221,6 +223,7 @@ def stopMarkingMenu(ui: adsk.core.UserInterface): else: ui.messageBox(str(obj) + " is not a valid object") + cmdDefs.clear() handlers.clear() except: ui.messageBox("Failed:\n{}".format(traceback.format_exc())) diff --git a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py index f5ae186d0c..388abbc4b9 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py +++ b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py @@ -1,7 +1,7 @@ -# Transition: AARD-1737 -from src import INTERNAL_ID +import logging +import traceback -from ..general_imports import * +from src import INTERNAL_ID, gm class Toolbar: @@ -40,7 +40,7 @@ def __init__(self, name: str): error = traceback.format_exc() self.logger.error(f"Failed at creating toolbar with {self.uid} due to {error}") - def getPanel(self, name: str, visibility: bool = True) -> str or None: + def getPanel(self, name: str, visibility: bool = True) -> str | None: """# Gets a control for a panel to the tabbed toolbar - optional param for visibility """ @@ -61,7 +61,7 @@ def getPanel(self, name: str, visibility: bool = True) -> str or None: return None @staticmethod - def getNewPanel(name: str, tab_id: str, toolbar_id: str, visibility: bool = True) -> str or None: + def getNewPanel(name: str, tab_id: str, toolbar_id: str, visibility: bool = True) -> str | None: """# Gets a control for a panel to the tabbed toolbar visibility""" logger = logging.getLogger(f"{INTERNAL_ID}.Toolbar.getNewPanel") diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py index cb8ec64c64..f041f71631 100644 --- a/exporter/SynthesisFusionAddin/src/__init__.py +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -1,6 +1,21 @@ +import os +import sys + +from src.GlobalManager import GlobalManager + APP_NAME = "Synthesis" APP_TITLE = "Synthesis Robot Exporter" DESCRIPTION = "Exports files from Fusion into the Synthesis Format" INTERNAL_ID = "synthesis" -__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID"] +A_EP = None # TODO: Will be removed by GH-1010 +DEBUG = True # TODO: Will be removed by GH-1010 + +gm = GlobalManager() + +__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID", "gm"] + +# Transition: AARD-1737 +# This method of running the resolve dependencies module will be revisited in AARD-1734 +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))) +from proto import deps diff --git a/exporter/SynthesisFusionAddin/src/general_imports.py b/exporter/SynthesisFusionAddin/src/general_imports.py deleted file mode 100644 index 042e4618ea..0000000000 --- a/exporter/SynthesisFusionAddin/src/general_imports.py +++ /dev/null @@ -1,55 +0,0 @@ -import json -import logging.handlers -import os -import pathlib -import sys -import traceback -import uuid -from datetime import datetime -from time import time -from types import FunctionType - -import adsk.core -import adsk.fusion - -# hard coded to bypass errors for now -PROTOBUF = True -DEBUG = True - -try: - from .GlobalManager import * - from .logging import setupLogger - from .strings import * - - (root_logger, log_handler) = setupLogger() -except ImportError as e: - # nothing to really do here - print(e) - -try: - path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) - - path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out")) - - if not path in sys.path: - sys.path.insert(1, path) - - if not path_proto_files in sys.path: - sys.path.insert(2, path_proto_files) - - from proto import deps - -except: - logging.getLogger(f"{INTERNAL_ID}.import_manager").error("Failed\n{}".format(traceback.format_exc())) - -try: - # simple analytics endpoint - # A_EP = AnalyticsEndpoint("UA-188467590-1", 1) - A_EP = None - - # Setup the global state - gm: GlobalManager = GlobalManager() - my_addin_path = os.path.dirname(os.path.realpath(__file__)) -except: - # should also log this - logging.getLogger(f"{INTERNAL_ID}.import_manager").error("Failed\n{}".format(traceback.format_exc())) diff --git a/exporter/SynthesisFusionAddin/src/strings.py b/exporter/SynthesisFusionAddin/src/strings.py deleted file mode 100644 index 6e3aa109e2..0000000000 --- a/exporter/SynthesisFusionAddin/src/strings.py +++ /dev/null @@ -1,4 +0,0 @@ -APP_NAME = "Synthesis" -APP_TITLE = "Synthesis Robot Exporter" -DESCRIPTION = "Exports files from Fusion into the Synthesis Format" -INTERNAL_ID = "synthesis" From 2733f083f8af4adc428d6f3c2d1f88c08b8ed0bb Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:18:55 -0700 Subject: [PATCH 03/11] Move logging --- exporter/SynthesisFusionAddin/src/logging.py | 105 ------------------- 1 file changed, 105 deletions(-) delete mode 100644 exporter/SynthesisFusionAddin/src/logging.py diff --git a/exporter/SynthesisFusionAddin/src/logging.py b/exporter/SynthesisFusionAddin/src/logging.py deleted file mode 100644 index 2bf9ce191b..0000000000 --- a/exporter/SynthesisFusionAddin/src/logging.py +++ /dev/null @@ -1,105 +0,0 @@ -import functools -import inspect -import logging.handlers -import os -import pathlib -import sys -import time -import traceback -from datetime import date, datetime -from typing import cast - -import adsk.core - -from .strings import INTERNAL_ID -from .UI.OsHelper import getOSPath - -MAX_LOG_FILES_TO_KEEP = 10 -TIMING_LEVEL = 25 - - -class SynthesisLogger(logging.Logger): - def timing(self, msg: str, *args: any, **kwargs: any) -> None: - return self.log(TIMING_LEVEL, msg, *args, **kwargs) - - def cleanupHandlers(self) -> None: - for handler in self.handlers: - handler.close() - - -def setupLogger() -> None: - now = datetime.now().strftime("%H-%M-%S") - today = date.today() - logFileFolder = getOSPath(f"{pathlib.Path(__file__).parent.parent}", "logs") - logFiles = [os.path.join(logFileFolder, file) for file in os.listdir(logFileFolder) if file.endswith(".log")] - logFiles.sort() - if len(logFiles) >= MAX_LOG_FILES_TO_KEEP: - for file in logFiles[: len(logFiles) - MAX_LOG_FILES_TO_KEEP]: - os.remove(file) - - logFileName = f"{logFileFolder}{getOSPath(f'{INTERNAL_ID}-{today}-{now}.log')}" - logHandler = logging.handlers.WatchedFileHandler(logFileName, mode="w") - logHandler.setFormatter(logging.Formatter("%(name)s - %(levelname)s - %(message)s")) - - logging.setLoggerClass(SynthesisLogger) - logging.addLevelName(TIMING_LEVEL, "TIMING") - logger = getLogger(INTERNAL_ID) - logger.setLevel(10) # Debug - logger.addHandler(logHandler) - - -def getLogger(name: str | None = None) -> SynthesisLogger: - if not name: - # Inspect the caller stack to automatically get the module from which the function is being called from. - name = f"{INTERNAL_ID}.{'.'.join(inspect.getmodule(inspect.stack()[1][0]).__name__.split('.')[1:])}" - - return cast(SynthesisLogger, logging.getLogger(name)) - - -# Log function failure decorator. -def logFailure(func: callable = None, /, *, messageBox: bool = False) -> callable: - def wrap(func: callable) -> callable: - @functools.wraps(func) - def wrapper(*args: any, **kwargs: any) -> any: - try: - return func(*args, **kwargs) - except BaseException: - excType, excValue, excTrace = sys.exc_info() - tb = traceback.TracebackException(excType, excValue, excTrace) - formattedTb = "".join(list(tb.format())[2:]) # Remove the wrapper func from the traceback. - clsName = "" - if args and hasattr(args[0], "__class__"): - clsName = args[0].__class__.__name__ + "." - - getLogger(f"{INTERNAL_ID}.{clsName}{func.__name__}").error(f"Failed:\n{formattedTb}") - if messageBox: - ui = adsk.core.Application.get().userInterface - ui.messageBox(f"Internal Failure: {formattedTb}", "Synthesis: Error") - - return wrapper - - if func is None: - # Called with parens. - return wrap - - # Called without parens. - return wrap(func) - - -# Time function decorator. -def timed(func: callable) -> callable: - def wrapper(*args: any, **kwargs: any) -> any: - startTime = time.perf_counter() - result = func(*args, **kwargs) - endTime = time.perf_counter() - runTime = f"{endTime - startTime:5f}s" - - clsName = "" - if args and hasattr(args[0], "__class__"): - clsName = args[0].__class__.__name__ + "." - - logger = getLogger(f"{INTERNAL_ID}.{clsName}{func.__name__}") - logger.timing(f"Runtime of '{func.__name__}' took '{runTime}'.") - return result - - return wrapper From 358064946283edafc6a96d984122c6db84da99fa Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:01:11 -0700 Subject: [PATCH 04/11] Revert back to previous state + remove `general_imports.py` --- exporter/SynthesisFusionAddin/Synthesis.py | 6 +-- exporter/SynthesisFusionAddin/src/APS/APS.py | 6 +-- .../SynthesisFusionAddin/src/Dependencies.py | 2 +- .../SynthesisFusionAddin/src/GlobalManager.py | 5 --- exporter/SynthesisFusionAddin/src/Logging.py | 4 +- .../src/Parser/ExporterOptions.py | 6 +-- .../src/Parser/SynthesisParser/Components.py | 12 +++--- .../Parser/SynthesisParser/JointHierarchy.py | 10 ++--- .../src/Parser/SynthesisParser/Joints.py | 11 +++-- .../src/Parser/SynthesisParser/Materials.py | 15 ++----- .../src/Parser/SynthesisParser/Parser.py | 16 +++---- .../SynthesisParser/PhysicalProperties.py | 6 +-- .../src/Parser/SynthesisParser/RigidGroup.py | 2 +- .../SynthesisFusionAddin/src/UI/Camera.py | 11 +++-- .../src/UI/ConfigCommand.py | 28 ++++++------- .../src/UI/Configuration/SerialCommand.py | 2 +- .../src/UI/CreateCommandInputsHelper.py | 2 +- .../src/UI/CustomGraphics.py | 4 +- .../SynthesisFusionAddin/src/UI/Events.py | 7 +++- .../src/UI/FileDialogConfig.py | 6 +-- .../src/UI/GamepieceConfigTab.py | 10 ++--- .../src/UI/GeneralConfigTab.py | 14 +++---- exporter/SynthesisFusionAddin/src/UI/HUI.py | 8 ++-- .../SynthesisFusionAddin/src/UI/Helper.py | 6 ++- .../src/UI/JointConfigTab.py | 9 ++-- .../src/UI/MarkingMenu.py | 5 +-- .../src/UI/ShowAPSAuthCommand.py | 2 +- .../src/UI/ShowWebsiteCommand.py | 3 +- .../SynthesisFusionAddin/src/UI/Toolbar.py | 5 +-- exporter/SynthesisFusionAddin/src/__init__.py | 7 ++-- .../src/general_imports.py | 42 ------------------- exporter/SynthesisFusionAddin/src/strings.py | 4 -- 32 files changed, 105 insertions(+), 171 deletions(-) delete mode 100644 exporter/SynthesisFusionAddin/src/general_imports.py delete mode 100644 exporter/SynthesisFusionAddin/src/strings.py diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 20f3fb35d6..7f8ffd34e2 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -15,8 +15,8 @@ setupLogger() try: - from .src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm - from .src.UI import ( + from src import APP_NAME, DESCRIPTION, INTERNAL_ID, gm + from src.UI import ( HUI, Camera, ConfigCommand, @@ -24,7 +24,7 @@ ShowAPSAuthCommand, ShowWebsiteCommand, ) - from .src.UI.Toolbar import Toolbar + from src.UI.Toolbar import Toolbar except (ImportError, ModuleNotFoundError) as error: getLogger().warn(f"Running resolve dependencies with error of:\n{error}") result = resolveDependencies() diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index a65728ec23..9f73eb9e0b 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -10,13 +10,13 @@ import requests -from ..general_imports import INTERNAL_ID, gm, my_addin_path -from ..Logging import getLogger +from src import gm, ADDIN_PATH +from src.Logging import getLogger logger = getLogger() CLIENT_ID = "GCxaewcLjsYlK8ud7Ka9AKf9dPwMR3e4GlybyfhAK2zvl3tU" -auth_path = os.path.abspath(os.path.join(my_addin_path, "..", ".aps_auth")) +auth_path = os.path.abspath(os.path.join(ADDIN_PATH, "..", ".aps_auth")) APS_AUTH = None APS_USER_INFO = None diff --git a/exporter/SynthesisFusionAddin/src/Dependencies.py b/exporter/SynthesisFusionAddin/src/Dependencies.py index b9ad31f7be..a61119c1d6 100644 --- a/exporter/SynthesisFusionAddin/src/Dependencies.py +++ b/exporter/SynthesisFusionAddin/src/Dependencies.py @@ -9,7 +9,7 @@ import adsk.core import adsk.fusion -from .Logging import getLogger, logFailure +from src.Logging import getLogger, logFailure logger = getLogger() system = platform.system() diff --git a/exporter/SynthesisFusionAddin/src/GlobalManager.py b/exporter/SynthesisFusionAddin/src/GlobalManager.py index a31688d119..fb95bda33b 100644 --- a/exporter/SynthesisFusionAddin/src/GlobalManager.py +++ b/exporter/SynthesisFusionAddin/src/GlobalManager.py @@ -1,13 +1,8 @@ """ Initializes the global variables that are set in the run method to reduce hanging commands. """ -import logging - import adsk.core import adsk.fusion -from .general_imports import * -from .strings import * - class GlobalManager(object): """Global Manager instance""" diff --git a/exporter/SynthesisFusionAddin/src/Logging.py b/exporter/SynthesisFusionAddin/src/Logging.py index 2bf9ce191b..dcfa863c67 100644 --- a/exporter/SynthesisFusionAddin/src/Logging.py +++ b/exporter/SynthesisFusionAddin/src/Logging.py @@ -11,8 +11,8 @@ import adsk.core -from .strings import INTERNAL_ID -from .UI.OsHelper import getOSPath +from src import INTERNAL_ID +from src.UI.OsHelper import getOSPath MAX_LOG_FILES_TO_KEEP = 10 TIMING_LEVEL = 25 diff --git a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py index 9151a7115d..69e9bbef5d 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py +++ b/exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py @@ -11,9 +11,9 @@ import adsk.core from adsk.fusion import CalculationAccuracy, TriangleMeshQualityOptions -from ..Logging import logFailure, timed -from ..strings import INTERNAL_ID -from ..Types import ( +from src import INTERNAL_ID +from src.Logging import logFailure, timed +from src.Types import ( KG, ExportLocation, ExportMode, diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index aa77cac500..0a034ca33e 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -9,12 +9,12 @@ from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2 -from ...Logging import logFailure, timed -from ...Types import ExportMode -from ..ExporterOptions import ExporterOptions -from . import PhysicalProperties -from .PDMessage import PDMessage -from .Utilities import * +from src.Logging import logFailure +from src.Types import ExportMode +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser import PhysicalProperties +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import * # TODO: Impelement Material overrides diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 53dd3d10fa..313b6d9fa2 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -8,11 +8,11 @@ from proto.proto_out import joint_pb2, types_pb2 -from ...general_imports import * -from ...Logging import getLogger, logFailure -from ..ExporterOptions import ExporterOptions -from .PDMessage import PDMessage -from .Utilities import guid_component, guid_occurrence +from src import gm +from src.Logging import getLogger, logFailure +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import guid_component, guid_occurrence logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index c79a0240d0..75066533a1 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -31,12 +31,11 @@ from proto.proto_out import assembly_pb2, joint_pb2, motor_pb2, signal_pb2, types_pb2 -from ...general_imports import * -from ...Logging import getLogger -from ...Types import JointParentType, SignalType -from ..ExporterOptions import ExporterOptions -from .PDMessage import PDMessage -from .Utilities import construct_info, fill_info, guid_occurrence +from src.Logging import getLogger +from src.Types import JointParentType, SignalType +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import construct_info, fill_info, guid_occurrence logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 97d8d47f57..5cf7e17356 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -1,18 +1,11 @@ -# Should contain Physical and Apperance materials ? -import json -import logging -import math -import traceback - import adsk from proto.proto_out import material_pb2 -from ...general_imports import * -from ...Logging import logFailure, timed -from ..ExporterOptions import ExporterOptions -from .PDMessage import PDMessage -from .Utilities import * +from src.Logging import logFailure +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.PDMessage import PDMessage +from src.Parser.SynthesisParser.Utilities import * OPACITY_RAMPING_CONSTANT = 14.0 diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index fe034d20b4..533c0a9381 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -7,14 +7,14 @@ from proto.proto_out import assembly_pb2, types_pb2 -from ...APS.APS import getAuth, upload_mirabuf -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 -from . import Components, JointHierarchy, Joints, Materials, PDMessage -from .Utilities import * +from src import gm +from src.APS.APS import getAuth, upload_mirabuf +from src.Logging import getLogger, logFailure, timed +from src.Types import ExportLocation, ExportMode +from src.UI.Camera import captureThumbnail, clearIconCache +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser import Components, JointHierarchy, Joints, Materials, PDMessage +from src.Parser.SynthesisParser.Utilities import * logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py index db488c115a..923d9c836a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py @@ -15,17 +15,13 @@ - Z """ - -import logging -import traceback from typing import Union import adsk from proto.proto_out import types_pb2 -from ...general_imports import INTERNAL_ID -from ...Logging import logFailure +from src.Logging import logFailure @logFailure diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py index 362a2a6e72..4cef6fea38 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py @@ -19,7 +19,7 @@ from proto.proto_out import assembly_pb2 -from ...Logging import logFailure +from src.Logging import logFailure @logFailure diff --git a/exporter/SynthesisFusionAddin/src/UI/Camera.py b/exporter/SynthesisFusionAddin/src/UI/Camera.py index 538968034d..85fa188ff8 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Camera.py +++ b/exporter/SynthesisFusionAddin/src/UI/Camera.py @@ -1,11 +1,10 @@ import os -from adsk.core import SaveImageFileOptions +import adsk.core -from ..general_imports import * -from ..Logging import logFailure, timed -from ..Types import OString -from . import Helper +from src.Logging import logFailure +from src.Types import OString +from src.UI import Helper @logFailure @@ -25,7 +24,7 @@ def captureThumbnail(size=250): path = OString.ThumbnailPath(name) - saveOptions = SaveImageFileOptions.create(str(path.getPath())) + saveOptions = adsk.core.SaveImageFileOptions.create(str(path.getPath())) saveOptions.height = size saveOptions.width = size saveOptions.isAntiAliased = True diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index d7fd6ec6bb..3a1f2e6c76 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -9,22 +9,18 @@ import adsk.core import adsk.fusion -from ..APS.APS import getAuth, getUserInfo, refreshAuthToken -from ..general_imports import * -from ..Logging import getLogger, logFailure -from ..Parser.ExporterOptions import ExporterOptions -from ..Parser.SynthesisParser.Parser import Parser -from ..Parser.SynthesisParser.Utilities import guid_occurrence -from ..Types import ExportLocation, ExportMode -from . import CustomGraphics, FileDialogConfig, Helper, IconPaths -from .Configuration.SerialCommand import SerialCommand -from .GamepieceConfigTab import GamepieceConfigTab -from .GeneralConfigTab import GeneralConfigTab - -# Transition: AARD-1685 -# In the future all components should be handled in this way. -# This import broke everything when attempting to use absolute imports??? Investigate? -from .JointConfigTab import JointConfigTab +from src import gm +from src.APS.APS import getAuth, getUserInfo, refreshAuthToken +from src.Logging import getLogger, logFailure +from src.Parser.ExporterOptions import ExporterOptions +from src.Parser.SynthesisParser.Parser import Parser +from src.Parser.SynthesisParser.Utilities import guid_occurrence +from src.Types import ExportLocation, ExportMode +from src.UI import CustomGraphics, FileDialogConfig, Helper, IconPaths +from src.UI.Configuration.SerialCommand import SerialCommand +from src.UI.GamepieceConfigTab import GamepieceConfigTab +from src.UI.GeneralConfigTab import GeneralConfigTab +from src.UI.JointConfigTab import JointConfigTab # ====================================== CONFIG COMMAND ====================================== diff --git a/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py b/exporter/SynthesisFusionAddin/src/UI/Configuration/SerialCommand.py index 16084148c5..663afe9337 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 import OString +from src.Types import OString def generateFilePath() -> str: diff --git a/exporter/SynthesisFusionAddin/src/UI/CreateCommandInputsHelper.py b/exporter/SynthesisFusionAddin/src/UI/CreateCommandInputsHelper.py index 536b93b57d..1f78b469bd 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CreateCommandInputsHelper.py +++ b/exporter/SynthesisFusionAddin/src/UI/CreateCommandInputsHelper.py @@ -1,6 +1,6 @@ import adsk.core -from ..Logging import logFailure +from src.Logging import logFailure @logFailure diff --git a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py index 52a49fa5d4..d92c26f823 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py +++ b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py @@ -4,8 +4,8 @@ import adsk.core import adsk.fusion -from ..general_imports import * -from ..Logging import logFailure +from src import gm +from src.Logging import logFailure @logFailure diff --git a/exporter/SynthesisFusionAddin/src/UI/Events.py b/exporter/SynthesisFusionAddin/src/UI/Events.py index 281ebf3f0e..0c4cf37798 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Events.py +++ b/exporter/SynthesisFusionAddin/src/UI/Events.py @@ -1,7 +1,10 @@ +import json from typing import Sequence, Tuple -from ..general_imports import * -from ..Logging import getLogger +import adsk.core + +from src import gm +from src.Logging import getLogger """ # This file is Special It links all function names to command requests that palletes can make automatically diff --git a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py index 6f6f764cd9..8b8b3a2f4c 100644 --- a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py +++ b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py @@ -3,10 +3,8 @@ import adsk.core import adsk.fusion -from ..general_imports import * - -# from ..proto_out import Configuration_pb2 -from ..Types import OString +from src import gm +from src.Types import OString def saveFileDialog(defaultPath: str | None = None, defaultName: str | None = None) -> str | bool: diff --git a/exporter/SynthesisFusionAddin/src/UI/GamepieceConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/GamepieceConfigTab.py index f0d2f7d4bd..8eb4f80044 100644 --- a/exporter/SynthesisFusionAddin/src/UI/GamepieceConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/GamepieceConfigTab.py @@ -1,11 +1,11 @@ import adsk.core import adsk.fusion -from ..Logging import logFailure -from ..Parser.ExporterOptions import ExporterOptions -from ..Types import Gamepiece, PreferredUnits, toKg, toLbs -from . import IconPaths -from .CreateCommandInputsHelper import ( +from src.Logging import logFailure +from src.Parser.ExporterOptions import ExporterOptions +from src.Types import Gamepiece, PreferredUnits, toKg, toLbs +from src.UI import IconPaths +from src.UI.CreateCommandInputsHelper import ( createBooleanInput, createTableInput, createTextBoxInput, diff --git a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py index 116b8ca7d7..40a602a406 100644 --- a/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/GeneralConfigTab.py @@ -1,18 +1,18 @@ import adsk.core import adsk.fusion -from ..Logging import logFailure -from ..Parser.ExporterOptions import ( +from src.Logging import logFailure +from src.Parser.ExporterOptions import ( ExporterOptions, ExportLocation, ExportMode, PreferredUnits, ) -from ..Types import KG, toKg, toLbs -from . import IconPaths -from .CreateCommandInputsHelper import createBooleanInput, createTableInput -from .GamepieceConfigTab import GamepieceConfigTab -from .JointConfigTab import JointConfigTab +from src.Types import KG, toKg, toLbs +from src.UI import IconPaths +from src.UI.CreateCommandInputsHelper import createBooleanInput, createTableInput +from src.UI.GamepieceConfigTab import GamepieceConfigTab +from src.UI.JointConfigTab import JointConfigTab class GeneralConfigTab: diff --git a/exporter/SynthesisFusionAddin/src/UI/HUI.py b/exporter/SynthesisFusionAddin/src/UI/HUI.py index 3b52de9999..d1a968d642 100644 --- a/exporter/SynthesisFusionAddin/src/UI/HUI.py +++ b/exporter/SynthesisFusionAddin/src/UI/HUI.py @@ -1,6 +1,8 @@ -from ..general_imports import * -from ..Logging import logFailure -from . import Handlers, OsHelper +import adsk.core + +from src import INTERNAL_ID, gm +from src.Logging import logFailure +from src.UI import Handlers, OsHelper # no longer used diff --git a/exporter/SynthesisFusionAddin/src/UI/Helper.py b/exporter/SynthesisFusionAddin/src/UI/Helper.py index 7c8e3a5930..2f9eeaa12c 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Helper.py +++ b/exporter/SynthesisFusionAddin/src/UI/Helper.py @@ -1,8 +1,10 @@ from inspect import getmembers, isfunction from typing import Union -from ..general_imports import * -from . import HUI, Events +import adsk.core + +from src import gm, APP_NAME, APP_TITLE, INTERNAL_ID +from src.UI import HUI, Events def getDocName() -> str or None: diff --git a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py index 7e34757783..000080eb79 100644 --- a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py @@ -4,11 +4,10 @@ import adsk.core import adsk.fusion -from ..general_imports import INTERNAL_ID -from ..Logging import logFailure -from ..Types import Joint, JointParentType, SignalType, Wheel, WheelType -from . import IconPaths -from .CreateCommandInputsHelper import ( +from src.Logging import logFailure +from src.Types import Joint, JointParentType, SignalType, Wheel, WheelType +from src.UI import IconPaths +from src.UI.CreateCommandInputsHelper import ( createBooleanInput, createTableInput, createTextBoxInput, diff --git a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py index 30c9f078e6..d6509b16d4 100644 --- a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py +++ b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py @@ -1,10 +1,7 @@ -import logging.handlers -import traceback - import adsk.core import adsk.fusion -from ..Logging import logFailure +from src.Logging import logFailure # Ripped all the boiler plate from the example code: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-c90ce6a2-c282-11e6-a365-3417ebc87622 diff --git a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py index bd45cfc062..13e3cec65d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py @@ -8,8 +8,8 @@ import adsk.core +from src import gm from src.APS.APS import CLIENT_ID, auth_path, convertAuthToken, getCodeChallenge -from src.general_imports import APP_NAME, DESCRIPTION, INTERNAL_ID, gm, my_addin_path from src.Logging import getLogger logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/UI/ShowWebsiteCommand.py b/exporter/SynthesisFusionAddin/src/UI/ShowWebsiteCommand.py index d7e1539e5e..cc99cffb07 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ShowWebsiteCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ShowWebsiteCommand.py @@ -1,8 +1,9 @@ +import traceback import webbrowser import adsk.core -from ..general_imports import * +from src import gm class ShowWebsiteCommandExecuteHandler(adsk.core.CommandEventHandler): diff --git a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py index bfcc34189a..4a0c581f3d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py +++ b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py @@ -1,6 +1,5 @@ -from ..general_imports import * -from ..Logging import logFailure -from ..strings import INTERNAL_ID +from src.Logging import logFailure +from src import INTERNAL_ID, gm class Toolbar: diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py index f041f71631..c7d951b784 100644 --- a/exporter/SynthesisFusionAddin/src/__init__.py +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -6,16 +6,17 @@ APP_NAME = "Synthesis" APP_TITLE = "Synthesis Robot Exporter" DESCRIPTION = "Exports files from Fusion into the Synthesis Format" -INTERNAL_ID = "synthesis" +INTERNAL_ID = "Synthesis" +ADDIN_PATH = os.path.dirname(os.path.realpath(__file__)) A_EP = None # TODO: Will be removed by GH-1010 DEBUG = True # TODO: Will be removed by GH-1010 gm = GlobalManager() -__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID", "gm"] +__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID", "ADDIN_PATH", "gm"] # Transition: AARD-1737 # This method of running the resolve dependencies module will be revisited in AARD-1734 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))) -from proto import deps +# from proto import deps diff --git a/exporter/SynthesisFusionAddin/src/general_imports.py b/exporter/SynthesisFusionAddin/src/general_imports.py deleted file mode 100644 index aabdae5cac..0000000000 --- a/exporter/SynthesisFusionAddin/src/general_imports.py +++ /dev/null @@ -1,42 +0,0 @@ -import json -import os -import pathlib -import sys -import traceback -import uuid -from datetime import datetime -from time import time -from types import FunctionType - -import adsk.core -import adsk.fusion - -from .GlobalManager import * -from .Logging import getLogger -from .strings import * - -logger = getLogger() - -# hard coded to bypass errors for now -PROTOBUF = True -DEBUG = True - -try: - path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) - - path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out")) - - if not path in sys.path: - sys.path.insert(1, path) - - if not path_proto_files in sys.path: - sys.path.insert(2, path_proto_files) -except: - logger.error("Failed:\n{}".format(traceback.format_exc())) - -try: - # Setup the global state - gm: GlobalManager = GlobalManager() - my_addin_path = os.path.dirname(os.path.realpath(__file__)) -except: - logger.error("Failed:\n{}".format(traceback.format_exc())) diff --git a/exporter/SynthesisFusionAddin/src/strings.py b/exporter/SynthesisFusionAddin/src/strings.py deleted file mode 100644 index b5d79c055c..0000000000 --- a/exporter/SynthesisFusionAddin/src/strings.py +++ /dev/null @@ -1,4 +0,0 @@ -APP_NAME = "Synthesis" -APP_TITLE = "Synthesis Robot Exporter" -DESCRIPTION = "Exports files from Fusion into the Synthesis Format" -INTERNAL_ID = "Synthesis" From ca0b17576fa411c45f94085bc7738b3e62fe0306 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:01:32 -0700 Subject: [PATCH 05/11] Sort imports --- exporter/SynthesisFusionAddin/src/APS/APS.py | 2 +- .../src/Parser/SynthesisParser/Components.py | 3 +-- .../src/Parser/SynthesisParser/JointHierarchy.py | 1 - .../src/Parser/SynthesisParser/Joints.py | 9 ++++++--- .../src/Parser/SynthesisParser/Materials.py | 1 - .../src/Parser/SynthesisParser/Parser.py | 13 +++++++++---- .../Parser/SynthesisParser/PhysicalProperties.py | 2 +- .../src/Parser/SynthesisParser/RigidGroup.py | 1 - exporter/SynthesisFusionAddin/src/UI/Helper.py | 2 +- exporter/SynthesisFusionAddin/src/UI/Toolbar.py | 2 +- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/exporter/SynthesisFusionAddin/src/APS/APS.py b/exporter/SynthesisFusionAddin/src/APS/APS.py index 9f73eb9e0b..a6f4f34a5b 100644 --- a/exporter/SynthesisFusionAddin/src/APS/APS.py +++ b/exporter/SynthesisFusionAddin/src/APS/APS.py @@ -10,7 +10,7 @@ import requests -from src import gm, ADDIN_PATH +from src import ADDIN_PATH, gm from src.Logging import getLogger logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index 0a034ca33e..0ac0078d1c 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -8,13 +8,12 @@ import adsk.fusion from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2 - from src.Logging import logFailure -from src.Types import ExportMode from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser import PhysicalProperties from src.Parser.SynthesisParser.PDMessage import PDMessage from src.Parser.SynthesisParser.Utilities import * +from src.Types import ExportMode # TODO: Impelement Material overrides diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 313b6d9fa2..5c106d0188 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -7,7 +7,6 @@ import adsk.fusion from proto.proto_out import joint_pb2, types_pb2 - from src import gm from src.Logging import getLogger, logFailure from src.Parser.ExporterOptions import ExporterOptions diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index 75066533a1..c5458cbae3 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -30,12 +30,15 @@ import adsk.fusion from proto.proto_out import assembly_pb2, joint_pb2, motor_pb2, signal_pb2, types_pb2 - from src.Logging import getLogger -from src.Types import JointParentType, SignalType from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage -from src.Parser.SynthesisParser.Utilities import construct_info, fill_info, guid_occurrence +from src.Parser.SynthesisParser.Utilities import ( + construct_info, + fill_info, + guid_occurrence, +) +from src.Types import JointParentType, SignalType logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index 5cf7e17356..ca7fb5480c 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -1,7 +1,6 @@ import adsk from proto.proto_out import material_pb2 - from src.Logging import logFailure from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 533c0a9381..95b124bbe3 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -6,15 +6,20 @@ from google.protobuf.json_format import MessageToJson from proto.proto_out import assembly_pb2, types_pb2 - from src import gm from src.APS.APS import getAuth, upload_mirabuf from src.Logging import getLogger, logFailure, timed -from src.Types import ExportLocation, ExportMode -from src.UI.Camera import captureThumbnail, clearIconCache from src.Parser.ExporterOptions import ExporterOptions -from src.Parser.SynthesisParser import Components, JointHierarchy, Joints, Materials, PDMessage +from src.Parser.SynthesisParser import ( + Components, + JointHierarchy, + Joints, + Materials, + PDMessage, +) from src.Parser.SynthesisParser.Utilities import * +from src.Types import ExportLocation, ExportMode +from src.UI.Camera import captureThumbnail, clearIconCache logger = getLogger() diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py index 923d9c836a..15e025f4c7 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py @@ -15,12 +15,12 @@ - Z """ + from typing import Union import adsk from proto.proto_out import types_pb2 - from src.Logging import logFailure diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py index 4cef6fea38..d6cbc47c77 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py @@ -18,7 +18,6 @@ import adsk.fusion from proto.proto_out import assembly_pb2 - from src.Logging import logFailure diff --git a/exporter/SynthesisFusionAddin/src/UI/Helper.py b/exporter/SynthesisFusionAddin/src/UI/Helper.py index 2f9eeaa12c..b6942afb4d 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Helper.py +++ b/exporter/SynthesisFusionAddin/src/UI/Helper.py @@ -3,7 +3,7 @@ import adsk.core -from src import gm, APP_NAME, APP_TITLE, INTERNAL_ID +from src import APP_NAME, APP_TITLE, INTERNAL_ID, gm from src.UI import HUI, Events diff --git a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py index 4a0c581f3d..f9d150cc3c 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Toolbar.py +++ b/exporter/SynthesisFusionAddin/src/UI/Toolbar.py @@ -1,5 +1,5 @@ -from src.Logging import logFailure from src import INTERNAL_ID, gm +from src.Logging import logFailure class Toolbar: From 0048d22abaaff277bb5f0a1cd73af3c254d5d934 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:25:47 -0700 Subject: [PATCH 06/11] Improved state managing --- exporter/SynthesisFusionAddin/Synthesis.py | 20 +------------------ .../SynthesisFusionAddin/src/GlobalManager.py | 5 +++++ .../src/UI/MarkingMenu.py | 7 +++++-- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 7f8ffd34e2..8775c80833 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -71,25 +71,7 @@ def stop(_): logger = getLogger(INTERNAL_ID) logger.cleanupHandlers() - for file in gm.files: - try: - os.remove(file) - except OSError: - pass - - # removes path so that proto files don't get confused - - import sys - - path = os.path.abspath(os.path.dirname(__file__)) - - path_proto_files = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out")) - - if path in sys.path: - sys.path.remove(path) - - if path_proto_files in sys.path: - sys.path.remove(path_proto_files) + gm.clear() @logFailure diff --git a/exporter/SynthesisFusionAddin/src/GlobalManager.py b/exporter/SynthesisFusionAddin/src/GlobalManager.py index fb95bda33b..6841a58750 100644 --- a/exporter/SynthesisFusionAddin/src/GlobalManager.py +++ b/exporter/SynthesisFusionAddin/src/GlobalManager.py @@ -42,6 +42,11 @@ def __init__(self): def __str__(self): return "GlobalManager" + def clear(self): + for attr, value in self.__dict__.items(): + if isinstance(value, list): + setattr(self, attr, []) + instance = None def __new__(cls): diff --git a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py index d6509b16d4..5b90c1b671 100644 --- a/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py +++ b/exporter/SynthesisFusionAddin/src/UI/MarkingMenu.py @@ -1,7 +1,7 @@ import adsk.core import adsk.fusion -from src.Logging import logFailure +from src.Logging import getLogger, logFailure # Ripped all the boiler plate from the example code: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-c90ce6a2-c282-11e6-a365-3417ebc87622 @@ -12,6 +12,8 @@ entities = [] occurrencesOfComponents = {} +logger = getLogger() + @logFailure(messageBox=True) def setupMarkingMenu(ui: adsk.core.UserInterface): @@ -204,6 +206,7 @@ def stopMarkingMenu(ui: adsk.core.UserInterface): if obj.isValid: obj.deleteMe() else: - ui.messageBox(str(obj) + " is not a valid object") + logger.warn(f"{str(obj)} is not a valid object") + cmdDefs.clear() handlers.clear() From 9f2af7126778804d62f6d6a6ee8fbfdae51ebfdf Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:42:18 -0700 Subject: [PATCH 07/11] Handle dependencies + update setup logger --- exporter/SynthesisFusionAddin/Synthesis.py | 40 ++++++++++---------- exporter/SynthesisFusionAddin/src/Logging.py | 3 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 8775c80833..31dd3559bd 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -3,35 +3,37 @@ import adsk.core -# Currently required for `resolveDependencies()`, will be required for absolute imports. +# Required for absolute imports. sys.path.append(os.path.dirname(os.path.abspath(__file__))) -from .src.Dependencies import resolveDependencies # isort:skip +from src.Dependencies import resolveDependencies +from src.Logging import logFailure, setupLogger -# Transition: AARD-1741 -# Import order should be removed in AARD-1737 and `setupLogger()` moved to `__init__.py` -from .src.Logging import getLogger, logFailure, setupLogger # isort:skip - -setupLogger() +logger = setupLogger() try: - from src import APP_NAME, DESCRIPTION, INTERNAL_ID, gm - from src.UI import ( - HUI, - Camera, - ConfigCommand, - MarkingMenu, - ShowAPSAuthCommand, - ShowWebsiteCommand, - ) - from src.UI.Toolbar import Toolbar + # Attempt to import required pip dependencies to verify their installation. + import google.protobuf + import requests except (ImportError, ModuleNotFoundError) as error: - getLogger().warn(f"Running resolve dependencies with error of:\n{error}") + logger.warn(f"Running resolve dependencies with error of:\n{error}") result = resolveDependencies() if result: adsk.core.Application.get().userInterface.messageBox("Installed required dependencies.\nPlease restart Fusion.") +from src import APP_NAME, DESCRIPTION, INTERNAL_ID, gm +from src.UI import ( + HUI, + Camera, + ConfigCommand, + MarkingMenu, + ShowAPSAuthCommand, + ShowWebsiteCommand, +) +from src.UI.Toolbar import Toolbar + + @logFailure def run(_): """## Entry point to application from Fusion. @@ -68,9 +70,7 @@ def stop(_): # nm.deleteMe() - logger = getLogger(INTERNAL_ID) logger.cleanupHandlers() - gm.clear() diff --git a/exporter/SynthesisFusionAddin/src/Logging.py b/exporter/SynthesisFusionAddin/src/Logging.py index dcfa863c67..e5f352f480 100644 --- a/exporter/SynthesisFusionAddin/src/Logging.py +++ b/exporter/SynthesisFusionAddin/src/Logging.py @@ -27,7 +27,7 @@ def cleanupHandlers(self) -> None: handler.close() -def setupLogger() -> None: +def setupLogger() -> SynthesisLogger: now = datetime.now().strftime("%H-%M-%S") today = date.today() logFileFolder = getOSPath(f"{pathlib.Path(__file__).parent.parent}", "logs") @@ -46,6 +46,7 @@ def setupLogger() -> None: logger = getLogger(INTERNAL_ID) logger.setLevel(10) # Debug logger.addHandler(logHandler) + return cast(SynthesisLogger, logger) def getLogger(name: str | None = None) -> SynthesisLogger: From 2ff084593eb34b6dd82ccc6abd526a296770e23f Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Tue, 6 Aug 2024 10:56:59 -0700 Subject: [PATCH 08/11] Final cleanups and handle transition tags --- exporter/SynthesisFusionAddin/Synthesis.py | 1 + exporter/SynthesisFusionAddin/src/Dependencies.py | 15 ++++++--------- .../src/Parser/SynthesisParser/Components.py | 11 +++++------ .../src/Parser/SynthesisParser/JointHierarchy.py | 4 +--- .../src/Parser/SynthesisParser/Joints.py | 2 +- .../src/Parser/SynthesisParser/Materials.py | 2 +- .../src/Parser/SynthesisParser/Parser.py | 2 +- .../src/Parser/SynthesisParser/RigidGroup.py | 2 +- exporter/SynthesisFusionAddin/src/UI/Camera.py | 1 - .../SynthesisFusionAddin/src/UI/ConfigCommand.py | 5 ++--- .../SynthesisFusionAddin/src/UI/CustomGraphics.py | 3 --- exporter/SynthesisFusionAddin/src/UI/Events.py | 2 +- .../src/UI/FileDialogConfig.py | 2 -- exporter/SynthesisFusionAddin/src/UI/Helper.py | 1 - .../SynthesisFusionAddin/src/UI/JointConfigTab.py | 3 --- .../src/UI/ShowAPSAuthCommand.py | 2 -- exporter/SynthesisFusionAddin/src/__init__.py | 13 ++++--------- 17 files changed, 24 insertions(+), 47 deletions(-) diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 31dd3559bd..06ead88431 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -5,6 +5,7 @@ # Required for absolute imports. sys.path.append(os.path.dirname(os.path.abspath(__file__))) +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "proto", "proto_out"))) from src.Dependencies import resolveDependencies from src.Logging import logFailure, setupLogger diff --git a/exporter/SynthesisFusionAddin/src/Dependencies.py b/exporter/SynthesisFusionAddin/src/Dependencies.py index a61119c1d6..c6c1b26b4c 100644 --- a/exporter/SynthesisFusionAddin/src/Dependencies.py +++ b/exporter/SynthesisFusionAddin/src/Dependencies.py @@ -1,7 +1,6 @@ import importlib.machinery import importlib.util import os -import platform import subprocess import sys from pathlib import Path @@ -9,10 +8,10 @@ import adsk.core import adsk.fusion +from src import SYSTEM from src.Logging import getLogger, logFailure logger = getLogger() -system = platform.system() # Since the Fusion python runtime is separate from the system python runtime we need to do some funky things # in order to download and install python packages separate from the standard library. @@ -29,13 +28,11 @@ def getInternalFusionPythonInstillationFolder() -> str: pythonStandardLibraryModulePath = importlib.machinery.PathFinder.find_spec("os", sys.path).origin # Depending on platform, adjust to folder to where the python executable binaries are stored. - if system == "Windows": + if SYSTEM == "Windows": folder = f"{Path(pythonStandardLibraryModulePath).parents[1]}" - elif system == "Darwin": - folder = f"{Path(pythonStandardLibraryModulePath).parents[2]}/bin" else: - # TODO: System string should be moved to __init__ after GH-1013 - raise RuntimeError("Unsupported platform.") + assert SYSTEM == "Darwin" + folder = f"{Path(pythonStandardLibraryModulePath).parents[2]}/bin" return folder @@ -100,7 +97,7 @@ def resolveDependencies() -> bool | None: adsk.doEvents() pythonFolder = getInternalFusionPythonInstillationFolder() - pythonExecutableFile = "python.exe" if system == "Windows" else "python" # Confirming 110% everything is fine. + pythonExecutableFile = "python.exe" if SYSTEM == "Windows" else "python" # Confirming 110% everything is fine. pythonExecutablePath = os.path.join(pythonFolder, pythonExecutableFile) progressBar = ui.createProgressDialog() @@ -109,7 +106,7 @@ def resolveDependencies() -> bool | None: progressBar.show("Synthesis", f"Installing dependencies...", 0, len(PIP_DEPENDENCY_VERSION_MAP) * 2 + 2, 0) # Install pip manually on macos as it is not included by default? Really? - if system == "Darwin" and not os.path.exists(os.path.join(pythonFolder, "pip")): + if SYSTEM == "Darwin" and not os.path.exists(os.path.join(pythonFolder, "pip")): pipInstallScriptPath = os.path.join(pythonFolder, "get-pip.py") if not os.path.exists(pipInstallScriptPath): executeCommand("curl", "https://bootstrap.pypa.io/get-pip.py", "-o", pipInstallScriptPath) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index 0ac0078d1c..fbdba1d891 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -1,9 +1,4 @@ # Contains all of the logic for mapping the Components / Occurrences -import logging -import traceback -import uuid -from typing import * - import adsk.core import adsk.fusion @@ -12,7 +7,11 @@ from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser import PhysicalProperties from src.Parser.SynthesisParser.PDMessage import PDMessage -from src.Parser.SynthesisParser.Utilities import * +from src.Parser.SynthesisParser.Utilities import ( + fill_info, + guid_component, + guid_occurrence, +) from src.Types import ExportMode # TODO: Impelement Material overrides diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 5c106d0188..2bd563b489 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -1,7 +1,5 @@ import enum -import logging -import traceback -from typing import * +from typing import Union import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py index c5458cbae3..0d0cdea910 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Joints.py @@ -29,7 +29,7 @@ import adsk.core import adsk.fusion -from proto.proto_out import assembly_pb2, joint_pb2, motor_pb2, signal_pb2, types_pb2 +from proto.proto_out import assembly_pb2, joint_pb2, signal_pb2, types_pb2 from src.Logging import getLogger from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index ca7fb5480c..d8538b5d9b 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -4,7 +4,7 @@ from src.Logging import logFailure from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage -from src.Parser.SynthesisParser.Utilities import * +from src.Parser.SynthesisParser.Utilities import construct_info, fill_info OPACITY_RAMPING_CONSTANT = 14.0 diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index 95b124bbe3..37148fb622 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -17,7 +17,7 @@ Materials, PDMessage, ) -from src.Parser.SynthesisParser.Utilities import * +from src.Parser.SynthesisParser.Utilities import fill_info from src.Types import ExportLocation, ExportMode from src.UI.Camera import captureThumbnail, clearIconCache diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py index d6cbc47c77..b90a2167fe 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py @@ -12,7 +12,7 @@ - Success """ -from typing import * +from typing import Union import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/UI/Camera.py b/exporter/SynthesisFusionAddin/src/UI/Camera.py index 85fa188ff8..02de04083a 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Camera.py +++ b/exporter/SynthesisFusionAddin/src/UI/Camera.py @@ -4,7 +4,6 @@ from src.Logging import logFailure from src.Types import OString -from src.UI import Helper @logFailure diff --git a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py index 3a1f2e6c76..c50c7feed2 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py @@ -10,13 +10,12 @@ import adsk.fusion from src import gm -from src.APS.APS import getAuth, getUserInfo, refreshAuthToken +from src.APS.APS import getAuth, getUserInfo from src.Logging import getLogger, logFailure from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.Parser import Parser -from src.Parser.SynthesisParser.Utilities import guid_occurrence from src.Types import ExportLocation, ExportMode -from src.UI import CustomGraphics, FileDialogConfig, Helper, IconPaths +from src.UI import FileDialogConfig from src.UI.Configuration.SerialCommand import SerialCommand from src.UI.GamepieceConfigTab import GamepieceConfigTab from src.UI.GeneralConfigTab import GeneralConfigTab diff --git a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py index d92c26f823..3b6bd8e2c2 100644 --- a/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py +++ b/exporter/SynthesisFusionAddin/src/UI/CustomGraphics.py @@ -1,6 +1,3 @@ -import logging -import traceback - import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/UI/Events.py b/exporter/SynthesisFusionAddin/src/UI/Events.py index 0c4cf37798..64d0f1ea29 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Events.py +++ b/exporter/SynthesisFusionAddin/src/UI/Events.py @@ -1,5 +1,5 @@ import json -from typing import Sequence, Tuple +from typing import Sequence import adsk.core diff --git a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py index 8b8b3a2f4c..d2465ae29b 100644 --- a/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py +++ b/exporter/SynthesisFusionAddin/src/UI/FileDialogConfig.py @@ -1,5 +1,3 @@ -from typing import Union - import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/UI/Helper.py b/exporter/SynthesisFusionAddin/src/UI/Helper.py index b6942afb4d..ba8bf9b0e9 100644 --- a/exporter/SynthesisFusionAddin/src/UI/Helper.py +++ b/exporter/SynthesisFusionAddin/src/UI/Helper.py @@ -1,5 +1,4 @@ from inspect import getmembers, isfunction -from typing import Union import adsk.core diff --git a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py index 000080eb79..b06ae6f2af 100644 --- a/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py +++ b/exporter/SynthesisFusionAddin/src/UI/JointConfigTab.py @@ -1,6 +1,3 @@ -import logging -import traceback - import adsk.core import adsk.fusion diff --git a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py index 13e3cec65d..999abd1176 100644 --- a/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py +++ b/exporter/SynthesisFusionAddin/src/UI/ShowAPSAuthCommand.py @@ -1,10 +1,8 @@ import json -import os import time import traceback import urllib.parse import urllib.request -import webbrowser import adsk.core diff --git a/exporter/SynthesisFusionAddin/src/__init__.py b/exporter/SynthesisFusionAddin/src/__init__.py index c7d951b784..1e426279bb 100644 --- a/exporter/SynthesisFusionAddin/src/__init__.py +++ b/exporter/SynthesisFusionAddin/src/__init__.py @@ -1,5 +1,5 @@ import os -import sys +import platform from src.GlobalManager import GlobalManager @@ -9,14 +9,9 @@ INTERNAL_ID = "Synthesis" ADDIN_PATH = os.path.dirname(os.path.realpath(__file__)) -A_EP = None # TODO: Will be removed by GH-1010 -DEBUG = True # TODO: Will be removed by GH-1010 +SYSTEM = platform.system() +assert SYSTEM != "Linux" gm = GlobalManager() -__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID", "ADDIN_PATH", "gm"] - -# Transition: AARD-1737 -# This method of running the resolve dependencies module will be revisited in AARD-1734 -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "proto", "proto_out"))) -# from proto import deps +__all__ = ["APP_NAME", "APP_TITLE", "DESCRIPTION", "INTERNAL_ID", "ADDIN_PATH", "SYSTEM", "gm"] From 715411be5b7747ba588065e0878c433ddea3d4b4 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:53:46 -0700 Subject: [PATCH 09/11] Version detection for protobuf fix --- exporter/SynthesisFusionAddin/Synthesis.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 06ead88431..5398577fde 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -14,8 +14,15 @@ try: # Attempt to import required pip dependencies to verify their installation. - import google.protobuf import requests + from proto.proto_out import ( + assembly_pb2, + joint_pb2, + material_pb2, + motor_pb2, + signal_pb2, + types_pb2, + ) except (ImportError, ModuleNotFoundError) as error: logger.warn(f"Running resolve dependencies with error of:\n{error}") result = resolveDependencies() From db138f94aca32ee5149b9fcac6b437868de59a40 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:10:07 -0700 Subject: [PATCH 10/11] Added `BaseException` catch for google `VersionError` --- exporter/SynthesisFusionAddin/Synthesis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/SynthesisFusionAddin/Synthesis.py b/exporter/SynthesisFusionAddin/Synthesis.py index 5398577fde..deba3c9551 100644 --- a/exporter/SynthesisFusionAddin/Synthesis.py +++ b/exporter/SynthesisFusionAddin/Synthesis.py @@ -23,7 +23,7 @@ signal_pb2, types_pb2, ) -except (ImportError, ModuleNotFoundError) as error: +except (ImportError, ModuleNotFoundError, BaseException) as error: # BaseException required to catch proto.VersionError logger.warn(f"Running resolve dependencies with error of:\n{error}") result = resolveDependencies() if result: From 4514f7ec87300e961abdffd896e14185028f5ae7 Mon Sep 17 00:00:00 2001 From: BrandonPacewic <92102436+BrandonPacewic@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:06:46 -0700 Subject: [PATCH 11/11] Import formatting fixes --- .../src/Parser/SynthesisParser/Components.py | 1 + .../src/Parser/SynthesisParser/JointHierarchy.py | 1 + .../SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py | 1 + .../SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py | 1 + .../src/Parser/SynthesisParser/PhysicalProperties.py | 1 + .../src/Parser/SynthesisParser/RigidGroup.py | 1 + 6 files changed, 6 insertions(+) diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py index 6f53db6eb1..aea709f04a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Components.py @@ -2,6 +2,7 @@ import adsk.core import adsk.fusion from proto.proto_out import assembly_pb2, joint_pb2, material_pb2, types_pb2 + from src.Logging import logFailure from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser import PhysicalProperties diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py index 811a39cc00..cf8c5e04b0 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py @@ -4,6 +4,7 @@ import adsk.core import adsk.fusion from proto.proto_out import joint_pb2, types_pb2 + from src import gm from src.Logging import getLogger, logFailure from src.Parser.ExporterOptions import ExporterOptions diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py index dbc996c08a..a077c764b7 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Materials.py @@ -1,5 +1,6 @@ import adsk from proto.proto_out import material_pb2 + from src.Logging import logFailure from src.Parser.ExporterOptions import ExporterOptions from src.Parser.SynthesisParser.PDMessage import PDMessage diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py index f43add6642..338f5a300a 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py @@ -5,6 +5,7 @@ import adsk.fusion from google.protobuf.json_format import MessageToJson from proto.proto_out import assembly_pb2, types_pb2 + from src import gm from src.APS.APS import getAuth, upload_mirabuf from src.Logging import getLogger, logFailure, timed diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py index f9c5ef7249..b178bcb3bb 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/PhysicalProperties.py @@ -20,6 +20,7 @@ import adsk from proto.proto_out import types_pb2 + from src.Logging import logFailure diff --git a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py index bdc012dbd1..8516cefae6 100644 --- a/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py +++ b/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/RigidGroup.py @@ -17,6 +17,7 @@ import adsk.core import adsk.fusion from proto.proto_out import assembly_pb2 + from src.Logging import logFailure