-
Notifications
You must be signed in to change notification settings - Fork 62
Exporter Materials Tagging [AARD-1880]
#1170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cae307e
feat: Added Tagging Tab with body selection, dropdown, & table
Dhruv-0-Arora 9531a07
Merge branch 'dev' into dhruv/1880/material-tagging
Dhruv-0-Arora be9fddd
feat: added add + remove functionality with table
Dhruv-0-Arora a6324da
feat: added remove button functionality
Dhruv-0-Arora 56739aa
chore: cleanup of code and formatting
Dhruv-0-Arora 8fc46fe
fix: corrected which row is removed
Dhruv-0-Arora 99378e6
feat: adding function to export tags
Dhruv-0-Arora a54ce77
fix: export button is unselectable due to tagging selection
Dhruv-0-Arora 48018ea
fix: full UI functionality
Dhruv-0-Arora 5f485df
Merging Dev
Dhruv-0-Arora d7b6ffd
chore: formatting
Dhruv-0-Arora a68333b
Merging Dev
Dhruv-0-Arora 66da85e
fix: merging reload PR
Dhruv-0-Arora 7d818e7
feat: stores bodies and tags for exporting
Dhruv-0-Arora 6f56faf
Merging Dev
Dhruv-0-Arora 159eb3f
feat: adding exporting
Dhruv-0-Arora cc2fdbb
Merging Dev
Dhruv-0-Arora 7989f03
formatting
Dhruv-0-Arora c1651a0
chore: code cleanup
Dhruv-0-Arora 648f41e
feat: adding component column and changing UI remove row message
Dhruv-0-Arora 67bfd07
fix: cleanup of unused code
Dhruv-0-Arora facc569
Merging Dev
Dhruv-0-Arora b0b150a
fix: cleaning dead code and fixing spelling error
Dhruv-0-Arora 6cd3d14
feat: added blank icon to allow users to select rows
Dhruv-0-Arora 4f7ff17
formatting
Dhruv-0-Arora c40a341
isort formatting
Dhruv-0-Arora 8c319e5
feat: adding export of tags into assembly data
Dhruv-0-Arora 0e7987e
code cleanup and formatting
Dhruv-0-Arora 688753e
Merge `dev`
BrandonPacewic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
exporter/SynthesisFusionAddin/src/UI/TaggingConfigTab.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import adsk.core | ||
| import adsk.fusion | ||
|
|
||
| from src.Logging import getLogger, logFailure | ||
| from src.UI import IconPaths | ||
| from src.UI.CreateCommandInputsHelper import createTableInput, createTextBoxInput | ||
|
|
||
| logger = getLogger() | ||
|
|
||
|
|
||
| class TaggingConfigTab: | ||
| # stores the types of tags available for selection | ||
| tagTypes = ["Softbody", "Rigid", "Chain", "Spring", "Rope"] | ||
| tagMap: dict[str, str] = {} | ||
| tagList: list[str] = [] | ||
|
|
||
| taggingConfigTab: adsk.core.TabCommandInput | ||
| taggingListTable: adsk.core.TableCommandInput | ||
| tagTypeDropdown: adsk.core.DropDownCommandInput | ||
|
|
||
| @logFailure | ||
| def __init__(self, args: adsk.core.CommandCreatedEventArgs) -> None: | ||
| self.taggingConfigTab = args.command.commandInputs.addTabCommandInput("taggingOptionsTab", "Tagging Options") | ||
| self.taggingConfigTab.tooltip = "Configure tagging options for materials" | ||
| taggingConfigTabInputs = self.taggingConfigTab.children | ||
|
|
||
| self.tagTypeDropdown = taggingConfigTabInputs.addDropDownCommandInput( | ||
| "tageTypeDropdown", "Tag Type", dropDownStyle=adsk.core.DropDownStyles.LabeledIconDropDownStyle | ||
| ) | ||
| self.tagTypeDropdown.isFullWidth = False | ||
| for tag in self.tagTypes: | ||
| self.tagTypeDropdown.listItems.add(tag, False) | ||
| self.tagTypeDropdown.isEnabled = self.tagTypeDropdown.isVisible = False | ||
|
|
||
| bodySelection = taggingConfigTabInputs.addSelectionInput( | ||
| "tagBodySelect", "Select Body", "Select a single body." | ||
| ) | ||
| bodySelection.addSelectionFilter("SolidBodies") | ||
| bodySelection.addSelectionFilter("SurfaceBodies") | ||
|
|
||
| self.taggingListTable = createTableInput("tagListTable", "Tag List", taggingConfigTabInputs, 6, "1:4:4:4") | ||
| self.taggingListTable.addCommandInput( | ||
| createTextBoxInput("headerIcon", "", taggingConfigTabInputs, "", bold=False), 0, 0 | ||
| ) | ||
| self.taggingListTable.addCommandInput( | ||
| createTextBoxInput("headerBodyName", "Body", taggingConfigTabInputs, "Body Name", background="#d9d9d9"), | ||
| 0, | ||
| 1, | ||
| ) | ||
| self.taggingListTable.addCommandInput( | ||
| createTextBoxInput( | ||
| "headerComponentName", "Component", taggingConfigTabInputs, "Component Name", background="#d9d9d9" | ||
| ), | ||
| 0, | ||
| 2, | ||
| ) | ||
| self.taggingListTable.addCommandInput( | ||
| createTextBoxInput("headerTagType", "Type", taggingConfigTabInputs, "Tag Type", background="#d9d9d9"), 0, 3 | ||
| ) | ||
|
|
||
| addTagInputButton = taggingConfigTabInputs.addBoolValueInput("tagAddButton", "Add", False) | ||
| removeTagInputButton = taggingConfigTabInputs.addBoolValueInput("tagRemoveButton", "Remove", False) | ||
| cancelInputButton = taggingConfigTabInputs.addBoolValueInput("tagCancelButton", "Cancel", False) | ||
|
|
||
| self.taggingListTable.addToolbarCommandInput(addTagInputButton) | ||
| self.taggingListTable.addToolbarCommandInput(removeTagInputButton) | ||
| self.taggingListTable.addToolbarCommandInput(cancelInputButton) | ||
|
|
||
| self.toggleSelecting(False) | ||
|
|
||
| @property | ||
| def isVisible(self) -> bool: | ||
| return self.taggingConfigTab.isVisible or False | ||
|
Dhruv-0-Arora marked this conversation as resolved.
|
||
|
|
||
| @isVisible.setter | ||
| def isVisible(self, value: bool) -> None: | ||
| self.taggingConfigTab.isVisible = value | ||
|
|
||
| @property | ||
| def isActive(self) -> bool: | ||
| return self.taggingConfigTab.isActive or False | ||
|
|
||
| def toggleSelecting(self, value: bool) -> None: | ||
| tagAddButton: adsk.core.BoolValueCommandInput = self.taggingConfigTab.commandInputs.itemById("tagAddButton") | ||
| tagRemoveButton: adsk.core.BoolValueCommandInput = self.taggingConfigTab.commandInputs.itemById( | ||
| "tagRemoveButton" | ||
| ) | ||
| tagBodySelection: adsk.core.SelectionCommandInput = self.taggingConfigTab.commandInputs.itemById( | ||
| "tagBodySelect" | ||
| ) | ||
| tagCancelButton: adsk.core.BoolValueCommandInput = self.taggingConfigTab.commandInputs.itemById( | ||
| "tagCancelButton" | ||
| ) | ||
|
|
||
| tagAddButton.isEnabled = tagRemoveButton.isEnabled = not value | ||
| tagCancelButton.isVisible = value | ||
| self.tagTypeDropdown.isEnabled = self.tagTypeDropdown.isVisible = value | ||
|
|
||
| if not value: | ||
| tagBodySelection.clearSelection() | ||
| tagBodySelection.setSelectionLimits(0) | ||
| tagBodySelection.isEnabled = tagBodySelection.isVisible = False | ||
|
|
||
| else: | ||
| tagBodySelection.isVisible = tagBodySelection.isEnabled = True | ||
| tagBodySelection.setSelectionLimits(0, 1) | ||
|
|
||
| def addTag(self, body: adsk.fusion.BRepBody, tag: str) -> None: | ||
| commandInputs = self.taggingListTable.commandInputs | ||
| row = self.taggingListTable.rowCount | ||
|
|
||
| icon = commandInputs.addImageCommandInput(f"tag_icon_{row}", "Ball", IconPaths.tagIcons["blank"]) | ||
| icon.tooltip = "Tag" | ||
|
|
||
| bodyName = commandInputs.addTextBoxCommandInput(f"bodyName_{row}", "Body Name", "", 1, True) | ||
| bodyName.formattedText = f"<p style='font-size:11px'>{body.name}</p>" | ||
|
|
||
| componentName = commandInputs.addTextBoxCommandInput(f"componentName_{row}", "Component Name", "", 1, True) | ||
| componentName.formattedText = f"<p style='font-size:11px'>{body.parentComponent.name}</p>" | ||
|
|
||
| tagType = commandInputs.addTextBoxCommandInput(f"tagType_{row}", "Tag Type", "", 1, True) | ||
| tagType.formattedText = f"<p style='font-size:11px'>{tag}</p>" | ||
|
|
||
| self.taggingListTable.addCommandInput(icon, row, 0) | ||
| self.taggingListTable.addCommandInput(bodyName, row, 1) | ||
| self.taggingListTable.addCommandInput(componentName, row, 2) | ||
| self.taggingListTable.addCommandInput(tagType, row, 3) | ||
|
|
||
| key_body = body.nativeObject or body | ||
| self.tagMap[key_body.entityToken] = tag | ||
| self.tagList.append(key_body.entityToken) | ||
|
|
||
| @logFailure | ||
| def handleInputChanged( | ||
| self, args: adsk.core.InputChangedEventArgs, globalCommandInputs: adsk.core.CommandInputs | ||
| ) -> None: | ||
| commandInput = args.input | ||
| tagBodySelection: adsk.core.SelectionCommandInput = globalCommandInputs.itemById("tagBodySelect") | ||
|
|
||
| if commandInput.id == "tagAddButton": | ||
| self.toggleSelecting(True) | ||
|
|
||
| elif commandInput.id == "tagRemoveButton": | ||
| if self.taggingListTable.selectedRow == -1: | ||
| app = adsk.core.Application.get() | ||
| ui = app.userInterface | ||
| ui.messageBox("Please first select a tag to remove.") | ||
| return | ||
|
|
||
| selectedRow = self.taggingListTable.selectedRow | ||
| if selectedRow == 0: | ||
| return | ||
|
|
||
| token_to_remove = self.tagList[selectedRow - 1] | ||
| self.taggingListTable.deleteRow(selectedRow) | ||
| self.tagMap.pop(token_to_remove) | ||
| self.tagList.pop(selectedRow - 1) | ||
|
|
||
| elif commandInput.id == "tagCancelButton": | ||
| self.toggleSelecting(False) | ||
|
|
||
| elif tagBodySelection.selectionCount == 1 and self.tagTypeDropdown.selectedItem is not None: | ||
| self.addTag(tagBodySelection.selection(0).entity, self.tagTypeDropdown.selectedItem.name) | ||
| self.toggleSelecting(False) | ||
|
|
||
| @logFailure | ||
| def getTags(self) -> dict[str, str]: | ||
| return self.tagMap | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to finalize which tags we would like