NXKnowledge

NX Open Programmer's Guide > Block Styler Automation > Dialog and Block Properties

Dialog and Block Properties

Every dialog and every block within a dialog have a set of properties which are used to customize and control the block's look and behavior at runtime. In the Block Styler the main dialog shows a tree in the "Blocks" window. The root of the tree references the Dialog. Expanding down from the root are all of the blocks that are in the dialog. Below the "Blocks" window is the "Properties" window — it shows all of the properties for the item selected in the tree. To display the Dialog properties, pick the root of the tree; to display the properties for a specific block, pick that block in the tree.

Every property is defined by its Name, Value, and value Type. For instance, a Dialog has a property named "Cue" which has a value of type String. The value of the Cue property is displayed in the NX Cue line when the dialog is active.

Finding Block Objects by Name

References to all block objects are established in the Initialize callback. The text string used to identify the block is shown in the "Blocks" window of the main Block Styler dialog — these names identify the nodes in the tree used to display and edit the dialog structure. By default these names are constructed from the type of block and a count, such as "button01" or "toggle04". Using these default names the following pseudo-code would be included in the Initialize callback to establish a reference to the button and toggle block objects:

button01 = theDialog.TopBlock.FindBlock("button01")
toggle04 = theDialog.TopBlock.FindBlock("toggle04")

The variables button01 and toggle04 will now reference their respective block objects.

To make these variable names more meaningful for your application, change the names in the Block Styler before generating the template code. For instance, if you renamed the toggle block to "blendOption", the generated Initialize code would use that name instead.

Getting and Setting Properties

Properties are accessed through a PropertyList obtained by calling GetProperties() on a block (or on theDialog.TopBlock for dialog-level properties). The general pattern is:

propertyList = block.GetProperties()
propertyList.Get<Type>(<property name>)
propertyList.Set<Type>(<property name>, ...)

For instance, to Get/Set a Dialog's Cue property:

dialogPropertyList = theDialog.TopBlock.GetProperties()
text = dialogPropertyList.GetString("Cue")
dialogPropertyList.SetString("Cue", "this is the text to display in the cue line")

Another example — getting/setting the current state of a toggle block renamed to blendOption. The current state of a toggle block is contained in the property named "Value":

togglePropertyList = blendOption.GetProperties()
togglePropertyList.SetLogical("Value", True)
toggleValue = togglePropertyList.GetLogical("Value")

NX Open for C++ example

NXOpen::NXString sourceText = sourceStringProp->GetString("Value");
NXOpen::NXString sourceLabel = sourceStringProp->GetString("Label");
// Set the value and label of the target string
targetStringProp->SetString("Label", sourceText);
targetStringProp->SetString("Value", sourceLabel);
// Set the current value of the Integer block and then
// use the current value to set source string value
integerProp->SetInteger("Value", 5);
char textBuff[25];
sprintf_s(textBuff,"%d",integerProp->GetInteger("Value"));
sourceStringProp->SetString("Value", textBuff);
// Disable the target string block
targetStringProp->SetLogical("Enable", false);
// Cleanup memory
delete sourceStringProp;
delete targetStringProp;
delete integerProp;
delete dialogProp;

Note: If a property list reference returned by GetProperties() is not deleted (in C++), then the memory used for the list will be lost until the dialog is closed.

Dialog and Block Properties — Language Specific Details

The doc's language-specific code examples cover accessing and setting: Dialog Cue Line, String Block Label, String Block Current Value, and other block-type-specific properties (Integer, Toggle/Logical, etc.) across NX Open for C++, .NET, and Java. The property accessor pattern (GetProperties() then typed Get<Type>/Set<Type> calls, e.g. GetString/SetString, GetLogical/SetLogical, GetInteger/SetInteger) is identical in shape across all languages; only syntax (pointer -> vs ., explicit delete in C++ vs GC in .NET/Java) differs.

Related Topics

  • Block Styler Automation
  • Block Styler Memory and Callbacks
  • Block Styler Selection Blocks
  • Block Styler Update Callback

Source: https://docs.sw.siemens.com/en-US/doc/209349590/PL20220512394070742.nxopen_prog_guide/block_styler_properties · retrieved 2026-07-07