Information of selected object on the status bar

Hi guys,

Imagine you want to insert a point feature in NX. When you select the appropriate command and move your cursor in the graphics window, you will notice the status bar changes with the info of the object you're on. For example "Midpoint - Edge of Extrude(4)". It also displays the same in a balloon tip close to your cursor.

This is what I want to mimic with a journal (output of that info to listing window for example.

Unfortunately journal recorder does not help much on that situation

Any ideas ?

This is an interesting question. I know of functions in the API to get the selected object or get a selected point; but not both at once. For example, the .SelectTaggedObject method will give you a reference to the selected object and it will give you the coordinates of the cursor when the object was picked (assuming it was picked and not selected by name). However, the cursor coordinates by itself does not tell you if the object was selected near an end point or mid point (etc), you'd have to calculate that yourself. The .PointSubfunction method will let you pick a point and it will report the selection method used (end point, point on curve, etc) but it will not report the object that the point was on.

If you have access to the BlockStyler application, there might be a selection block that provides both pieces of information. I don't currently have access to the BlockStyler, so I can't say for sure.

Actually I am using UI Block Styler to implement this. But I can't find any method or function to get this from the block class. The class is NXOpen.BlockStyler.SpecifyPoint and the only function it has is GetSelectedObjects() As NXOpen.TaggedObject()
Here is the output from the BlockStyler application.


'==============================================================================
' WARNING!! This file is overwritten by the Block UI Styler while generating
' the automation code. Any modifications to this file will be lost after
' generating the code again.
'
'
' This file was generated by the NX Block UI Styler
' Created by:
' Version: NX 10
' Date: 06-02-2017 (Format: mm-dd-yyyy)
' Time: 11:51 (Format: hh-mm)
'
'==============================================================================

'==============================================================================
' Purpose: This TEMPLATE file contains VB.NET source to guide you in the
' construction of your Block application dialog. The generation of your
' dialog file (.dlx extension) is the first step towards dialog construction
' within NX. You must now create a NX Open application that
' utilizes this file (.dlx).
'
' The information in this file provides you with the following:
'
' 1. Help on how to load and display your Block UI Styler dialog in NX
' using APIs provided in NXOpen.BlockStyler namespace
' 2. The empty callback methods (stubs) associated with your dialog items
' have also been placed in this file. These empty methods have been
' created simply to start you along with your coding requirements.
' The method name, argument list and possible return values have already
' been provided for you.
'==============================================================================

'------------------------------------------------------------------------------
'These imports are needed for the following template code
'------------------------------------------------------------------------------
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.BlockStyler

'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class PointSelectionBlockUI
'class members
Private Shared theSession As Session
Private Shared theUI As UI
Private theDlxFileName As String
Private theDialog As NXOpen.BlockStyler.BlockDialog
Private group0 As NXOpen.BlockStyler.Group' Block type: Group
Private point0 As NXOpen.BlockStyler.SpecifyPoint' Block type: Specify Point
'------------------------------------------------------------------------------
'Bit Option for Property: SnapPointTypesEnabled
'------------------------------------------------------------------------------
Public Shared ReadOnly Dim SnapPointTypesEnabled_UserDefined As Integer = 1
Public Shared ReadOnly Dim SnapPointTypesEnabled_Inferred As Integer = 2
Public Shared ReadOnly Dim SnapPointTypesEnabled_ScreenPosition As Integer = 4
Public Shared ReadOnly Dim SnapPointTypesEnabled_EndPoint As Integer = 8
Public Shared ReadOnly Dim SnapPointTypesEnabled_MidPoint As Integer = 16
Public Shared ReadOnly Dim SnapPointTypesEnabled_ControlPoint As Integer = 32
Public Shared ReadOnly Dim SnapPointTypesEnabled_Intersection As Integer = 64
Public Shared ReadOnly Dim SnapPointTypesEnabled_ArcCenter As Integer = 128
Public Shared ReadOnly Dim SnapPointTypesEnabled_QuadrantPoint As Integer = 256
Public Shared ReadOnly Dim SnapPointTypesEnabled_ExistingPoint As Integer = 512
Public Shared ReadOnly Dim SnapPointTypesEnabled_PointonCurve As Integer = 1024
Public Shared ReadOnly Dim SnapPointTypesEnabled_PointonSurface As Integer = 2048
Public Shared ReadOnly Dim SnapPointTypesEnabled_PointConstructor As Integer = 4096
Public Shared ReadOnly Dim SnapPointTypesEnabled_TwocurveIntersection As Integer = 8192
Public Shared ReadOnly Dim SnapPointTypesEnabled_TangentPoint As Integer = 16384
Public Shared ReadOnly Dim SnapPointTypesEnabled_Poles As Integer = 32768
Public Shared ReadOnly Dim SnapPointTypesEnabled_BoundedGridPoint As Integer = 65536
Public Shared ReadOnly Dim SnapPointTypesEnabled_FacetVertexPoint As Integer = 131072
'------------------------------------------------------------------------------
'Bit Option for Property: SnapPointTypesOnByDefault
'------------------------------------------------------------------------------
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_UserDefined As Integer = 1
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_Inferred As Integer = 2
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_ScreenPosition As Integer = 4
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_EndPoint As Integer = 8
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_MidPoint As Integer = 16
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_ControlPoint As Integer = 32
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_Intersection As Integer = 64
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_ArcCenter As Integer = 128
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_QuadrantPoint As Integer = 256
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_ExistingPoint As Integer = 512
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_PointonCurve As Integer = 1024
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_PointonSurface As Integer = 2048
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_PointConstructor As Integer = 4096
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_TwocurveIntersection As Integer = 8192
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_TangentPoint As Integer = 16384
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_Poles As Integer = 32768
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_BoundedGridPoint As Integer = 65536
Public Shared ReadOnly Dim SnapPointTypesOnByDefault_FacetVertexPoint As Integer = 131072

#Region "Block Styler Dialog Designer generator code"
'------------------------------------------------------------------------------
'Constructor for NX Styler class
'------------------------------------------------------------------------------
Public Sub New()
Try

theSession = Session.GetSession()
theUI = UI.GetUI()
theDlxFileName = "PointSelectionBlockUI.dlx"
theDialog = theUI.CreateDialog(theDlxFileName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddOkHandler(AddressOf ok_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddCancelHandler(AddressOf cancel_cb)
theDialog.AddFilterHandler(AddressOf filter_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)

Catch ex As Exception

'---- Enter your exception handling code here -----
Throw ex
End Try
End Sub
#End Region

'------------------------------- DIALOG LAUNCHING ---------------------------------
'
' Before invoking this application one needs to open any part/empty part in NX
' because of the behavior of the blocks.
'
' Make sure the dlx file is in one of the following locations:
' 1.) From where NX session is launched
' 2.) $UGII_USER_DIR/application
' 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
' recommended. This variable is set to a full directory path to a file
' containing a list of root directories for all custom applications.
' e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
'
' You can create the dialog using one of the following way:
'
' 1. Journal Replay
'
' 1) Replay this file through Tool->Journal->Play Menu.
'
' 2. USER EXIT
'
' 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
' 2) Invoke the Shared Library through File->Execute->NX Open menu.
'
'------------------------------------------------------------------------------
Public Shared Sub Main()
Dim thePointSelectionBlockUI As PointSelectionBlockUI = Nothing
Try

thePointSelectionBlockUI = New PointSelectionBlockUI()
' The following method shows the dialog immediately
thePointSelectionBlockUI.Show()

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
Finally
If thePointSelectionBlockUI IsNot Nothing Then
thePointSelectionBlockUI.Dispose()
thePointSelectionBlockUI = Nothing
End If
End Try
End Sub
'------------------------------------------------------------------------------
' This method specifies how a shared image is unloaded from memory
' within NX. This method gives you the capability to unload an
' internal NX Open application or user exit from NX. Specify any
' one of the three constants as a return value to determine the type
' of unload to perform:
'
'
' Immediately : unload the library as soon as the automation program has completed
' Explicitly : unload the library from the "Unload Shared Image" dialog
' AtTermination : unload the library when the NX session terminates
'
'
' NOTE: A program which associates NX Open applications with the menubar
' MUST NOT use this option since it will UNLOAD your NX Open application image
' from the menubar.
'------------------------------------------------------------------------------
Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
Return CType(Session.LibraryUnloadOption.Immediately, Integer)
' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
End Function
'------------------------------------------------------------------------------
' Following method cleanup any housekeeping chores that may be needed.
' This method is automatically called by NX.
'------------------------------------------------------------------------------
Public Shared Sub UnloadLibrary(ByVal arg As String)
Try

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub

'------------------------------------------------------------------------------
'This method shows the dialog on the screen
'------------------------------------------------------------------------------
Public Sub Show()
Try

theDialog.Show

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub

'------------------------------------------------------------------------------
'Method Name: Dispose
'------------------------------------------------------------------------------
Public Sub Dispose()
If theDialog IsNot Nothing Then
theDialog.Dispose()
theDialog = Nothing
End If
End Sub

'------------------------------------------------------------------------------
'---------------------Block UI Styler Callback Functions--------------------------
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
'Callback Name: initialize_cb
'------------------------------------------------------------------------------
Public Sub initialize_cb()
Try

group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.Group)
point0 = CType(theDialog.TopBlock.FindBlock("point0"), NXOpen.BlockStyler.SpecifyPoint)

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub

'------------------------------------------------------------------------------
'Callback Name: dialogShown_cb
'This callback is executed just before the dialog launch. Thus any value set
'here will take precedence and dialog will be launched showing that value.
'------------------------------------------------------------------------------
Public Sub dialogShown_cb()
Try

'---- Enter your callback code here -----

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub

'------------------------------------------------------------------------------
'Callback Name: apply_cb
'------------------------------------------------------------------------------
Public Function apply_cb() As Integer
Dim errorCode as Integer = 0
Try

'---- Enter your callback code here -----

Catch ex As Exception

'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
apply_cb = errorCode
End Function

'------------------------------------------------------------------------------
'Callback Name: update_cb
'------------------------------------------------------------------------------
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try

If block Is point0 Then
'---- Enter your code here -----

End If

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
update_cb = 0
End Function

'------------------------------------------------------------------------------
'Callback Name: ok_cb
'------------------------------------------------------------------------------
Public Function ok_cb() As Integer
Dim errorCode as Integer = 0
Try

'---- Enter your callback code here -----
errorCode = apply_cb()

Catch ex As Exception

'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
ok_cb = errorCode
End Function

'------------------------------------------------------------------------------
'Callback Name: cancel_cb
'------------------------------------------------------------------------------
Public Function cancel_cb() As Integer
Try

'---- Enter your callback code here -----

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
cancel_cb = 0
End Function

'------------------------------------------------------------------------------
'Callback Name: filter_cb
'------------------------------------------------------------------------------
Public Function filter_cb(ByVal block As NXOpen.BlockStyler.UIBlock, ByVal selectedObject As NXOpen.TaggedObject) As Integer
filter_cb = NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT
End Function

'------------------------------------------------------------------------------
'Function Name: GetBlockProperties
'Returns the propertylist of the specified BlockID
'------------------------------------------------------------------------------
Public Function GetBlockProperties(ByVal blockID As String) As PropertyList
GetBlockProperties = Nothing
Try

GetBlockProperties = theDialog.GetBlockProperties(blockID)

Catch ex As Exception

'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Function

End Class

Here is also the dlx file needed. You can change the theDlxFileName = "PointSelectionBlockUI.dlx" to your absolute path and filename for more convenient test, ie theDlxFileName = "D:\VBnet\Tests\PointSelectionBlockUI.dlx"
Copy and paste it to new file named PointSelectionBlockUI.dlx

<?xml version="1.0" encoding="UTF-8"?>

in your filter callback you can get some information from the selected object (which is the object you are currently hovering over), unfortunately I have only figured out how to get info about the object itself, and not the snap point or the cursor location.
for instance you can do things like:

dim mytype as integer = nothing
dim mysubtype as integer = nothing

theUFSession.obj.AskTypeAndSubtype(selectedobject.tag, mytype, mySubtype)

then you could display text in the status bar or get other types of information about the object.

what I can't figure out is how to get the snap point information, can anyone help with that?