Repository navigation
Conversation
…sembly (#583) A component of an assembly is placed by a REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATION with an ITEM_DEFINED_TRANSFORMATION. Usually rep_1 is the component and rep_2 the assembly; SolidWorks writes it the other way round. GetTransformation combined the rotation of the displacement with the translation of the passive coordinate change, which is only right when the component's placement is the identity and rep_1 is the component. With rep_1 = assembly, the component was turned correctly but moved to the wrong place. Now each shape representation remembers the product of its SHAPE_DEFINITION_REPRESENTATION. contextDependentShapeRepresentation compares the products of rep_1 and rep_2 with the related and relating product of the NEXT_ASSEMBLY_USAGE_OCCURRENCE (like Open CASCADE's STEPConstruct_Assembly::CheckSRRReversesNAUO), and when that settles which side is the component, the transformation moves the component's placement onto the assembly's placement, as mapped_item already does. When it cannot be decided, or when StepImport.Transformation is set, the old code runs unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T9C2KYWSC8fNbLDvhoEdJK
This branch has not been deployed
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.
Fixes #583.
Problem
An assembly component is placed by a
REPRESENTATION_RELATIONSHIP_WITH_TRANSFORMATIONwith anITEM_DEFINED_TRANSFORMATION. Usuallyrep_1is the component andrep_2the assembly. SolidWorks writes it the other way round.GetTransformationmixed two different formulas: its rotation came from the rigid displacement, its translation from the passive coordinate change. That only gives the right result whenrep_1is the component and the component's placement is the identity. In the reversed order, the component was turned correctly but moved to the wrong place.The same bug also affects the usual order when the placement inside the component is not the identity. The issue does not mention this case.
Fix
Follows the suggestion in the issue:
shapeDefinitionRepresentationrecords on itsused_representationwhich product it belongs to (_ofProducts).contextDependentShapeRepresentationcompares the products ofrep_1andrep_2with the related and relating product of theNEXT_ASSEMBLY_USAGE_OCCURRENCE, like Open CASCADE'sSTEPConstruct_Assembly::CheckSRRReversesNAUO.GetTransformationreturnsModOp.Fit(component, assembly): the component's placement is moved onto the assembly's placement, asmapped_itemalready does.StepImport.Transformationis set, the old code runs unchanged.Tests
StepAssemblyPlacementTestsbuilds assemblies fromissue101.stpin both orders, with four placements each:Before the fix, 4 of the 8 cases failed. All pass now. The full suites pass too:
CADability.Testshas 1003 passed and 12 skipped,CADability.ImportTestshas 104 passed and 1 skipped (net8.0, Linux).Comparison with Open CASCADE 8.0.1
The same 8 files were read with Open CASCADE 8.0.1. When the component's placement is the identity, Open CASCADE agrees with this change in both orders. When the component's placement is not the identity, Open CASCADE applies
gp_Trsf::SetTransformation(assembly, component)and gets a different result. The parts of ISO 10303-43 / ISO/TS 10303-1345 I could read do not settle the formula for this case. This PR keeps the reading proposed in the issue, which matches CADability'smapped_item. The test documents this. Exporters practically always write the identity there, including SolidWorks in the issue's file.Generated by Claude Code