@@ -12,6 +12,7 @@ import { NODE_TYPES } from '$lib/constants/nodeTypes';
1212import { BLOCK_CATEGORY_ORDER } from '$lib/constants/python' ;
1313import { isSubsystem , isInterface } from '$lib/nodes/shapes' ;
1414import { blockImportPaths } from '$lib/nodes/generated/blocks' ;
15+ import { ENGINE_MODULE , enginePath } from '$lib/constants/engine' ;
1516import { graphStore , findParentSubsystem } from '$lib/stores/graph' ;
1617import {
1718 runStreamingSimulation ,
@@ -165,8 +166,11 @@ function collectBlockImportGroups(nodes: NodeInstance[]): Map<string, Set<string
165166
166167 // Toolbox-registered blocks carry their own importPath; built-ins
167168 // fall back to the static map. Last fallback is core pathsim.blocks.
168- const importPath =
169- typeDef . importPath ?? blockImportPaths [ typeDef . blockClass ] ?? 'pathsim.blocks' ;
169+ // enginePath() rewrites core pathsim paths to the active engine module
170+ // (identity in the default pathsim build).
171+ const importPath = enginePath (
172+ typeDef . importPath ?? blockImportPaths [ typeDef . blockClass ] ?? 'pathsim.blocks'
173+ ) ;
170174 if ( ! groups . has ( importPath ) ) groups . set ( importPath , new Set ( ) ) ;
171175 groups . get ( importPath ) ! . add ( typeDef . blockClass ) ;
172176 }
@@ -395,9 +399,9 @@ export function generatePythonCode(
395399 lines . push ( '# IMPORTS' ) ;
396400 lines . push ( 'import numpy as np' ) ;
397401 if ( hasSubsystems ) {
398- lines . push ( ' from pathsim import Simulation, Connection, Subsystem, Interface' ) ;
402+ lines . push ( ` from ${ ENGINE_MODULE } import Simulation, Connection, Subsystem, Interface` ) ;
399403 } else {
400- lines . push ( ' from pathsim import Simulation, Connection' ) ;
404+ lines . push ( ` from ${ ENGINE_MODULE } import Simulation, Connection` ) ;
401405 }
402406 for ( const [ importPath , classes ] of importGroups ) {
403407 const sorted = [ ...classes ] . sort ( ) ;
@@ -408,12 +412,12 @@ export function generatePythonCode(
408412 }
409413 }
410414 // Ensure at least pathsim.blocks is imported even if no blocks
411- if ( ! importGroups . has ( 'pathsim .blocks' ) ) {
412- lines . push ( ' from pathsim .blocks import *' ) ;
415+ if ( ! importGroups . has ( ` ${ ENGINE_MODULE } .blocks` ) ) {
416+ lines . push ( ` from ${ ENGINE_MODULE } .blocks import *` ) ;
413417 }
414- lines . push ( `from pathsim .solvers import ${ getSettingOrDefault ( settings , 'solver' ) } ` ) ;
418+ lines . push ( `from ${ ENGINE_MODULE } .solvers import ${ getSettingOrDefault ( settings , 'solver' ) } ` ) ;
415419 if ( hasEvents ) {
416- lines . push ( `from pathsim .events import ${ [ ...eventClasses ] . join ( ', ' ) } ` ) ;
420+ lines . push ( `from ${ ENGINE_MODULE } .events import ${ [ ...eventClasses ] . join ( ', ' ) } ` ) ;
417421 }
418422 lines . push ( '' ) ;
419423
@@ -566,9 +570,9 @@ function generateFormattedPythonCode(
566570 lines . push ( 'import matplotlib.pyplot as plt' ) ;
567571 lines . push ( '' ) ;
568572 if ( hasSubsystems ) {
569- lines . push ( ' from pathsim import Simulation, Connection, Subsystem, Interface' ) ;
573+ lines . push ( ` from ${ ENGINE_MODULE } import Simulation, Connection, Subsystem, Interface` ) ;
570574 } else {
571- lines . push ( ' from pathsim import Simulation, Connection' ) ;
575+ lines . push ( ` from ${ ENGINE_MODULE } import Simulation, Connection` ) ;
572576 }
573577
574578 // Collect block classes grouped by import path
@@ -589,9 +593,9 @@ function generateFormattedPythonCode(
589593 }
590594 }
591595
592- lines . push ( `from pathsim .solvers import ${ getSettingOrDefault ( settings , 'solver' ) } ` ) ;
596+ lines . push ( `from ${ ENGINE_MODULE } .solvers import ${ getSettingOrDefault ( settings , 'solver' ) } ` ) ;
593597 if ( hasEvents ) {
594- lines . push ( `from pathsim .events import ${ [ ...eventClasses ] . join ( ', ' ) } ` ) ;
598+ lines . push ( `from ${ ENGINE_MODULE } .events import ${ [ ...eventClasses ] . join ( ', ' ) } ` ) ;
595599 }
596600 lines . push ( '' ) ;
597601
0 commit comments