refactor: Engine updates and NX hooks improvements
optimization_engine: - Updated nx_solver.py with improvements - Enhanced solve_simulation.py - Updated extractors/__init__.py - Improved NX CAD hooks (expression_manager, feature_manager, geometry_query, model_introspection, part_manager) - Enhanced NX CAE solver_manager hook Documentation: - Updated OP_01_CREATE_STUDY.md protocol - Updated SYS_12_EXTRACTOR_LIBRARY.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -107,18 +107,25 @@ class NXSolver:
|
||||
|
||||
def _find_journal_runner(self) -> Path:
|
||||
"""Find the NX journal runner executable."""
|
||||
# Simcenter3D has run_journal.exe for batch execution
|
||||
# First check the provided nx_install_dir
|
||||
if self.nx_install_dir:
|
||||
direct_path = self.nx_install_dir / "NXBIN" / "run_journal.exe"
|
||||
if direct_path.exists():
|
||||
return direct_path
|
||||
|
||||
# Fallback: check common installation paths
|
||||
possible_exes = [
|
||||
Path(f"C:/Program Files/Siemens/Simcenter3D_{self.nastran_version}/NXBIN/run_journal.exe"),
|
||||
Path(f"C:/Program Files/Siemens/NX{self.nastran_version}/NXBIN/run_journal.exe"),
|
||||
Path(f"C:/Program Files/Siemens/DesigncenterNX{self.nastran_version}/NXBIN/run_journal.exe"),
|
||||
]
|
||||
|
||||
for exe in possible_exes:
|
||||
if exe.exists():
|
||||
return exe
|
||||
|
||||
# Return first guess (will error in __init__ if doesn't exist)
|
||||
return possible_exes[0]
|
||||
# Return the direct path (will error in __init__ if doesn't exist)
|
||||
return self.nx_install_dir / "NXBIN" / "run_journal.exe" if self.nx_install_dir else possible_exes[0]
|
||||
|
||||
def _find_solver_executable(self) -> Path:
|
||||
"""Find the Nastran solver executable."""
|
||||
@@ -440,9 +447,35 @@ sys.argv = ['', {argv_str}] # Set argv for the main function
|
||||
# Set up environment for Simcenter/NX
|
||||
env = os.environ.copy()
|
||||
|
||||
# Use existing SPLM_LICENSE_SERVER from environment if set
|
||||
# Only set if not already defined (respects user's license configuration)
|
||||
if 'SPLM_LICENSE_SERVER' not in env or not env['SPLM_LICENSE_SERVER']:
|
||||
# Get SPLM_LICENSE_SERVER - prefer system registry (most up-to-date) over process env
|
||||
license_server = ''
|
||||
|
||||
# First try system-level environment (Windows registry) - this is the authoritative source
|
||||
import subprocess as sp
|
||||
try:
|
||||
result = sp.run(
|
||||
['reg', 'query', 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment', '/v', 'SPLM_LICENSE_SERVER'],
|
||||
capture_output=True, text=True, timeout=5
|
||||
)
|
||||
if result.returncode == 0:
|
||||
# Parse: " SPLM_LICENSE_SERVER REG_SZ value"
|
||||
for line in result.stdout.splitlines():
|
||||
if 'SPLM_LICENSE_SERVER' in line:
|
||||
parts = line.split('REG_SZ')
|
||||
if len(parts) > 1:
|
||||
license_server = parts[1].strip()
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Fall back to process environment if registry query failed
|
||||
if not license_server:
|
||||
license_server = env.get('SPLM_LICENSE_SERVER', '')
|
||||
|
||||
if license_server:
|
||||
env['SPLM_LICENSE_SERVER'] = license_server
|
||||
print(f"[NX SOLVER] Using license server: {license_server}")
|
||||
else:
|
||||
env['SPLM_LICENSE_SERVER'] = '29000@localhost'
|
||||
print(f"[NX SOLVER] WARNING: SPLM_LICENSE_SERVER not set, using default: {env['SPLM_LICENSE_SERVER']}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user