|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例4 E5 E( F8 I, r; F: M5 U- m) H
: o0 r9 L- N- L: {+ `
+ L. o" @) v% H8 b* l5 ^Option Infer On8 }! Q) ~; V3 ^1 |8 Y; ]
Imports Snap, Snap.Create' E4 y: L0 P2 H% @
; h/ O% ^0 ~# P4 H" T& N5 d' This is a very simple example showing you how to use a Snap.UI.BlockForm+ z7 \& A6 ^" z5 ]
' to create a dialog that enables the user to select multiple point locations at once.
2 l( D2 g* M: I5 f' `7 [! ]! t, r& r: m( m+ d
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
" p5 A8 A$ C& J& R
" I& \/ Y( G/ g8 |, O ' Declarations of the blocks on the dialog% A- y& G: P: T% Q
5 x" F2 V+ H6 d- z& Z
Dim ptsBlock As UI.Block.SelectObject
" Q1 z/ J0 u" }# _( q. O
( o* G0 @1 ?, v7 T. v1 A ' Constructor for a dialog object5 ^: M# H2 h/ P5 k
Public Sub New()" F/ `! {3 S$ K0 g% G9 g1 F& O4 d
( a4 H) f8 K9 }5 X Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
& h' t. X9 l, W2 c- Q) Q! M Me.Cue = "Please select some locations" ' Text to be shown in cue line
/ M" u/ h1 I9 g: `/ R1 M! C6 \, f" L) x* R$ s- Z6 ^1 ]4 z
ptsBlock = New UI.Block.SelectObject# m* [: t8 {- U+ D; j: J# X* r/ _
ptsBlock.AllowMultiple = True
1 `% n6 {% T7 i# Q& v' B' X& a1 ` ptsBlock.MaskTriples =
7 H' Q6 L, s7 R( s {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}6 ^; Q( p0 r' ~9 D
ptsBlock.LabelString = "Select locations"1 p, |! B4 B: ^! U- L
ptsBlock.PointOverlay = True
9 W5 h- u. F+ _* o- l) T( x ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)& M6 d" B$ ?. \
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
, U8 t1 R( |! d% b. F4 A# e4 t) h" Q4 g+ B) q, Q
' Add the block to the BlockForm
+ X; W% y# m( I Me.AddBlocks(ptsBlock)
3 J9 C; E+ q0 E$ A7 P: p v/ c& Z8 X& a8 W$ n# f5 n _* ?
End Sub
7 k! l4 F, O. @$ {6 }' \, M$ q: o8 q# W
Public Shared Sub Main()
1 t& d l0 s+ U. l5 \5 K2 V J. I* u$ a3 j
' Create and display a dialog; ~3 A5 a, U8 P
Dim myForm = New SnapBlockFormApplication2()9 b/ L6 l L ]5 I: _( l, q, E8 E
myForm.Show(). H0 ]+ U( \# u
8 c% V; U5 }- M$ x w
End Sub
F/ r/ X; k$ P& ]: u0 W. a( S
& @/ _/ a' h* z Public Overrides Sub OnApply() I- ^' |0 i: G% o9 C
' K) y+ n6 ^% t+ r) m5 Z4 U
InfoWindow.WriteLine("You selected these locations:")
& \( v; o! s' y6 Y" l7 m- O+ a3 `5 H
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects$ c; ~- N; u0 ~* X! C* U9 \( v
InfoWindow.WriteLine(anObj.Position)
, X" h5 p: C a! f, t Next
" Y: f8 _. @0 g* e
4 [9 a, v! q( H8 O End Sub! A: p# E9 J6 J- |
6 O2 M( q/ c! B: Y* z1 r Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
7 E6 m5 b6 e& n- F G m2 u6 ?" i8 l, ?- }2 F! a/ j5 V. z
' This is going to be annoying so don't really do it!4 A W- \- ] V- C- I- A4 `
If changedBlock = ptsBlock Then
0 q& K& `" m. d( N( B$ ~; a If ptsBlock.SelectedObjects.Length = 1 Then& M- C( a' Y( O( c* p8 a
InfoWindow.WriteLine("You picked a Location")
( S* f) P. C; W, z0 ^ Else
' L# h" V, k3 k$ x0 V InfoWindow.WriteLine("You picked another Location")
0 y+ I8 z8 L* u; |4 y6 m End If. _& n% [4 o3 Z3 O' R6 F8 w3 ~7 n' R
End If4 S4 E% @2 ]9 @* N5 c. [' W
+ W+ b# f9 a, K. A/ d* I
End Sub' j! `2 J; P# i2 u
7 P6 o- Z8 t6 F, ^+ O( _ Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
/ O6 ^/ a g1 i! B' {6 _+ s Return Snap.UnloadOption.Immediately, v+ L L9 X, ]7 A
End Function
C1 i T5 G3 d d5 a2 H0 y8 } B2 H2 W$ R+ k7 r9 }1 M. R4 _
End Class% \ ?' u% W8 I7 g' a
|
|