diff --git a/docs/NXOPEN_INTELLISENSE_SETUP.md b/docs/NXOPEN_INTELLISENSE_SETUP.md index 029b78b6..479768e8 100644 --- a/docs/NXOPEN_INTELLISENSE_SETUP.md +++ b/docs/NXOPEN_INTELLISENSE_SETUP.md @@ -23,43 +23,79 @@ This dramatically improves development speed and reduces NXOpen API lookup time. - **Siemens NX 2412** (or later) installed with Programming Tools - **VSCode** with **Pylance extension** (usually installed with Python extension) -- **Python 3.10+** environment +- **Python 3.11** environment (required for NXOpen module compatibility) --- ## Setup Instructions -### Step 1: Verify Stub Files Exist +### Step 0: Ensure Python 3.11 Environment + +NXOpen modules are compiled for Python 3.11. **You must use Python 3.11**: + +```bash +# 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: + +```bash +# For atomizer environment: +# Create file: C:\Users\\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: ```bash # Windows path: -dir "C:\Program Files\Siemens\Simcenter3D_2412\ugopen\pythonStubs\NXOpen" +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 2: Configure VSCode +### Step 3: Configure VSCode Update `.vscode/settings.json` in your Atomizer project: ```json { "python.analysis.typeCheckingMode": "basic", - "python.analysis.stubPath": "C:\\Program Files\\Siemens\\Simcenter3D_2412\\ugopen\\pythonStubs" + "python.analysis.stubPath": "C:\\Program Files\\Siemens\\NX2412\\UGOPEN\\pythonStubs" } ``` **Note**: Use double backslashes (`\\`) in Windows paths for JSON. -### Step 3: Restart VSCode +### Step 4: Restart VSCode Close and reopen VSCode to load the new stub files. -### Step 4: Verify Intellisense Works +### Step 5: Verify NXOpen Import and Intellisense Works + +First, test that NXOpen can be imported: + +```python +python +>>> import NXOpen +>>> print("Success! NXOpen is available") +>>> exit() +``` + +Then test intellisense: Open `tests/test_nxopen_intellisense.py` and verify: