|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例 T1 D ^/ y9 N: \9 r3 `
: u" }1 A- M; ^7 y' H2 R% E6 @6 u" Z) Z3 K; M4 `; M6 \$ H
Option Infer On
+ i C" ], j# A( P& R, k" EImports Snap, Snap.Create
0 v4 m) e, k+ R8 {. ~4 h9 L! _: Y% X1 t0 b
' This is a very simple example showing you how to use a Snap.UI.BlockForm) [ t$ F. S. C; n$ X
' to create a dialog that enables the user to select multiple point locations at once.
; e8 ?9 @( C( r/ L/ b- c3 w/ d1 ]5 n- @; E
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
- H% ]% @+ i, |) ?$ l
) r1 ]1 Q) a5 Z) A. D5 D0 y+ t" \ ' Declarations of the blocks on the dialog
- K) e, i1 `8 s6 Q6 H, b! t
0 c6 @( m+ \2 r3 B- u; y8 M Dim ptsBlock As UI.Block.SelectObject
8 z4 _4 s( E. j+ U8 Z$ X" S7 x' G# [ W: M) d5 N i8 b4 x
' Constructor for a dialog object
2 R7 K9 Q( I" k# V$ j9 i/ e+ V+ g6 @ Public Sub New()
. Z/ G& K+ L; W9 K7 `1 F" z2 S
0 O/ b1 W' t2 x9 b; E# o B, P Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog4 P+ u( n4 V# V" r8 @
Me.Cue = "Please select some locations" ' Text to be shown in cue line
; N1 h& ^) m# Q7 _- u, Y/ J% V! H6 w5 k! A7 x: G0 H+ C
ptsBlock = New UI.Block.SelectObject; L5 e) U9 V0 s5 e0 p
ptsBlock.AllowMultiple = True! ~1 d/ X) Q# A& A/ ~
ptsBlock.MaskTriples =
6 z1 q5 n7 O8 d- V {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
! k. J2 w1 m6 n/ ]- X% P ptsBlock.LabelString = "Select locations"
0 S, x( C1 p5 A0 J ptsBlock.PointOverlay = True% X X9 Z2 l8 Z. W& ?
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)% ~7 m% ~$ e& T
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly4 x4 c8 Z+ z( |. b0 e
+ ?( i- u/ F& e3 a0 } ' Add the block to the BlockForm
* N& x1 n" M& {8 k0 A+ k6 |4 E Me.AddBlocks(ptsBlock)
" l0 z* n* _0 Z
2 D9 s- @; j9 C, T8 Y' h End Sub
/ P0 g) l9 k6 P* A. y
, i- m, L8 E8 \7 G Public Shared Sub Main()0 g- G6 A& x6 j8 S* U& t6 E
! y5 V" R6 _1 V& ?6 T ' Create and display a dialog
1 G% j8 T$ w5 a6 B Dim myForm = New SnapBlockFormApplication2()
- p3 r4 B; g7 Y* d5 v- a myForm.Show() K0 G t* r* ~1 P+ k/ J/ P' k A
. L1 C( q$ m ]0 B$ b, n- I End Sub
' R" }% {7 Q; u" A7 q. ~. F1 L+ a6 j& i3 ]1 j
Public Overrides Sub OnApply()
7 l. Y; x# ?; y3 ~5 s. M0 k: ~* l- ]/ b2 L! T& i+ D3 A% @
InfoWindow.WriteLine("You selected these locations:")9 d5 Z/ }, a; y: Q) [
# `% w G n6 ]+ i' j/ M For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects6 }( z8 n/ m8 [- A$ B8 ?: N
InfoWindow.WriteLine(anObj.Position)
# |- B s: k6 F2 q+ N7 [ Next- H9 y2 g7 \, M
2 V/ q( i$ z: @( g7 K8 C
End Sub+ P3 ?7 W1 v1 B4 n
/ k. J2 |, Y" [+ V
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)* u- l1 u ]' ~% Y& N
" h! H) j- l$ ]3 b" V$ x) ` ' This is going to be annoying so don't really do it!
2 _1 Q- Y5 h7 h) \' Z If changedBlock = ptsBlock Then% M+ V* w* b0 m. S
If ptsBlock.SelectedObjects.Length = 1 Then
- ?+ f* L# H7 O f InfoWindow.WriteLine("You picked a Location")
% B" F3 p9 }$ h) u' V+ E Else
, P5 s0 F/ j, O InfoWindow.WriteLine("You picked another Location")
+ s+ n0 y( l" m7 V7 | End If
/ n4 V3 L# ^, L End If/ b/ Z$ l" Q+ N
k. j3 o8 i5 T$ S2 a8 h
End Sub
' z. W9 b- L- |4 e2 X3 F
/ V+ Y' i: p8 U6 P* { Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
0 H- S) J+ H0 U" M/ [ Return Snap.UnloadOption.Immediately
, @* B( W" Z* ?* a End Function0 V |/ c5 ~3 f5 H' y o
0 w; g& `: A; j7 \# u2 Y+ u
End Class( S" Z6 ?5 T" D! a/ ^
|
|