Skip to content

STEP import: place assembly components correctly when rep_1 is the assembly - #584

Open
dsn27 wants to merge 1 commit into
masterfrom
claude/vibrant-noether-oz7n52
Open

dsn27 wants to merge 1 commit into
masterfrom
claude/vibrant-noether-oz7n52

Conversation

@dsn27

@dsn27 dsn27 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes #583.

Problem

An assembly component 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 mixed two different formulas: its rotation came from the rigid displacement, its translation from the passive coordinate change. That only gives the right result when rep_1 is 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:

  • shapeDefinitionRepresentation records on its used_representation which product it belongs to (_ofProducts).
  • 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.
  • When that decides which side is the component, GetTransformation returns ModOp.Fit(component, assembly): the component's placement is moved onto the assembly's placement, as mapped_item already does.
  • When it cannot be decided (no product, several products, or contradictory), or when StepImport.Transformation is set, the old code runs unchanged.

Tests

StepAssemblyPlacementTests builds assemblies from issue101.stp in both orders, with four placements each:

  • turned at (500, 0, 0), as in the issue
  • an offset, tilted placement inside the component
  • a pure translation
  • a pure rotation

Before the fix, 4 of the 8 cases failed. All pass now. The full suites pass too: CADability.Tests has 1003 passed and 12 skipped, CADability.ImportTests has 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's mapped_item. The test documents this. Exporters practically always write the identity there, including SolidWorks in the issue's file.


Generated by Claude Code

…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

No deployments
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.

STEP import: assembly parts land in the wrong place when rep_1 of the relationship is the assembly

2 participants