×
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!
  • Students Click Here

*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.

Students Click Here

Jobs

NX9 Snap Help

NX9 Snap Help

NX9 Snap Help

(OP)
This is snap Code, and I just copy and paste from snap manual(page 100) to my vb code.
And Start is good, but I click "Ok", error message is appeared,,,
Why it happened?
My verseion is 9.0.3.4-Mp10



Imports Snap, Snap.UI

Public Class MyProgram

Public Shared Sub Main()

' Your code goes here

Dim dialog As New BlockForm()
dialog.Title = "Selection Demo"

Dim selectionBlock As New Block.SelectObject()

selectionBlock.Cue = "Please select a line to be hidden"
selectionBlock.SetFilter(NX.ObjectTypes.Type.Line)
selectionBlock.MaximumScope = Block.SelectionScope.AnyInAssembly
dialog.AddBlocks(selectionBlock)

Dim response = dialog.Show()

If response <> UI.Response.Cancel Then
selectionBlock.SelectedObjects(0).IsHidden = True
End If


End Sub

End Class

RE: NX9 Snap Help

I get the same error. It looks like a bug. You should report it. This code works:

Imports Snap, Snap.UI

Public Class MyProgram

Public Shared Sub Main()

Dim cue = "Please select a line to be hidden"
Dim dialog As Selection.Dialog = Selection.SelectObject(cue)
dialog.SetFilter(NX.ObjectTypes.Type.Line)
dialog.Title = "Selection Demo"
dialog.Scope = Selection.Dialog.SelectionScope.AnyInAssembly
dialog.IncludeFeatures = False
Dim result As Selection.Result = dialog.Show()
If result.Response <> NXOpen.Selection.Response.Cancel Then
result.Object.IsHidden = True
End If

End Sub

End Class

RE: NX9 Snap Help

If you really want to use a BlockForm (so that you can put other blocks on it, in addition to the SelectObject block), then this works:

Option Infer On
Imports Snap, Snap.UI

Public Class BlankLineDialog : Inherits UI.BlockForm

' The various members of a BlankLineDialog object
Dim selectionBlock As Block.SelectObject ' A SelectObject block

' Constructor to create a new BlankLineDialog
Public Sub New()

selectionBlock = New Block.SelectObject()
selectionBlock.Cue = "Please select a line to be hidden"
selectionBlock.SetFilter(NX.ObjectTypes.Type.Line)
selectionBlock.MaximumScope = Block.SelectionScope.AnyInAssembly
Me.AddBlocks(selectionBlock)

End Sub

' The main function
Public Shared Sub Main()

Dim dialog = New BlankLineDialog() ' Create a dialog
dialog.Show() ' Display it

End Sub

' Function that gets called when user clicks Apply (or OK)
Public Overrides Sub OnApply()

Dim selection = Me.selectionBlock.SelectedObjects(0)
selection.IsHidden = true

End Sub

End Class

RE: NX9 Snap Help

(OP)
Thanks,, Bubbak!!!

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