Selecting Point VB
Selecting Point VB
(OP)
This is used in UG, I am selecting a point, however if cancel is selected I want to use a default value of x and y. For some reason though I am only getting a value of 0, 0.
My head says this should work, when I select a point it works, so we definitely have a True response, however a false response is NOT working.
Any help is appreciated.
CODE
Try
response = theUI.SelectionManager.SelectScreenPosition("Select location for LAM Lines to Begin", _
view, cursor)
booleanResponse = True
Catch
booleanResponse = False
End Try
If booleanResponse = true Then
x = cursor.x
y = cursor.y
Else
x = 170
y = 450
End If
response = theUI.SelectionManager.SelectScreenPosition("Select location for LAM Lines to Begin", _
view, cursor)
booleanResponse = True
Catch
booleanResponse = False
End Try
If booleanResponse = true Then
x = cursor.x
y = cursor.y
Else
x = 170
y = 450
End If
My head says this should work, when I select a point it works, so we definitely have a True response, however a false response is NOT working.
Any help is appreciated.





RE: Selecting Point VB
RE: Selecting Point VB
Here is the code
CODE
ufS.Ui.SpecifyScreenPosition("Select location for LAM Lines to Begin", Nothing, IntPtr.Zero, _
origin, view2, response)
If response = UFConstants.UF_UI_PICK_RESPONSE Then
booleanResponse = True
End If
Finally
' Restore UI state always including in case of error.
ufS.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
If booleanResponse = true Then
x = cursor.x
y = cursor.y
Else
x = 170
y = 450
End If
When the user selects a point on the sheet I want the program to set x and y to those coordinates, otherwise I want them to use the default values.
I get no error when the command is run, cancel works fine, but when a point is clicked x and y are both set to 0.
Thanks in advance for any help.
RE: Selecting Point VB
RE: Selecting Point VB
Here is a small example from GTAC:
CODE
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities
Module select_screen_position
Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Sub Main()
Try
Dim old_cursor_view As Integer
Dim new_cursor_view As Integer = 0 'ANY view
Dim screen_pos As Point3d
ufs.Ui.AskCursorView(old_cursor_view) ' get original setting
ufs.Ui.SetCursorView(new_cursor_view)
While select_screen_pos(screen_pos) = Selection.Response.Ok
s.ListingWindow.Open()
s.ListingWindow.WriteLine("Position: X: " & screen_pos.X.ToString & _
" Y: " & screen_pos.Y.ToString & _
" Z: " & screen_pos.Z.ToString)
End While
ufs.Ui.SetCursorView(old_cursor_view) 'reset to original
Catch ex As Exception
s.ListingWindow.Open()
s.ListingWindow.WriteLine("ERROR: " & ex.ToString)
End Try
End Sub
Function select_screen_pos(ByRef loc As Point3d) As Selection.Response
Dim resp As Selection.DialogResponse = Selection.DialogResponse.None
Dim localView As View
resp = theUI.SelectionManager.SelectScreenPosition("Screen Position:", _
localView, loc)
If resp <> Selection.DialogResponse.Back And _
resp <> Selection.DialogResponse.Cancel Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module
www.nxjournaling.com