Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SDETERS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program Help

Status
Not open for further replies.

designnewz

Automotive
Jan 11, 2014
52
I have enclosed a vb program I have developed using the Block Styler. Also I have attached the .DLX FILE. My problem is where do I put the code to place the txt on the drawing sheet at a certain size and its font. This program allows the user to activate and pick a number or a series of numbers to place them on the drawing sheet. Any Help in helping me finish this program would be benifical. I can pick the text and place it but the program does not know how big and what the text should look like. I do believe both files attached need to be in the same folder for the .vb to work.

'==============================================================================
' 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:
'
' This file was generated by the NX Block UI Styler
' Created by:
' Version: NX 9
' Date: 04-24-2018 (Format: mm-dd-yyyy)
' Time: 08:35 (Format: hh-mm)
'
'==============================================================================

'==============================================================================
' Purpose: This file contains template code that will help you create a
' working block-based dialog. You have to "fill in the blanks". Specifically,
' you have to write code within each of the "callback" functions whose stubs
' are shown below. As the user interacts with your dialog, NX will call these
' functions, and your code will be executed. For further information,
' please refer to Chapter 11 of the SNAP Getting Started Guide.
'==============================================================================
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.BlockStyler

'------------------------------------------------------------------------------
'Represents a custom dialog generated by the NX Block UI Styler
'------------------------------------------------------------------------------
Public Class BlockStyler350EX
Inherits Snap.UI.BlockDialog
Public Shared theBlockStyler350EX As BlockStyler350EX

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 list_box0 As NXOpen.BlockStyler.ListBox' Block type: List Box
Private list_box01 As NXOpen.BlockStyler.ListBox' Block type: List Box
Private cursorLocation0 As NXOpen.BlockStyler.SpecifyLocation' Block type: Specify Cursor Location

'------------------------------------------------------------------------------
'Constructor to which dlx file with complete path name is passed
'------------------------------------------------------------------------------
Public Sub New(theDlxFileName As String)
Try



Me.NXOpenBlockDialog = New Snap.UI.BlockDialog(theDlxFileName).NXOpenBlockDialog
Me.NXOpenBlockDialog.AddApplyHandler(AddressOf ApplyCallback)
Me.NXOpenBlockDialog.AddOkHandler(AddressOf OkCallback)
Me.NXOpenBlockDialog.AddUpdateHandler(AddressOf UpdateCallback)
Me.NXOpenBlockDialog.AddInitializeHandler(AddressOf InitializeCallback)
Me.NXOpenBlockDialog.AddDialogShownHandler(AddressOf DialogShownCallback)

Catch ex As Exception

Throw ex
End Try
End Sub

'------------------------------------------------------------------------------
Public Shared Sub Main()
Try

' Specify the filename (pathname) of the dlx file
Dim theDlxFileName As String = "C:\Users\sspring\Desktop\PROGRAMS2\350EX.dlx"

theBlockStyler350EX = New BlockStyler350EX(theDlxFileName)
theBlockStyler350EX.Show()

Catch ex As Exception

'---- Enter your exception handling code here -----

Finally



theBlockStyler350EX.Dispose()
theBlockStyler350EX = Nothing
'End If

End Try
End Sub
'------------------------------------------------------------------------------
' This function specifies when/how this application is to be unloaded from memory)
'------------------------------------------------------------------------------
Public Shared Function GetUnloadOption() As Integer
'Return CType(NXOpen.Session.LibraryUnloadOption.Explicitly, Integer) ' By using File-->Utilities-->Unload
Return CType(NXOpen.Session.LibraryUnloadOption.Immediately, Integer) ' Immediately after executing
' Return CType(NXOpen.Session.LibraryUnloadOption.AtTermination, Integer) ' When NX is terminated
End Function
'------------------------------------------------------------------------------
' This function will cleanup any housekeeping chores that may be needed)
'------------------------------------------------------------------------------

Public Shared Sub UnloadLibrary()
End Sub

'------------------------------------------------------------------------------
'InitializeCallback -- called during the dialog construction and just before the values are loaded from dialog memory
'------------------------------------------------------------------------------
Public Sub InitializeCallback()
End Sub

'------------------------------------------------------------------------------
'DialogShownCallback -- called just before the dialog is displayed
'------------------------------------------------------------------------------
Public Sub DialogShownCallback()
'---- Enter your callback code here -----
End Sub

'------------------------------------------------------------------------------
'ApplyCallback -- called when the user clicks the Apply button
'------------------------------------------------------------------------------
Public Function ApplyCallback() As Integer
ApplyCallback = 0
'---- Enter your callback code here -----
End Function

'------------------------------------------------------------------------------
'UpdateCallback -- called whenever the user changes anything in the dialog
'------------------------------------------------------------------------------
Public Function UpdateCallback(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
UpdateCallback = 0
End Function

'------------------------------------------------------------------------------
'OkCallback -- called when the user clicks the OK button
'------------------------------------------------------------------------------
Public Function OkCallback() As Integer
OkCallback = 0
OkCallback = ApplyCallback()
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

 
 https://files.engineering.com/getfile.aspx?folder=c979d58d-775e-47a6-8d46-0d9b3839a5da&file=350EX.dlx
Replies continue below

Recommended for you

Updated new .vb program... Writes to a listing window only now but need to drop it on my drawing/spec file. You still need the .dxl file in previous thread within the same folder as the .vb

'==============================================================================
' 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:
'' This file was generated by the NX Block UI Stylerdlx
' Created by:
' Version: NX 9
' Date: 04-24-2018 (Format: mm-dd-yyyy)
' Time: 08:35 (Format: hh-mm)
'
'==============================================================================

'==============================================================================
' Purpose: This file contains template code that will help you create a
' working block-based dialog. You have to "fill in the blanks". Specifically,
' you have to write code within each of the "callback" functions whose stubs
' are shown below. As the user interacts with your dialog, NX will call these
' functions, and your code will be executed. For further information,
' please refer to Chapter 11 of the SNAP Getting Started Guide.
'==============================================================================
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations
Imports NXOpen.Assemblies
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.BlockStyler

'------------------------------------------------------------------------------
'Represents a custom dialog generated by the NX Block UI Styler
'------------------------------------------------------------------------------
Public Class BlockStyler350EX
Inherits Snap.UI.BlockDialog
Public Shared theBlockStyler350EX As BlockStyler350EX

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 list_box0 As NXOpen.BlockStyler.ListBox' Block type: List Box
Private list_box01 As NXOpen.BlockStyler.ListBox' Block type: List Box
Private Shared lw As ListingWindow
Private cursorLocation0 As NXOpen.BlockStyler.SpecifyLocation' Block type: Specify Cursor Location

'------------------------------------------------------------------------------
'Constructor to which dlx file with complete path name is passed
'------------------------------------------------------------------------------
Public Sub New(theDlxFileName As String)
Try



Me.NXOpenBlockDialog = New Snap.UI.BlockDialog(theDlxFileName).NXOpenBlockDialog
Me.NXOpenBlockDialog.AddApplyHandler(AddressOf ApplyCallback)
Me.NXOpenBlockDialog.AddOkHandler(AddressOf OkCallback)
Me.NXOpenBlockDialog.AddUpdateHandler(AddressOf UpdateCallback)
Me.NXOpenBlockDialog.AddInitializeHandler(AddressOf InitializeCallback)
Me.NXOpenBlockDialog.AddDialogShownHandler(AddressOf DialogShownCallback)
theSession = Session.GetSession()
lw = theSession.ListingWindow()
lw.Open()

Catch ex As Exception

Throw ex
End Try
End Sub

'------------------------------------------------------------------------------
Public Shared Sub Main()
Try

' Specify the filename (pathname) of the dlx file
Dim theDlxFileName As String = "C:\Users\xxxxxxx\Desktop\PROGRAMS2\350EX.dlx"

theBlockStyler350EX = New BlockStyler350EX(theDlxFileName)
theBlockStyler350EX.Show()

Catch ex As Exception

'---- Enter your exception handling code here -----

Finally



theBlockStyler350EX.Dispose()
theBlockStyler350EX = Nothing
'End If

End Try
End Sub
'------------------------------------------------------------------------------
' This function specifies when/how this application is to be unloaded from memory)
'------------------------------------------------------------------------------
Public Shared Function GetUnloadOption() As Integer
'Return CType(NXOpen.Session.LibraryUnloadOption.Explicitly, Integer) ' By using File-->Utilities-->Unload
Return CType(NXOpen.Session.LibraryUnloadOption.Immediately, Integer) ' Immediately after executing
' Return CType(NXOpen.Session.LibraryUnloadOption.AtTermination, Integer) ' When NX is terminated
End Function
'------------------------------------------------------------------------------
' This function will cleanup any housekeeping chores that may be needed)
'------------------------------------------------------------------------------

Public Shared Sub UnloadLibrary()
End Sub

'------------------------------------------------------------------------------
'InitializeCallback -- called during the dialog construction and just before the values are loaded from dialog memory
'------------------------------------------------------------------------------
Public Sub InitializeCallback()

Try

group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.UIBlock)
list_box0 = CType(theDialog.TopBlock.FindBlock("list_box0"), NXOpen.BlockStyler.ListBox)

Catch ex As Exception

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

End Sub

'------------------------------------------------------------------------------
'DialogShownCallback -- called just before the dialog is displayed
'------------------------------------------------------------------------------
Public Sub DialogShownCallback()
'---- Enter your callback code here -----
End Sub

'------------------------------------------------------------------------------
'ApplyCallback -- called when the user clicks the Apply button
'------------------------------------------------------------------------------
Public Function ApplyCallback() As Integer
ApplyCallback = 0
'---- Enter your callback code here -----
End Function

'------------------------------------------------------------------------------
'UpdateCallback -- called whenever the user changes anything in the dialog
'------------------------------------------------------------------------------
Public Function UpdateCallback(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try

lw.WriteLine(" block : " & block.Name.ToString() )

' Capture text selected in list_box0
If block.Name = "list_box0" Then

lw.WriteLine("Current SelectedItems in List Box 0:")
Dim pl As PropertyList = block.GetProperties()
Dim items() As String = pl.GetStrings("ListItems")
Dim selected() As Integer = pl.GetIntegerVector("SelectedItems")
For Each picked As Integer In selected
lw.WriteLine(" " & items(picked))
Next
pl.Dispose()
End If

' Capture text selected in list_box01
If block.Name = "list_box01" Then

lw.WriteLine("Current SelectedItems in List Box 01:")
Dim pl As PropertyList = block.GetProperties()
Dim items() As String = pl.GetStrings("ListItems")
Dim selected() As Integer = pl.GetIntegerVector("SelectedItems")
For Each picked As Integer In selected
lw.WriteLine(" " & items(picked))
Next
pl.Dispose()
End If

' Capture point and create text

if block.Name = "cursorLocation0" Then


lw.WriteLine("Point Selected")

Try
Dim displayPart As Part = theSession.Parts.Work
Dim cursor As Point3d

Dim letteringPrefs As LetteringPreferences
letteringPrefs = displayPart.Annotations.Preferences.GetLetteringPreferences()
letteringPrefs.AlignmentPosition = AlignmentPosition.TopLeft
Dim userSymPrefs As UserSymbolPreferences = Nothing
Dim noteText() As String = Nothing

'noteText = list_box_text
'cursor = point_selected_on_screen
displayPart.Annotations.CreateNote(noteText, cursor, _
AxisOrientation.Horizontal, letteringPrefs, userSymPrefs)

Catch ex As NXOpen.NXException


End Try


End If
Catch ex As Exception

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

UpdateCallback = 0
End Function

'------------------------------------------------------------------------------
'OkCallback -- called when the user clicks the OK button
'------------------------------------------------------------------------------
Public Function OkCallback() As Integer
OkCallback = 0
OkCallback = ApplyCallback()
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor