Skip to content

Latest commit

 

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NXOpenPythonStub

Cleaned NXOpen Python API stubs for Pylance.

Contents

  • NXOpen/
  • NXOpenUI/
  • scripts/clean_nxopen_stubs.py
  • NXOpen_stub_cleanup.md

Purpose

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 any or Tag[]
  • static method inference for APIs like Session.GetSession()
  • converting annotated members to property form for more stable chained type inference

Acknowledgements

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.

Pylance

Point python.analysis.stubPath to the directory that contains NXOpen/ and NXOpenUI/.

Examples

  • 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 as matrix[0, 1, 1], with automatic grid sizing derived from the body data and optional per-component manual grid-size overrides. External scripts can pass grid_size_overrides directly to build_component_spatial_matrices(...) or use set_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.

Regeneration

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.

About

NXOpen Python API Stub

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages