From 5805c390900c3c0a129d4c20489287fa57a711e4 Mon Sep 17 00:00:00 2001 From: Paul Jordaan Date: Sun, 6 Sep 2026 21:09:33 +0200 Subject: [PATCH] fix: don't create a sub-component when design intent is Part Fusion's newer document types can be created with a "Part" design intent, which only supports a single component. Calling Occurrences.addNewComponent() on the root component in that case raises: "Failed to create component: Part Design documents can only contain one component, please add this Part to an Assembly to add multiple components." Only create a new sub-component when the design intent is Hybrid (the common case for pre-existing/legacy documents); otherwise generate the panel geometry directly in the root component. Timeline grouping is adjusted to use timeline counts before/after generation instead of relying on the now-optional new occurrence. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01AgGpgrEGYVZbzoqi5D2X8m --- lib/panelUtils/panel_command.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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