Skip to content

import_step: detach single free shape from its temporary wrapper#1365

Open
cyberhuman wants to merge 1 commit into
gumyr:devfrom
cyberhuman:pr/import-detach-root
Open

import_step: detach single free shape from its temporary wrapper#1365
cyberhuman wants to merge 1 commit into
gumyr:devfrom
cyberhuman:pr/import-detach-root

Conversation

@cyberhuman

Copy link
Copy Markdown

Problem

With exactly one free shape in the document, import_step returns
root.children[0] while it is still parented to the discarded wrapper
Compound. export_step walks .parent, finds no label for the wrapper,
and silently builds an empty XCAF document — so
export_step(import_step(f), out) always fails with
RuntimeError: Failed to write STEP file.

Fix

Detach the unwrapped shape from the temporary wrapper before returning it.

Testing

test_reexport_imported_assembly (added) — import_step's result has
parent is None and survives an export/import round-trip with label,
colour and placement intact. Fails before this change.

With exactly one free shape in the document, import_step returns
root.children[0] while it is still parented to the discarded wrapper
Compound. export_step then walks .parent, finds no label for the
wrapper, and silently builds an empty XCAF document, failing with
"Failed to write STEP file" — so an imported STEP could never be
re-exported. Detach the shape before returning it.

Adds a regression test (test_reexport_imported_assembly) that fails
before this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant