From d2e51fdb5f0b10d169a45f93c61ba9ed8e75452a Mon Sep 17 00:00:00 2001
From: Dhineshkumar S <dhineshkumar@cgvakindia.com>
Date: Sun, 17 Nov 2024 07:20:48 +0000
Subject: [PATCH] Fix 3D viewer omission of STEP models with relative path
 assignment

The project was not assigned to the board in the 3D viewer frame,
resulting in a failure to locate the relative path for STEP models.
To fix this, the current project should be assigned to the board in
the 3D viewer frame.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16242
---
 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp
index ce1bcceee9..d3f8a12529 100644
--- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp
+++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp
@@ -571,6 +571,9 @@ void EDA_3D_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE *aCfg )
     {
         applySettings( cfg );
 
+        if( !GetBoard()->GetProject() )
+            GetBoard()->SetProject( &Prj() );
+
         m_boardAdapter.SetBoard( GetBoard() );
 
         // When opening the 3D viewer, we use the OpenGL mode, never the ray tracing engine