Cleaned NXOpen Python API stubs for Pylance.
NXOpen/NXOpenUI/scripts/clean_nxopen_stubs.pyNXOpen_stub_cleanup.md
These stubs are cleaned from generated NXOpen API output so they are easier for Pylance to consume.
The cleanup focuses on:
- invalid identifiers and generated syntax artifacts
- broken annotation forms such as
anyorTag[] - static method inference for APIs like
Session.GetSession() - converting annotated members to property form for more stable chained type inference
Thanks to the original stub provider, theScriptingEngineer / Frederik Vanhee, for publishing the original NXOpen Python Intellisense stubs and usage notes in the Siemens Community post:
This repository publishes a cleaned and Pylance-friendly derivative of that stub set.
Point python.analysis.stubPath to the directory that contains NXOpen/ and NXOpenUI/.
examples/traverse_all_components.py: recursively traverses all assembly components from the work part root component and writes the result to the NX Listing Window.examples/component_body_spatial_matrix.py: collects per-body geometry data and builds a tuple-indexed 3D spatial matrix such asmatrix[0, 1, 1], with automatic grid sizing derived from the body data and optional per-component manual grid-size overrides. External scripts can passgrid_size_overridesdirectly tobuild_component_spatial_matrices(...)or useset_component_grid_size_overrides(...)to build and normalize an updated overrides mapping without mutating global state.examples/highlight_component_body_by_journal_identifier.py: finds a body occurrence from a component JournalIdentifier and a body JournalIdentifier, then highlights that body in the assembly.
If you regenerate the raw NXOpen files, rerun:
python scripts/clean_nxopen_stubs.py <raw_stub_root> <clean_output_root>More detail is in NXOpen_stub_cleanup.md.