INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

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.

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

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

(OP)
Found a new way to call for a point location and managed to get the cancel to work properly.

RE: Selecting Point VB

(OP)
Update I got the cancel to work but now the actual click is not working.

Here is the code

CODE

Try
         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

Check out the sister site to this one - Tek-Tips.com.  The computer nerds live and die over there!!!

RE: Selecting Point VB

Perhaps SelectScreenPosition will give you what you need?

Here is a small example from GTAC:

CODE

Option Strict Off

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close