Message 1 of 3
Error when mirroring newly created component: NONROOT_OCCURRENCE_PATH_ROOT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Has anyone ever seen this error before? No results for this error exist online as fast as I can tell.
I'm trying to mirror a newly created component.
Have not succeeded in recreating this problem in a sample script yet, sorry.
The error only happens if I have another component that the root component active in the ui.
File "...logic.py", line 424, in create_mirror_feature
mirror_feature = features.mirrorFeatures.add(mirror_feature_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/Library/Application Support/Autodesk/webdeploy/pre-production/f20f20e2c96b4b67a6e9ce4db65bc41e8c4963b7/Autodesk Fusion.app/Contents/Api/Python/packages/adsk/fusion.py", line 36635, in add
return _fusion.MirrorFeatures_add(self, input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: 3 : MirrorComponent1 / Compute Failed // NONROOT_OCCURRENCE_PATH_ROOT - Occurrence Path must be from root component
def create_mirror_feature(
entities: Union[adsk.core.ObjectCollection,
List[Union[adsk.fusion.BRepFace, adsk.fusion.Feature,
adsk.fusion.BRepBody, adsk.fusion.Occurrence]]],
midplane: adsk.fusion.ConstructionPlane,
name: str,
parent_component: Optional[adsk.fusion.Component] = None,
is_join: bool = True
) -> adsk.fusion.MirrorFeature:
"""
Create a mirror feature.
Args:
entities (Union[adsk.core.ObjectCollection, List[Union[adsk.fusion.BRepFace, adsk.fusion.Feature, adsk.fusion.BRepBody, adsk.fusion.Occurrence]]]): The entities to mirror.
midplane (adsk.fusion.ConstructionPlane): The midplane to mirror along.
name (str): The name of the mirror feature.
parent_component (adsk.fusion.Component, optional): The parent component where the mirror feature will be added. If None is passed, the root component is used.
is_join (bool, optional): Determines if the mirror feature should combine the mirrored bodies with the original bodies. Defaults to True.
Returns:
adsk.fusion.MirrorFeature: The created mirror feature.
"""
# Get the active design.
design = adsk.core.Application.get().activeProduct
# Use the root component if parent_component is None.
if parent_component is None:
parent_component = design.rootComponent
features = parent_component.features
# Check if entities is a list and convert to ObjectCollection if necessary
if isinstance(entities, list):
# Check if all entities are of the same type
entity_types = {type(entity) for entity in entities}
if len(entity_types) > 1:
raise ValueError(
f'All entities in a mirror feature must be of the same type. Found types: {", ".join([str(t) for t in entity_types])}'
)
entities = adsk.core.ObjectCollection.createWithArray(entities)
mirror_feature_input = features.mirrorFeatures.createInput(
entities, midplane
)
mirror_feature_input.isCombine = is_join # This is how to make a join feature
entity_to_mirror = entities.item(0)
plane_parent = midplane.parent
root_comp = design.rootComponent
# Add debug information about component hierarchy
entity_info = ""
if isinstance(entity_to_mirror, adsk.fusion.Occurrence):
entity_info = f"Component to Mirror: {entity_to_mirror.name} (Full path: {entity_to_mirror.fullPathName})"
else: # BRepBody
entity_info = f"Body to Mirror: {entity_to_mirror.name} (Parent: {entity_to_mirror.parentComponent.name})"
# Log information
entity_type = "component occurrence" if isinstance(entity_to_mirror, adsk.fusion.Occurrence) else "body"
ui.messageBox(
f"Component Hierarchy Information:\n\n" +
f"Root Component: {root_comp.name} (ID: {root_comp.id})\n" +
f"{entity_info}\n" +
f"Mirror Plane Parent: {plane_parent.name} (ID: {plane_parent.id})\n"
f"Attempting to mirror {entity_type} {entity_to_mirror.name} using plane {midplane.name} from {plane_parent.name}.\n" +
f"Mirror feature will be created in {parent_component.name}."
)
mirror_feature = features.mirrorFeatures.add(mirror_feature_input)
mirror_feature.name = name
return mirror_feature
Component Hierarchy Information logged before the error happens:
Root Component: (Unsaved) (ID: 74b03e4a-8a8a-44e1-a66d-49b97b263d12)
Component to Mirror: Drawer front:1 (Full path: Drawer front:1)
Mirror Plane Parent: Component2 (ID: 933468d0-7062-452e-8f3f-0e9286706aa2)
Attempting to mirror component occurrence Drawer front:1 using plane Width Midplane from Component2.
Mirror feature will be created in Component2.