Summary of "Community Conversations: NXOpen - FAQs, examples, and Python tips & tricks"
Overview
This document summarizes the “Community Conversations: NXOpen” quarterly enablement session. The session covered NXOpen (NX Open) FAQs, example applications, Python tips & tricks, live demos, and a Q&A.
Session purpose
- Provide practical guidance on NXOpen Python usage, common pitfalls, and example automations.
- Demonstrate live demos and answer community questions.
- Share example code, stub files, and reference links (slides and recording to be posted).
Where to find materials
- Recording and slides will be posted to the NX (Siemens) community/forum shortly after the session.
- The speaker provided additional stub files, examples and links (including GitHub); slides will include those links.
Key technical topics and product features
Running NX journals headless
- Use
journal.pywith arguments (quote paths that contain spaces). The same principles apply as with other languages. - Headless graphical drawing/screenshots require enabling headless graphics; additional licensing may be required for Linux/batch servers.
Console / interactive input
- There is no built-in IPython-like interactive console for NXOpen Python by default.
- An anonymous community contributor reportedly implemented a socket-based console hack; the speaker may demo it if the contributor surfaces.
Using external Python packages
- NX’s built-in Python supports Tkinter out-of-the-box.
- To use packages like NumPy or requests, configure an external interpreter (documented in the NX annex docs). The speaker has a recorded advanced course showing the setup.
GUI development inside NX
- Block Styler supports Python and is recommended for complex UIs; it requires an additional license.
- NX has limited built-in input/output selection without Block Styler; custom UIs can also be created externally.
Parallel processing / threading
- NX journaling is inherently single-threaded; parallelization is limited and is not a core journaling feature. Forum discussion can add nuance for specific approaches.
Stub files & IntelliSense
- Siemens provides stub (
.pyi) files starting from NX 2406/2412 if the “programming tools” option is checked during installation. - Community- or speaker-provided stub files can be copied into the stubs folder to improve IntelliSense for NXOpen APIs and for older NX releases.
- Be aware that .NET API names can differ from Python wrappers (for example,
.NET "Model"vs Pythonmodeling); consult Python docs when IntelliSense differs.
Debugging
- Standard Python debuggers like
pdborweb-pdbcan be used. - The speaker often uses the NX listing window for quick debugging (legacy habit).
IDEs and Python versions
- Any IDE can be used; the speaker prefers VS Code (PyCharm is also recommended).
- NX bundles its own Python interpreter; the exact external interpreter version matters less for journaling because NX executes the scripts. A short journal that prints the runtime executable/version is useful when needed.
Licensing and distribution
- For personal or internal use (not distributing code), Python usage is permitted without extra license.
- Distributing NXOpen Python code to others requires an NX author (or “open author”) license. Siemens enforces licensing.
- Python scripts are typically distributed as source. Obfuscation tools exist but are imperfect.
Teamcenter integration
- Additional login/connection code is required when using Teamcenter; file path syntax differs.
- Once connected, core NXOpen operations (open/save, modify attributes) work the same.
Linux / Batch
- NX batch (headless) runs on certain Linux distributions (e.g., CentOS/RedHat) with GUI disabled; additional licensing is typically required for Linux batch runs.
Examples and real-world automation shown
Admin / bookkeeping
- Extract points/coordinates for export to custom formats.
- Clean unused materials/constraints.
- Compute sheet body dimensions across assemblies.
CAD/legacy conversion and reconstruction
- Convert historical title blocks and drawings to new formats.
- Reconstruct parametric sketch/extrude geometry from imported models (example demo by Polymath showed regenerating editable NX features from other CAD sources).
Simulation / Simcenter integration
- Read Simcenter 3D simulation results, extract element/node data, perform buckling checks, and run calculations in scaled cloud instances.
- Write results back for visualization in Simcenter.
- NXOpen TSC (pre/post-processing) capabilities used: mesh creation, constraints, solver sets, result manipulation, and screenshots.
Batch processing
- Open many parts, run geometry queries (intersections), export intersection properties, and write reports.
Practical tools / UI examples
- Embed Excel on drawings, allow editing via a button, and export a screenshot/table onto the drawing (preserving colors).
- Create templated assembly structures via a UI with department-specific options.
- Color-code body types (e.g., convergent vs. solid) and assemblies.
- Convert all bodies in a part into separate components and build an assembly for concept modeling, with an accompanying Excel mapping for names.
Medical / convergent geometry examples
- Generate a centerline of convergent (triangulated/STL) bodies (e.g., bone from CT) using plane slices, cross-section centroids, and spline fitting.
- Create surgical guides: automated curve placement, implicit surface regeneration, and printing text on curved surfaces for surgical orientation (examples used in real surgeries; demo from Amsterdam team).
Tips & Tricks (practical coding advice)
Improving IntelliSense in loops
- Use typing and list comprehensions: cast collections to a typed list (e.g.,
List[nxopen.body]) so the IDE knows element types. - Predefine loop variables with type hints before using them.
- Create wrapper functions that return typed objects so IntelliSense can infer return types.
Calling NXOpen (.NET / native) functions from Python
- Native functions are exposed via Python wrappers and may have different module names; consult the docs.
- Functions that use pass-by-reference in C/C++/.NET typically return tuples in Python—out args are included in the returned tuple.
- Community stub files can help with accurate IntelliSense for these wrappers.
Enumerations (enum handling)
- NXOpen enums often print as integers. Create helper methods to map enum objects/integers to human-readable names and to map strings back to enum objects.
- Speaker provided reusable helpers for converting between enum int, enum object, and readable names.
Logging
- Use Python’s
loggingmodule and add handlers to control console/listing-window output formats (timestamp, module, level).
Resources, guides, tutorials, and sample code
- NX community / NXOpen forum — recordings and thread discussions.
- NXOpen Python reference guide (Siemens documentation and annex docs on external interpreter setup).
- Speaker’s GitHub: NXOpen DSC (automation library) — open-source wrappers and utilities used in examples.
- Speaker’s Udemy courses:
- Beginner NXOpen + Python course (coupon provided during the event).
- Advanced NXOpen topics (external interpreter setup, web-pdb, advanced patterns).
- Community-distributed stub files for legacy NX releases (available from the speaker’s post).
- Polymath demo/tool for regenerating parametric NX features from other CAD data.
Q&A highlights (selected)
- Session recordings and slides will be posted to the forum within a few days.
- Headless/batch runs on Linux are possible (GUI-less) but require correct licensing.
- External interpreter support enables use of NumPy, requests, etc.; a demo was suggested for a future session.
- Block Styler is recommended for complex dialogs (Python-capable) but requires a license.
- Debugging options:
web-pdb,pdb, or the NX listing window. - IDE choice is personal; VS Code was recommended by the speaker.
- Handling recorded
find_objectsidentifiers: recordings often yield journals with recorded IDs. A common approach is to retrieve all candidate bodies and identify the target by attributes (color, size, name, metadata).
Main speakers and contributors
- Taryn Blake — host; Community Engagement Program Manager, Siemens PLM community.
- Frederick von He (presented as “Frederick von he”) — speaker; independent developer, NXOpen / Simcenter automation expert, author of NXOpen Python materials and courses.
Other referenced contributors / sources
- Jim Bernhardt — quoted regarding licensing.
- Anonymous community contributor — socket-based interactive console hack.
- Various forum participants (examples: Joe Caprio, Roberto, Pablo) who contributed during the Q&A.
Category
Technology
Share this summary
Is the summary off?
If you think the summary is inaccurate, you can reprocess it with the latest model.
Preparing reprocess...