admin 发表于 2017-1-16 15:27:51

通过对话框选择多个点实例

通过对话框选择多个点实例


Option Infer On
Imports Snap, Snap.Create

' This is a very simple example showing you how to use a Snap.UI.BlockForm
' to create a dialog that enables the user to select multiple point locations at once.

Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm

    ' Declarations of the blocks on the dialog

    Dim ptsBlock As UI.Block.SelectObject

    ' Constructor for a dialog object
    Public Sub New()

      Me.Title = "Select Multiple Locations"' Text to be shown in title bar of dialog
      Me.Cue = "Please select some locations"   ' Text to be shown in cue line

      ptsBlock = New UI.Block.SelectObject
      ptsBlock.AllowMultiple = True
      ptsBlock.MaskTriples =
            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
      ptsBlock.LabelString = "Select locations"
      ptsBlock.PointOverlay = True
      ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
      ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly

      ' Add the block to the BlockForm
      Me.AddBlocks(ptsBlock)

    End Sub

    Public Shared Sub Main()

      ' Create and display a dialog
      Dim myForm = New SnapBlockFormApplication2()
      myForm.Show()

    End Sub

    Public Overrides Sub OnApply()

      InfoWindow.WriteLine("You selected these locations:")

      For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
            InfoWindow.WriteLine(anObj.Position)
      Next

    End Sub

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)

      ' This is going to be annoying so don't really do it!
      If changedBlock = ptsBlock Then
            If ptsBlock.SelectedObjects.Length = 1 Then
                InfoWindow.WriteLine("You picked a Location")
            Else
                InfoWindow.WriteLine("You picked another Location")
            End If
      End If

    End Sub

    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
      Return Snap.UnloadOption.Immediately
    End Function

End Class
页: [1]
查看完整版本: 通过对话框选择多个点实例