Files
Atomizer/examples/check_nx_license.py
Anto01 2729bd3278 feat: Add journal-based NX solver integration for optimization
Implements NX solver integration that connects to running Simcenter3D GUI
to solve simulations using the journal API. This approach handles licensing
properly and ensures fresh output files are generated for each iteration.

**New Components:**
- optimization_engine/nx_solver.py: Main solver wrapper with auto-detection
- optimization_engine/solve_simulation.py: NX journal script for batch solving
- examples/test_journal_optimization.py: Complete optimization workflow test
- examples/test_nx_solver.py: Solver integration tests
- tests/journal_*.py: Reference journal files for NX automation

**Key Features:**
- Auto-detects NX installation and version
- Connects to running NX GUI session (uses existing license)
- Closes/reopens .sim files to force reload of updated .prt files
- Deletes old output files to force fresh solves
- Waits for background solve completion
- Saves simulation to ensure all outputs are written
- ~4 second solve time per iteration

**Workflow:**
1. Update parameters in .prt file (nx_updater.py)
2. Close any open parts in NX session
3. Open .sim file fresh from disk (loads updated .prt)
4. Reload components and switch to FEM component
5. Solve in background mode
6. Save .sim file
7. Wait for .op2/.f06 to appear
8. Extract results from fresh .op2

**Tested:**
- Multiple iteration loop (3+ iterations)
- Files regenerated fresh each time (verified by timestamps)
- Complete parameter update -> solve -> extract workflow

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 12:23:57 -05:00

90 lines
2.2 KiB
Python

"""
Check NX License Configuration
"""
import os
from pathlib import Path
print("="*60)
print("NX LICENSE CONFIGURATION CHECK")
print("="*60)
# Check environment variables
print("\n--- Environment Variables ---")
license_vars = [
'SPLM_LICENSE_SERVER',
'UGII_LICENSE_BUNDLE',
'LM_LICENSE_FILE',
'NX_LICENSE_FILE',
]
for var in license_vars:
value = os.environ.get(var)
if value:
print(f"{var} = {value}")
else:
print(f"{var} = (not set)")
# Check license server files
print("\n--- License Server Files ---")
possible_license_files = [
Path("C:/Program Files/Siemens/License Server/ugslmd.opt"),
Path("C:/Program Files/Siemens/License Server/server.lic"),
Path("C:/Program Files (x86)/Siemens/License Server/ugslmd.opt"),
]
for lic_file in possible_license_files:
if lic_file.exists():
print(f" ✓ Found: {lic_file}")
else:
print(f" ✗ Not found: {lic_file}")
# Check NX installation licensing
print("\n--- NX Installation License Info ---")
nx_dirs = [
Path("C:/Program Files/Siemens/NX2412"),
Path("C:/Program Files/Siemens/Simcenter3D_2412"),
]
for nx_dir in nx_dirs:
if nx_dir.exists():
print(f"\n{nx_dir.name}:")
license_file = nx_dir / "ugslmd.lic"
if license_file.exists():
print(f" ✓ License file: {license_file}")
else:
print(f" ✗ No ugslmd.lic found")
print("\n" + "="*60)
print("RECOMMENDATIONS:")
print("="*60)
print("""
1. If you see SPLM_LICENSE_SERVER:
- License server is configured ✓
2. If no environment variables are set:
- You may need to set SPLM_LICENSE_SERVER
- Format: port@hostname (e.g., 28000@localhost)
- Or: path to license file
3. Common fixes:
- Set environment variable in Windows:
setx SPLM_LICENSE_SERVER "28000@your-license-server"
- Or use license file:
setx SPLM_LICENSE_FILE "C:\\path\\to\\license.dat"
4. For local/node-locked license:
- Check License Server is running
- Services → Siemens License Server should be running
5. For network license:
- Verify license server hostname/IP
- Check port (usually 28000)
- Verify firewall allows connection
""")