|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例3 ?1 x8 z! X, o' ]# f
5 P8 o, i" K' r
, {9 r1 S- p' B2 U; o5 X+ v8 JOption Infer On
$ P+ G; K5 {, m$ q, AImports Snap, Snap.Create
1 K* T: E( C4 k! {* y; w
6 f. c* [$ |. J% q, ?! D' This is a very simple example showing you how to use a Snap.UI.BlockForm7 [) d) n' H# D& T/ q' n: J K8 A3 h
' to create a dialog that enables the user to select multiple point locations at once.$ N6 X1 z1 R5 J; I6 T$ o
3 }+ A4 z7 R' Z; e4 p: M* q. VPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm% B6 m& `$ ?. F' w
; t* e* a5 k9 e) e% G V! ^
' Declarations of the blocks on the dialog
# i# c9 y1 K+ k) |% X* p. C) k* V
y* l7 w' z/ A! y. W3 w- x) ]& y7 z9 P9 k Dim ptsBlock As UI.Block.SelectObject2 @) J! Z" b) ~. ]8 F" c
0 C& w4 A! {" x) z# I- m ' Constructor for a dialog object8 J2 ^% }5 b. F$ l/ }+ M6 ^: y3 O
Public Sub New()
$ |1 ?9 @% ^ U$ C- B
0 q" L# x8 C! d u Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog$ J8 [$ D8 ~6 T6 _3 r
Me.Cue = "Please select some locations" ' Text to be shown in cue line
% G7 w6 n! h7 k% e! _5 a+ r- \: l4 ^* H4 {+ n8 @& p+ c+ P# `# Y
ptsBlock = New UI.Block.SelectObject6 C) c4 v8 K6 Z' J0 f
ptsBlock.AllowMultiple = True3 c: u; |& H$ E/ M' K3 F( b# y# Z
ptsBlock.MaskTriples =
4 W) J% n: M5 V4 x8 i% x [" X {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
) u& i9 l( Z7 w ?, @ ptsBlock.LabelString = "Select locations"
+ ~, [$ @! U+ d) ?) m ptsBlock.PointOverlay = True, e5 {% i% g+ u- @% V6 C
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
/ [/ V' J4 _$ J ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
9 O- U. E- I/ K5 v+ V* O2 M% s" j" [1 H# \! }' h% q1 G
' Add the block to the BlockForm, o1 H4 \% E) X7 N. h; o
Me.AddBlocks(ptsBlock)
& N; w) I# L$ A$ K* J$ @
9 M4 G9 j0 V8 ~ i L1 N End Sub# @; w1 g, b# Q. R2 m$ `# P3 q
" O8 S1 Q' x; X0 Z" f6 }* k Public Shared Sub Main()0 R0 F! Z9 |- n! r, A6 Y
0 f* N8 w1 T$ _! \3 r
' Create and display a dialog, w: s# R, f4 u Q, L2 t
Dim myForm = New SnapBlockFormApplication2()8 K0 r! n, r* r3 s5 H a
myForm.Show()8 a: T' N. [+ @+ w9 h$ b
! s. ]) U" C, ?% L) X
End Sub
4 u! X1 X$ V, T0 j- \1 Y- X
" |- z( H+ R- d Public Overrides Sub OnApply()
}" i/ f5 m( B, Z$ S- Q U! d- R* D0 C4 _5 x" |8 a
InfoWindow.WriteLine("You selected these locations:"). h* n) M: G" t2 `
. W- {6 ]' V) h, v, X; a4 ?
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects/ p3 C& O P! S2 ~
InfoWindow.WriteLine(anObj.Position)
5 ?6 i6 z& Q9 z8 z/ t5 E P2 Z% _% V8 x Next
8 d. p4 l5 G# p [2 g4 T& f) x" g# j6 s' D
End Sub4 A" W9 C# c0 ^2 h, q K4 D0 A
3 f- ?) a& ]/ x! q' T. d Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
# @ h1 H L! [1 {; @& @2 D R8 s3 g& ]* \) r3 L+ H& b
' This is going to be annoying so don't really do it!# R* \, R* J( _# w! k, P8 b2 ~
If changedBlock = ptsBlock Then" a+ w. T! `+ k, a3 c" ?# ^: x
If ptsBlock.SelectedObjects.Length = 1 Then
+ z; r3 `0 w# d" b InfoWindow.WriteLine("You picked a Location")
: E' l6 O R: F; \& R: S+ o Else
9 Z' z& i% I4 ? InfoWindow.WriteLine("You picked another Location")
5 C: ]3 } a# ]- g) [ End If5 ]% C" B7 p: E( t' h
End If
! h W8 z; A- c' ]: a
m/ h) X% c5 y$ x1 B, F1 ^5 [" ?1 | End Sub
8 _8 y* ^# W9 `
9 J, Y; M% u! g: W2 b$ _ Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer' `( I! B6 E, c2 l
Return Snap.UnloadOption.Immediately+ v/ u- Q# o. z0 F+ H: S- [
End Function( J$ h/ ~% }1 c/ }/ c8 p; b
. C* O9 n$ H7 H6 k
End Class
) Q" D0 e6 |9 j% i* d |
|