|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
7 \ G* z" f) N* B" u C
' n6 J0 V5 ?. w& S+ R/ c4 g7 x9 V$ d- \# U/ D
Option Infer On8 _# ^6 w! B6 m) }% c8 d% D
Imports Snap, Snap.Create
2 ?, |5 ]! c* z1 r
! Y- Q; ]! T' [# D$ U' s' This is a very simple example showing you how to use a Snap.UI.BlockForm
8 L2 A, {) M8 r0 V4 Q9 ~' to create a dialog that enables the user to select multiple point locations at once.
4 C- N( t" C) {* ]2 I- b3 ~: A% H, E X! G6 }4 [- J, [. x) c" |
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm- b2 t4 }' I4 e2 O1 t8 l% G
7 h' d, `! n* j& p" [5 W$ L$ r ' Declarations of the blocks on the dialog
! c& T3 W, e, _% f. t" s
! u: z& n9 L# E Dim ptsBlock As UI.Block.SelectObject$ K9 B' f; ?" ]5 U: Z! i) z
" C2 A; N$ |( ^+ I" S/ @' l ' Constructor for a dialog object
# w) W3 R/ X U3 ^( J% a Public Sub New()
* F; o/ ~ q9 X f
' V3 L& i- E1 ~9 u# Q6 x Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
* w# E f# i% j- W7 a" a/ X Me.Cue = "Please select some locations" ' Text to be shown in cue line
5 R. j2 n N; @0 x5 H' e, H$ d e9 Q7 b* M6 I1 k
ptsBlock = New UI.Block.SelectObject) I5 G* W7 [# D! J V* O
ptsBlock.AllowMultiple = True
% O4 D' T( y `/ o2 O! M ptsBlock.MaskTriples =( l- J9 [( |5 y: S% [4 s5 l
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}- E, K, c! O$ T2 Z9 @1 i8 K8 H
ptsBlock.LabelString = "Select locations"
+ r+ T8 }/ R& R! T: a ptsBlock.PointOverlay = True
' C$ J: r- O. F0 j ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)/ l* M# U _ x8 S0 u8 d
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
% b2 w. ?( z8 _8 g
6 E/ F$ V: E$ S: N ' Add the block to the BlockForm" h* M. T" K* [5 v8 ^9 y- z+ C
Me.AddBlocks(ptsBlock)/ M% P9 q% I2 X
, {3 o8 H8 L6 m* L/ p* q End Sub
4 s7 [% {4 ]! U2 p0 R) h% b- w U3 d# @+ c/ R
Public Shared Sub Main()3 V! T1 E" ^3 f' w+ a7 T. v* T
8 P: s8 A! Q) X& [. K4 q# Q/ c
' Create and display a dialog
3 S5 Y8 m1 @: y6 r( _) U `4 z- P Dim myForm = New SnapBlockFormApplication2()& {# z7 g. O9 x4 F% A. y
myForm.Show()+ F) s$ J/ g+ W! e
/ X7 G. _ k! N ? C
End Sub- W# n8 W& j: u- X% }/ v' ]
+ Z5 y3 y- C, r1 e ?' m
Public Overrides Sub OnApply()
, J7 x9 Z% X* e+ v# F U# g# q/ l' S8 L. K. I2 z
InfoWindow.WriteLine("You selected these locations:")
: g! E. {6 s% B# ~: C6 j
L# B4 u( k" x3 k" W6 l For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects/ t2 E6 N2 x0 B& J& ]
InfoWindow.WriteLine(anObj.Position)
/ x' e6 S( U* e: v4 V5 m Next
. @1 m$ ~6 X [3 n: d( u8 G6 @" E U, Y! N* M: g) f( V6 I' c3 ]2 Z
End Sub
" Y0 h$ C0 o+ d6 q4 Z- B/ V3 q7 T) T' f2 v' r
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)6 \2 i; c# f, U4 ^3 _7 U4 b- \
2 N# T- Z$ q$ E ' This is going to be annoying so don't really do it!# W3 \4 J* l4 n. S+ ^. ]
If changedBlock = ptsBlock Then
: }9 o( F% ?, D/ K8 R If ptsBlock.SelectedObjects.Length = 1 Then1 n$ y$ i0 z4 a. X9 T
InfoWindow.WriteLine("You picked a Location")
# ^! Z9 j! b+ n2 G Else; S* P- G! Z7 F& X$ V
InfoWindow.WriteLine("You picked another Location")
% K2 K2 B0 v; d8 P i+ F, \ End If) X. u. \; k% J' \' B
End If
/ Y# e" C: p% T
$ A6 p8 u, ^1 Q5 o8 I( @# O End Sub b* p6 p5 q- x' T9 O1 ^7 T
0 |% d4 A9 v% j! y; S) } Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
8 A% _7 w6 A% r# D( Q( E8 L: O Return Snap.UnloadOption.Immediately
5 o! m) c4 W- G# D! f3 G End Function- l8 d( H% l" v' P6 }
' m5 v) q7 B2 b3 J& C( k. c" |& r
End Class h( @9 u9 p+ b; u5 w' C, X/ B
|
|