Handle model projection in Altium import

If the model is seated on the back, KiCad just needs to rotate and
offset for the board (if it is placed)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/213356
This commit is contained in:
Seth Hillbrand 2025-07-17 16:47:39 -07:00
parent e8219c4300
commit 8556bd45c2
2 changed files with 23 additions and 5 deletions

View File

@ -702,6 +702,7 @@ ACOMPONENTBODY6::ACOMPONENTBODY6( ALTIUM_BINARY_PARSER& aReader )
rotation = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "MODEL.2D.ROTATION" ), 0. );
body_opacity_3d = ALTIUM_PROPS_UTILS::ReadDouble( properties, wxT( "BODYOPACITY3D" ), 1. );
body_projection = ALTIUM_PROPS_UTILS::ReadInt( properties, wxT( "BODYPROJECTION" ), 0 );
aReader.SkipSubrecord();

View File

@ -1116,6 +1116,7 @@ void ALTIUM_PCB::ParseBoard6Data( const ALTIUM_PCB_COMPOUND_FILE& aAltiumPcb
}
HelperCreateBoardOutline( elem.board_vertices );
m_board->GetDesignSettings().SetBoardThickness( stackup.BuildBoardThicknessFromStackup() );
}
@ -1450,13 +1451,21 @@ void ALTIUM_PCB::ConvertComponentBody6ToFootprintItem( const ALTIUM_PCB_COMPOUND
orientation = -orientation;
}
VECTOR3D modelRotation( aElem.modelRotation );
if( aElem.body_projection == 1 )
{
modelRotation.x += 180;
modelRotation.z += 180;
}
RotatePoint( &modelSettings.m_Offset.x, &modelSettings.m_Offset.y, orientation );
modelSettings.m_Rotation.x = normalizeAngleDegrees( -aElem.modelRotation.x, -180, 180 );
modelSettings.m_Rotation.y = normalizeAngleDegrees( -aElem.modelRotation.y, -180, 180 );
modelSettings.m_Rotation.z = normalizeAngleDegrees( -aElem.modelRotation.z + aElem.rotation
+ orientation.AsDegrees(),
-180, 180 );
modelSettings.m_Rotation.x = normalizeAngleDegrees( -modelRotation.x, -180, 180 );
modelSettings.m_Rotation.y = normalizeAngleDegrees( -modelRotation.y, -180, 180 );
modelSettings.m_Rotation.z = normalizeAngleDegrees( -modelRotation.z + aElem.rotation
+ orientation.AsDegrees(),
-180, 180 );
modelSettings.m_Opacity = aElem.body_opacity_3d;
aFootprint->Models().push_back( modelSettings );
@ -1541,6 +1550,14 @@ void ALTIUM_PCB::ParseComponentsBodies6Data( const ALTIUM_PCB_COMPOUND_FILE&
orientation = -orientation;
}
if( elem.body_projection == 1 )
{
elem.modelRotation.x += 180;
elem.modelRotation.z += 180;
modelSettings.m_Offset.z = pcbIUScale.IUTomm( m_board->GetDesignSettings().GetBoardThickness() )
+ modelSettings.m_Offset.z;
}
RotatePoint( &modelSettings.m_Offset.x, &modelSettings.m_Offset.y, orientation );
modelSettings.m_Rotation.x = normalizeAngleDegrees( -elem.modelRotation.x, -180, 180 );