Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX9 Snap Help 1

Status
Not open for further replies.

sjkim

Automotive
Apr 1, 2015
13
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

error_ks5eps.jpg


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
 
Replies continue below

Recommended for you

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

 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor