- Restructure docs/ folder (remove numeric prefixes): - 04_USER_GUIDES -> guides/ - 05_API_REFERENCE -> api/ - 06_PHYSICS -> physics/ - 07_DEVELOPMENT -> development/ - 08_ARCHIVE -> archive/ - 09_DIAGRAMS -> diagrams/ - Replace tagline 'Talk, don't click' with 'LLM-driven optimization framework' in 9 files - Create comprehensive docs/GETTING_STARTED.md: - Prerequisites and quick setup - Project structure overview - First study tutorial (Claude or manual) - Dashboard usage guide - Neural acceleration introduction - Rewrite docs/00_INDEX.md with correct paths and modern structure - Archive obsolete files: - 01_PROTOCOLS.md -> archive/historical/01_PROTOCOLS_legacy.md - 03_GETTING_STARTED.md -> archive/historical/ - ATOMIZER_PODCAST_BRIEFING.md -> archive/marketing/ - Update timestamps to 2026-01-20 across all key files - Update .gitignore to exclude docs/generated/ - Version bump: ATOMIZER_CONTEXT v1.8 -> v2.0
8.1 KiB
NXOpen Python Intellisense Setup
Status: ✅ Implemented (2025-11-17)
Enable intelligent code completion for NXOpen Python API using Siemens-provided stub files
Overview
Siemens NX 2412 includes Python stub files (.pyi) that provide full type hints for the NXOpen API. These enable:
- Autocomplete: Suggestions for classes, methods, and properties
- Type Hints: Parameter types and return values
- Documentation: Inline docstrings and API descriptions
- Error Detection: Type checking catches errors before runtime
This dramatically improves development speed and reduces NXOpen API lookup time.
Prerequisites
- Siemens NX 2412 (or later) installed with Programming Tools
- VSCode with Pylance extension (usually installed with Python extension)
- Python 3.11 environment (required for NXOpen module compatibility)
Setup Instructions
Step 0: Ensure Python 3.11 Environment
NXOpen modules are compiled for Python 3.11. You must use Python 3.11:
# Check your Python version
python --version # Should show: Python 3.11.x
# If using conda, upgrade atomizer environment:
conda install -n atomizer python=3.11 -y
Step 1: Add NXOpen to Python Path
Create a .pth file in your Python environment's site-packages to enable NXOpen imports:
# For atomizer environment:
# Create file: C:\Users\<username>\anaconda3\envs\atomizer\Lib\site-packages\nxopen.pth
# Contents:
C:\Program Files\Siemens\NX2412\NXBIN\python
This allows import NXOpen to work in your Python scripts!
Step 2: Verify Stub Files Exist
Check that stub files are installed:
# Windows path:
dir "C:\Program Files\Siemens\NX2412\UGOPEN\pythonStubs\NXOpen"
# Should show: __init__.pyi and many module folders (CAE, Assemblies, etc.)
If missing: Reinstall NX 2412 and ensure "Programming Tools" is checked during installation.
Step 3: Configure VSCode
Update .vscode/settings.json in your Atomizer project:
{
"python.analysis.typeCheckingMode": "basic",
"python.analysis.stubPath": "C:\\Program Files\\Siemens\\NX2412\\UGOPEN\\pythonStubs"
}
Note: Use double backslashes (\\) in Windows paths for JSON.
Step 4: Restart VSCode
Close and reopen VSCode to load the new stub files.
Step 5: Verify NXOpen Import and Intellisense Works
First, test that NXOpen can be imported:
python
>>> import NXOpen
>>> print("Success! NXOpen is available")
>>> exit()
Then test intellisense:
Open tests/test_nxopen_intellisense.py and verify:
-
Import Autocomplete:
- Type
import NXOpen.→ Should suggest: Part, Session, CAE, Assemblies, etc.
- Type
-
Method Autocomplete:
- Type
session.→ Should suggest: GetSession(), Parts, etc. - Type
expressions.→ Should suggest: FindObject, CreateExpression, etc.
- Type
-
Parameter Hints:
- Hover over
CreateExpression()→ Shows parameter types and documentation
- Hover over
-
Documentation Tooltips:
- Hover over any NXOpen class/method → Shows docstring
If working: ✅ Intellisense is configured correctly!
What You Get
Before Intellisense:
import NXOpen
session = NXOpen.Session.GetSession()
# ❌ No suggestions when typing "session."
# ❌ No parameter hints for methods
# ❌ Must look up API in documentation
After Intellisense:
import NXOpen
session = NXOpen.Session.GetSession()
# ✅ Type "session." → See: Parts, ListingWindow, LogFile, etc.
# ✅ Type "session.Parts." → See: Work, Display, FindObject, etc.
# ✅ Hover over methods → See parameter types and documentation
# ✅ Catch type errors before running code
Available Modules
The stub files cover all NXOpen modules:
Core Modules:
NXOpen.Session- NX session managementNXOpen.Part- Part objects and operationsNXOpen.Assemblies- Assembly operations
CAE Modules:
NXOpen.CAE- Finite element analysisNXOpen.CAE.FemPart- FEM modelsNXOpen.CAE.SimSolution- Solutions and solver control
Design Modules:
NXOpen.Features- Parametric featuresNXOpen.Sketches- Sketch operationsNXOpen.Modeling- Modeling operations
And many more: Drafting, Display, Motion, Optimization, etc.
Example: Using Intellisense During Development
Scenario: Update Part Expression
Without Intellisense (manual lookup required):
# 1. Google: "NXOpen get expression"
# 2. Find documentation
# 3. Copy method signature
# 4. Hope you got it right
work_part.Expressions.FindObject("tip_thickness")
With Intellisense (guided development):
# 1. Type "work_part.Exp" → Autocomplete suggests "Expressions"
# 2. Type "work_part.Expressions." → See all methods
# 3. Select "FindObject" → See parameter types
# 4. Hover for documentation
work_part.Expressions.FindObject("tip_thickness") # ✅ Correct!
Benefits for Atomizer Development
1. Faster Development
- No context switching to documentation
- Discover APIs as you type
- Reduce typos and API misuse
2. Better Code Quality
- Type checking catches errors early
- Method signatures documented inline
- Parameter validation before runtime
3. LLM-Assisted Coding
When using Claude Code to develop Atomizer:
- Claude can "see" NXOpen API structure via stub files
- Better code generation suggestions
- Reduced hallucination of API methods
4. Onboarding
- New contributors learn NXOpen API faster
- Inline documentation reduces learning curve
- Explore API without leaving IDE
Integration with Atomizer Workflow
Journal Script Development
When writing NX journal scripts (optimization_engine/solve_simulation.py):
import NXOpen
theSession = NXOpen.Session.GetSession()
workPart = theSession.Parts.Work
# Intellisense shows:
# - workPart.Expressions.FindObject(...)
# - workPart.Expressions.EditWithUnits(...)
# - workPart.Update()
# - workPart.Save(...)
LLM Code Generation
When LLM generates NXOpen code, stub files help:
- Validate generated code against actual API
- Suggest corrections for API misuse
- Provide parameter type hints
Future: NXOpen Documentation Integration
This is Step 1 of NXOpen integration. Future work:
- ✅ Stub files for intellisense (current)
- 🔜 Documentation scraping for LLM knowledge base
- 🔜 Authenticated docs access for latest API references
- 🔜 LLM-generated journal scripts with validation
Troubleshooting
Intellisense Not Working
Problem: No autocomplete suggestions appear
Solutions:
- Check Pylance Extension: VSCode → Extensions → Search "Pylance" → Ensure installed
- Verify Settings:
.vscode/settings.jsonhas correct stub path - Check Python Interpreter: VSCode bottom-left → Select correct Python environment
- Restart VSCode: Close all windows and reopen
- Check Stub Path: Ensure path exists and contains
NXOpenfolder
Wrong Suggestions
Problem: Autocomplete shows incorrect or outdated methods
Solution: Ensure stub files match your NX version:
- NX 2412 → Use
NX2412\ugopen\pythonStubs - Different NX version → Update stub path in settings
Type Errors Shown
Problem: Pylance shows type errors for valid code
Solutions:
- Set
"python.analysis.typeCheckingMode": "basic"(not "strict") - Add
# type: ignorefor false positives - Update stub files if using newer NX version
References
- Siemens NX Documentation: PLM Portal
- TheScriptingEngineer: Blog with NXOpen examples
- Pylance Documentation: VSCode Python
Next Steps
Now that intellisense is configured:
- Try It: Open
tests/test_nxopen_intellisense.pyand explore - Develop Faster: Use autocomplete when writing journal scripts
- Contribute: Help improve Atomizer's NXOpen integration
See: DEVELOPMENT_GUIDANCE.md for strategic roadmap including NXOpen documentation access.
Implemented By: Antoine Letarte Date: 2025-11-17 NX Version: 2412 Status: Production Ready