NX Open Programmer's Guide > Common Object Model (synthesis: Session and UI, plus Session usage across UNDO/redo and journals topics)
The Session Object
NXOpen.Session (together with NXOpen.UI) is described in the Common Object Model overview as the "gateway" class for the API — all other object references in NX Open are obtained directly or indirectly through Session (or through UI, which is only usable when the program runs inside the interactive NX user interface, not in Batch mode).
This page collects everything the Programmer's Guide says about Session, drawn from several pages that each touch a different facet of it.
Session as the entry point
From objectModel.md (Common Object Model): Session and UI are the two "gateway" classes. Everything else — parts, features, expressions, the UI, undo state — is reached by walking down from a Session reference. A typical NX Open program's first line of real work is to obtain the current session (the exact accessor differs by language — e.g. a static/shared property on the Session class itself in most Common API languages).
Session-level state and session-scoped operations documented in this book
Several session-scoped capabilities are documented as methods directly on Session:
Undo Marks (Session.SetUndoMark / DeleteUndoMark / UndoToMark)
The UNDO methods let a program checkpoint and roll back NX/part state:
NXOpen::Session::UndoMarkId myMark;
myMark = theSession->SetUndoMark(NXOpen::Session::MarkVisibilityInvisible, "markName");
// ... do work ...
theSession->DeleteUndoMark(myMark, "markName"); // success path
theSession->UndoToMark(myMark, "markName"); // error-recovery path
Session.SetUndoMark(MarkVisibility, markName)returns anUndoMarkId.Session.MarkVisibility.Invisible— hides the mark from the user's UNDO menu (used for internal error recovery); the visible counterpart exposes it in the UNDO list for the user to invoke directly.- The number of active UNDO marks in NX is capped at 200; older marks are recycled once the limit is hit.
See update-manager-and-undo.md for the full treatment, including the Python/legacy-UF equivalents.
Redo control (Session.EnableRedo)
Redo is implemented by recording NX Open function calls and replaying them after an undo. Only NX Open (not UF) calls are recorded, and only the recorded functions' internal actions are redone — not any surrounding program logic. Because recording many calls can be expensive, and because some operations cannot be correctly redone by pure function replay, Session.EnableRedo lets a program disable redo recording around such operations. See update-manager-and-undo.md.
Session as the root for UF interop
From wrappers.md: to call into the wrapped Open C (UF) API from .NET, Java, or Python, you first obtain a UFSession instance (a session-scoped object parallel to Session but specifically for the UF wrapper layer). Each Open C module's wrapper class is then exposed as a method on UFSession — e.g. .curve() returns a UFCurve instance whose methods wrap the UF_CURVE_* functions. This is a second, UF-specific "session" concept that sits alongside the main NXOpen.Session.
Session in Block Styler dialogs
Generated Block Styler template code holds a reference to the session's UI (via theUI) for showing message boxes, e.g.:
testBlockDialog::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what());
This confirms the pattern described above: even generated dialog code reaches NX-wide services (NXMessageBox) by going through the session's UI gateway object rather than holding any other global state. See blockstyler-launching-dialogs.md.
What this book does not cover about Session
This Programmer's Guide does not include a dedicated "Session class reference" page enumerating every property/method (e.g. Session.Parts, Session.ListingWindow, licensing/version properties, etc.) — that level of detail lives in the language-specific NX Open API references (nxopen-cpp-reference, nxopen-dotnet-reference, nxopen-java-reference, nxopen-python-reference), covered separately. This page captures only what the Programmer's Guide itself documents about Session's role and the specific Session methods it walks through in worked examples.
Related Topics
- Common Object Model (
objectModel.md) - UNDO / NX Open and redo (
update-manager-and-undo.md) - Wrappers (
wrappers.md) - Block Styler Automation