import_step: detach single free shape from its temporary wrapper#1365
Open
cyberhuman wants to merge 1 commit into
Open
import_step: detach single free shape from its temporary wrapper#1365cyberhuman wants to merge 1 commit into
cyberhuman wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With exactly one free shape in the document,
import_stepreturnsroot.children[0]while it is still parented to the discarded wrapperCompound.export_stepwalks.parent, finds no label for the wrapper,and silently builds an empty XCAF document — so
export_step(import_step(f), out)always fails withRuntimeError: 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 hasparent is Noneand survives an export/import round-trip with label,colour and placement intact. Fails before this change.