Skip to content

Commit

Permalink
AARD-1685: Joint Config Panel (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Jul 22, 2024
2 parents 55a2dde + 5285fad commit 11c7a54
Show file tree
Hide file tree
Showing 5 changed files with 746 additions and 798 deletions.
38 changes: 25 additions & 13 deletions exporter/SynthesisFusionAddin/src/Parser/ExporterOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Not 100% sure what this is for - Brandon
JointParentType = Enum("JointParentType", ["ROOT", "END"])

WheelType = Enum("WheelType", ["STANDARD", "OMNI"])
WheelType = Enum("WheelType", ["STANDARD", "OMNI", "MECANUM"])
SignalType = Enum("SignalType", ["PWM", "CAN", "PASSIVE"])
ExportMode = Enum("ExportMode", ["ROBOT", "FIELD"]) # Dynamic / Static export
PreferredUnits = Enum("PreferredUnits", ["METRIC", "IMPERIAL"])
Expand All @@ -40,6 +40,12 @@ class Joint:
speed: float = field(default=None)
force: float = field(default=None)

# Transition: AARD-1865
# Should consider changing how the parser handles wheels and joints as there is overlap between
# `Joint` and `Wheel` that should be avoided
# This overlap also presents itself in 'ConfigCommand.py' and 'JointConfigTab.py'
isWheel: bool = field(default=False)


@dataclass
class Gamepiece:
Expand Down Expand Up @@ -78,7 +84,10 @@ class ModelHierarchy(Enum):

@dataclass
class ExporterOptions:
fileLocation: str = field(
# Python's `os` module can return `None` when attempting to find the home directory if the
# user's computer has conflicting configs of some sort. This has happened and should be accounted
# for accordingly.
fileLocation: str | None = field(
default=(os.getenv("HOME") if platform.system() == "Windows" else os.path.expanduser("~"))
)
name: str = field(default=None)
Expand All @@ -103,18 +112,21 @@ class ExporterOptions:
physicalDepth: PhysicalDepth = field(default=PhysicalDepth.AllOccurrence)
physicalCalculationLevel: CalculationAccuracy = field(default=CalculationAccuracy.LowCalculationAccuracy)

def readFromDesign(self) -> None:
designAttributes = adsk.core.Application.get().activeProduct.attributes
for field in fields(self):
attribute = designAttributes.itemByName(INTERNAL_ID, field.name)
if attribute:
setattr(
self,
field.name,
self._makeObjectFromJson(field.type, json.loads(attribute.value)),
)
def readFromDesign(self) -> "ExporterOptions":
try:
designAttributes = adsk.core.Application.get().activeProduct.attributes
for field in fields(self):
attribute = designAttributes.itemByName(INTERNAL_ID, field.name)
if attribute:
setattr(
self,
field.name,
self._makeObjectFromJson(field.type, json.loads(attribute.value)),
)

return self
return self
except:
return ExporterOptions()

def writeToDesign(self) -> None:
designAttributes = adsk.core.Application.get().activeProduct.attributes
Expand Down
Loading

0 comments on commit 11c7a54

Please sign in to comment.