Ehaviv
Computer
- Jul 2, 2003
- 1,012
Hi
The atached Blockstyler journal not react as expected.
The Ok and the Apply buttons not become active as expected.
theDlxFileName = "C:\MarkBrdComponents.dlx"
The atached Blockstyler journal not react as expected.
The Ok and the Apply buttons not become active as expected.
theDlxFileName = "C:\MarkBrdComponents.dlx"
Code:
'==============================================================================
' 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.
'
' Filename: C:\MarkBrdComponents.vb
'
' This file was generated by the NX Block UI Styler
' Created by: me
' Version: NX 11
' Date: 07-25-2018 (Format: mm-dd-yyyy)
' Time: 13:25 (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 MarkBrdComponents
'class members
Private Shared theSession As Session
Private Shared theUI As UI
Private theDlxFileName As String
Private theDialog As NXOpen.BlockStyler.BlockDialog
Private myDialog As NXOpen.BlockStyler.Group' Block type: Group
Private grpCompsMarks As NXOpen.BlockStyler.Group' Block type: Group
Private facecollectorBrdFace As NXOpen.BlockStyler.FaceCollector' Block type: Face Collector
Private bodycollectorCompBody As NXOpen.BlockStyler.BodyCollector' Block type: Body Collector
Private multilinestringShowText As NXOpen.BlockStyler.MultilineString' Block type: Multiline String
Private objectcolorpickerMarkColor As NXOpen.BlockStyler.ObjectColorPicker' Block type: Color Picker
Private grpMarkSearch As NXOpen.BlockStyler.Group' Block type: Group
Private stringSearchText As NXOpen.BlockStyler.StringBlock' Block type: String
Private objectcolorpickerSearchColor As NXOpen.BlockStyler.ObjectColorPicker' Block type: Color Picker
Private actionbuttonMarkSearch As NXOpen.BlockStyler.Button' Block type: Button
Private markClearAll As NXOpen.BlockStyler.Group' Block type: Group
Private btnSwitch As NXOpen.BlockStyler.Button' Block type: Button
#Region "Block Styler Dialog Designer generator code"
'------------------------------------------------------------------------------
'Constructor for NX Styler class
'------------------------------------------------------------------------------
Public Sub New()
Try
theSession = Session.GetSession()
theUI = UI.GetUI()
theDlxFileName = "C:\MarkBrdComponents.dlx"
theDialog = theUI.CreateDialog(theDlxFileName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddOkHandler(AddressOf ok_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddFocusNotifyHandler(AddressOf focusNotify_cb)
theDialog.AddEnableOKButtonHandler(AddressOf enableOKButton_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_BASE_DIR\ugii\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 theMarkBrdComponents As MarkBrdComponents = Nothing
Try
theMarkBrdComponents = New MarkBrdComponents()
' The following method shows the dialog immediately
theMarkBrdComponents.Show()
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
Finally
If theMarkBrdComponents IsNot Nothing Then
theMarkBrdComponents.Dispose()
theMarkBrdComponents = 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
myDialog = CType(theDialog.TopBlock.FindBlock("myDialog"), NXOpen.BlockStyler.Group)
grpCompsMarks = CType(theDialog.TopBlock.FindBlock("grpCompsMarks"), NXOpen.BlockStyler.Group)
facecollectorBrdFace = CType(theDialog.TopBlock.FindBlock("facecollectorBrdFace"), NXOpen.BlockStyler.FaceCollector)
bodycollectorCompBody = CType(theDialog.TopBlock.FindBlock("bodycollectorCompBody"), NXOpen.BlockStyler.BodyCollector)
multilinestringShowText = CType(theDialog.TopBlock.FindBlock("multilinestringShowText"), NXOpen.BlockStyler.MultilineString)
objectcolorpickerMarkColor = CType(theDialog.TopBlock.FindBlock("objectcolorpickerMarkColor"), NXOpen.BlockStyler.ObjectColorPicker)
grpMarkSearch = CType(theDialog.TopBlock.FindBlock("grpMarkSearch"), NXOpen.BlockStyler.Group)
stringSearchText = CType(theDialog.TopBlock.FindBlock("stringSearchText"), NXOpen.BlockStyler.StringBlock)
objectcolorpickerSearchColor = CType(theDialog.TopBlock.FindBlock("objectcolorpickerSearchColor"), NXOpen.BlockStyler.ObjectColorPicker)
actionbuttonMarkSearch = CType(theDialog.TopBlock.FindBlock("actionbuttonMarkSearch"), NXOpen.BlockStyler.Button)
markClearAll = CType(theDialog.TopBlock.FindBlock("markClearAll"), NXOpen.BlockStyler.Group)
btnSwitch = CType(theDialog.TopBlock.FindBlock("btnSwitch"), NXOpen.BlockStyler.Button)
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
Dim text2search As String
Dim mark_text As String
Dim face_color As Integer
Dim body_color As Integer
Dim search_color As Integer
Dim aBody As Body
Dim aFace As Face
If block Is facecollectorBrdFace Then
'---- Enter your code here -----
bodycollectorCompBody.Focus
aFace = facecollectorBrdFace.GetSelectedObjects(0)
aFace.UnHighlight
face_color = objectcolorpickerMarkColor.GetValue(0)
aFace.Color = face_color
aFace.RedisplayObject()
ElseIf block Is bodycollectorCompBody Then
'---- Enter your code here -----
aBody = bodycollectorCompBody.GetSelectedObjects(0)
aBody.UnHighlight
body_color = objectcolorpickerMarkColor.GetValue(0)
aBody.Color = body_color
aBody.RedisplayObject()
ElseIf block Is multilinestringShowText Then
'---- Enter your code here -----
ElseIf block Is objectcolorpickerMarkColor Then
'---- Enter your code here -----
ElseIf block Is stringSearchText Then
'---- Enter your code here -----
ElseIf block Is objectcolorpickerSearchColor Then
'---- Enter your code here -----
ElseIf block Is actionbuttonMarkSearch Then
'---- Enter your code here -----
search_color = objectcolorpickerSearchColor.GetValue(0)
mark_text = stringSearchText.Value
theUI.NXMessageBox.Show("mark_text", NXMessageBox.DialogType.Information, "mark_text = stringSearchText.Value = " & mark_text)
theUI.NXMessageBox.Show("search_color", NXMessageBox.DialogType.Information, "search_color = objectcolorpickerSearchColor.GetValue(0) = " & search_color.ToString)
ElseIf block Is btnSwitch 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: focusNotify_cb
'This callback is executed when any block (except the ones which receive keyboard entry such as Integer block) receives focus.
'------------------------------------------------------------------------------
Public Sub focusNotify_cb(ByVal block As BlockStyler.UIBlock, ByVal focus As Boolean)
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: enableOKButton_cb
'This callback allows the dialog to enable/disable the OK and Apply button.
'------------------------------------------------------------------------------
Public Function enableOKButton_cb() As Boolean
enableOKButton_cb = True
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 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