diff --git a/lib/panelUtils/panel_command.py b/lib/panelUtils/panel_command.py index 511c176..7942c15 100644 --- a/lib/panelUtils/panel_command.py +++ b/lib/panelUtils/panel_command.py @@ -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