Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/panelUtils/panel_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,22 @@ def generatePanel(args: adsk.core.CommandEventArgs):
root = adsk.fusion.Component.cast(des.rootComponent)
componentName = "{} {} {} Panel".format(OPTIONS.formatName, OPTIONS.widthInHp, OPTIONS.widthUnitName)

# create new component
newCmpOcc = adsk.fusion.Occurrences.cast(root.occurrences).addNewComponent(adsk.core.Matrix3D.create())
newCmpOcc.component.name = componentName
newCmpOcc.activate()

panelComponent: adsk.fusion.Component = newCmpOcc.component
originalTimelineCount = des.timeline.count
if des.designIntent == adsk.fusion.DesignIntentTypes.HybridDesignIntentType:
# create new component, only allowed in hybrid intent type
newCmpOcc = adsk.fusion.Occurrences.cast(root.occurrences).addNewComponent(adsk.core.Matrix3D.create())
newCmpOcc.component.name = componentName
newCmpOcc.activate()
panelComponent: adsk.fusion.Component = newCmpOcc.component
else:
# Part design intent only supports a single component, use root directly
panelComponent: adsk.fusion.Component = root

generatePanelComponent(panelComponent, OPTIONS)

# group features in timeline
count = panelComponent.sketches.count + panelComponent.features.count + panelComponent.constructionAxes.count + panelComponent.constructionPlanes.count
if count > 1:
panelGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + count)
if des.timeline.count - originalTimelineCount > 1:
panelGroup = des.timeline.timelineGroups.add(originalTimelineCount, des.timeline.count - 1)
panelGroup.name = componentName
except Exception as err:
args.executeFailed = True
Expand Down