Open C++ Programmer's Guide > Open C++ Classes > Overview
Open C++ Classes: Overview
There are five categories of Open C++ classes:
| Category | Purpose |
|---|---|
| Application Classes | Control the NX application itself. Examples: UgSession, UgInfoWindow, UgException. |
| Object Classes | Define operations on objects residing in an NX part file. Examples: UgArc, UgFace, UgExpression. UgPart (representing the NX part) is also in this category. |
| Template Classes | Before V18, provided platform-independent equivalents of STL classes — mainly arrays (UgArray) and strings (UgString). In V18, standard std::vector and std::string replaced UgArray/UgString (now obsolete). There is also a template class for iterating over Open C++ objects. |
| Helper Classes | Define temporary objects used by other classes. Examples: ThruPoint, Evaluator. |
| Math Classes | General-purpose math objects for use with NX object classes — points, vectors, matrices, coordinate systems. |
Each class is typically defined in its own header file, named after the class
(e.g. UgArc is defined in ug_arc.hxx). A header may also define nested or
helper classes needed by its primary class.
Any public method on an Open C++ class can be called freely. Private methods cannot be called at all; protected methods are only usable from a class you derive.
Application Classes
Session Class
UgSession performs Open C initialization, which must happen before any other
Open C++ method is invoked. Initialization (and termination) can be done two
ways.
Static methods:
UgSession::initalize();
// Your Open C++ code goes here
UgSession::terminate();
Constructing a UgSession object (destructor auto-terminates Open C when
the object goes out of scope):
UgSession mySession ( true );
// Your Open C++ code goes here
Open C initialization can be inhibited by constructing UgSession without the
true argument:
UgSession mySession;
In that case the destructor will not terminate Open C either.
Initializing Open C via UgSession is functionally identical to calling the
traditional Open C function UF_initialize(). At the start of your
application, do one or the other — not both. After that point you can freely
mix Open C++ methods and traditional Open C (UF_ prefixed) routines.
UgSession is also used to control the state/behavior of the current NX
session — e.g. changing the work part, modifying layer status, closing all
parts.
Object Classes
Open C++ classes such as UgArc, UgFace, and UgExpression define
operations on objects that live inside an NX part file. UgPart represents
the NX part itself. Most application code operates on these object classes.
There are two kinds of object classes:
- Base classes — define operations common to related object types; they do
not define a
create()method. - Leaf classes — define operations specific to one object type; most leaf
classes define a
create()method. A leaf class represents one specific kind of NX object, while a base class represents a family of related kinds.
The class hierarchy uses multiple inheritance in some cases to give unrelated object types a common interface.
The root base class for all NX objects is UgObject, which defines methods
common to every NX object — e.g. UgObject::askOwningPart(), returning the
part that owns a given object.
Other base classes derive from UgObject, including UgTypedObject and
UgDisplayableObject (most base classes in Open C++ have names ending in
Object). UgTypedObject provides methods to name and delete NX objects;
UgDisplayableObject provides methods such as blank/unblank, change color,
and layer.
Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.open_c_plus_plus_program · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)