NXKnowledge

NX Open Programmer's Guide > Creating NX Open Automation > Turning Journals Into Applications

Turning Journals Into Applications

Recorded Journals provide no user interface — replay repeats exactly what was recorded against the exact same named objects. This topic covers modifying a Journal to add a UI so it becomes a general solution, and when to migrate further into a fully compiled/linked application.

Capability comparison

Journal (as recorded) Journal Application (adding UI) Fully Compiled and Linked Application
Source files Single source file Single source file Any number of source files
Object targeting Named objects matching those selected during recording, author-supplied parameters User-selected objects, user-supplied parameters at runtime User-selected objects, user-supplied parameters at runtime
API scope Limited to NX commands that support Journaling All Common API classes supported by .NET libraries linked with NX (see Journal Fundamentals) All Common API classes and any desired .NET class
Startup/event init None None Can auto-load at NX startup; a startup method can register event handlers for dialogs, User Defined Objects, and other runtime options
Licensing Feature based license checking Feature based license checking Author license required during development; signature required before release

QuickExtrude Example

Located at: <NX install directory>\UGOPEN\SampleNXOpenApplications\.NET\QuickExtrude\QuickExtrude.vb

Starts as a recorded Journal that selects an existing sketch and extrudes it a fixed distance. The example modifies the source to prompt for the distance and let the user pick the sketch, with original recorded lines commented out and new UI lines added — illustrating exactly what to remove/add to convert a Journal into an application. A readme in the example folder explains how to identify the diffs.

Adding a User Interface

Original recorded VB lines (fixed values):

extend1.SetValue("0.0")
extend2.SetValue("1.0")

Replaced with an input dialog via NXInputBox:

Dim inputBox As NXInputBox = New NXInputBox
extend1.SetValue(inputBox.GetInputString("Set the Start Limit: ", "Extrude Starting Offset", "0.0"))
extend2.SetValue(inputBox.GetInputString("Set the End Limit: ", "Extrude Ending Offset", "1.0"))

Requires Imports NXOpenUI.

Removing Selection Stickiness

Journals record the exact object names selected during recording (not user intent), so replay only works against those same named objects — "Selection Stickiness." E.g., a Journal blanking datum planes by name fails if replayed in a part file lacking datum planes with those same names.

To remove stickiness in QuickExtrude, a sketch-selection function is added before End Module. Steps: define selection scope, define selection mask, call SelectObject on SelectionManager. Requires Imports NXOpen.UF and Imports NXOpenUI.

Public Function SelectSketch() As Sketch
	Dim ui As UI = ui.GetUI
	Dim message As String = "Select sketch"
	Dim title As String = "Selection"
	Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
	Dim keepHighlighted As Boolean = False
	Dim includeFeatures As Boolean = True
	Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
	Dim selectionMask_array(1) As Selection.MaskTriple
	With selectionMask_array(0)
		.Type = UFConstants.UF_sketch_type
		.Subtype = 0
		.SolidBodySubtype = 0
	End With
	Dim selectedObject As NXObject = Nothing
	Dim cursor As Point3d
	ui.SelectionManager.SelectObject(message, title, scope, _
						selectionAction, includeFeatures, _
						keepHighlighted, selectionMask_array, _
						selectedObject, cursor)
	Dim sketch As Sketch = CType(selectedObject, Sketch)
	If sketch Is Nothing Then
		Return Nothing
	End If
	Return sketch
End Function

Called at the start of the Journal:

Dim sketch1 As Sketch = SelectSketch()
If sketch1 Is Nothing Then
	Return
End If

Replacing FindObject() calls

Original recorded code referenced the specific object name "SKETCH(4)":

' **** Removed Code ****
'Dim sketchFeature1 As Features.SketchFeature = CType(workPart.Features.FindObject("SKETCH(4)"), Features.SketchFeature)
'features1(0) = sketchFeature1

Replaced using the interactively selected sketch:

features1(0) = sketch1.Feature

For the curves used by the extrude section, the recorded code referenced a specific curve name ("Curve Arc1"). Since selection intent was "Feature Curves" (all curves of the selected feature), replace with the first geometry item of the selected sketch:

Dim geoms() As NXObject = sketch1.GetAllGeometry() 'Gets all the geometry objects controlled by the sketch feature
Dim nXObject1 As NXObject = geoms(0) 'first curve; selection intent finds the rest

Then swap the reference in AddToSection:

' **** Removed Code ****
'section1.AddToSection(rules1, arc1, nullNXObject, nullNXObject, helpPoint1, Section.Mode.Create)
' **** Added Code ****
section1.AddToSection(rules1, nXObject1, nullNXObject, nullNXObject, helpPoint1, Section.Mode.Create)

Journal Replay

After the changes, replaying prompts the user to select a sketch, then enter values in "Set Start Limit" / "Set End Limit" input boxes, producing an extrude feature from the selected sketch and entered values.

Deciding When to Compile and Link

  • Compiled/linked applications: full access to the Common API and .NET framework, full access to NX events, NX dialogs, and User Defined Objects. Require an author license, checked at load time during development and required to run the signing utility (see Development Cycle Considerations, Signing Process).
  • Journals: single source file, most (not all) Common API capability, no author license required.
  • Both use feature-based license checking at runtime.
  • Whether to move a Journal to a compiled/linked application depends on the application's complexity and benefit.

Related Topics

  • Journals

Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/turning_journals_into_apps · retrieved Tue Jul 07 2026 00:00:00 GMT+0000 (Coordinated Universal Time)