|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
4 B+ ~7 x/ V/ F7 b: {( L. d) h
! B) I2 `" F0 ?6 R
$ g9 y# W( U2 H2 c& V* O7 bOption Infer On$ o9 j: l1 c. _" i
Imports Snap, Snap.Create
. k) \! \) s0 v/ b" m; X' S M0 u# E' u7 k& X( Z$ X- w
' This is a very simple example showing you how to use a Snap.UI.BlockForm
5 u6 F" J/ {5 m' v& }4 H. y6 y' to create a dialog that enables the user to select multiple point locations at once.. k* Z: U; u8 W. _* ]1 G
, Q: t* H* O; T: _9 h V' f% U4 Y, mPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm6 S h. Z+ h- ?( ]
! b" S1 g& y0 g+ z
' Declarations of the blocks on the dialog% w3 t+ E; a# w# r1 D
$ `! c& D1 z6 Z3 ~: { Dim ptsBlock As UI.Block.SelectObject
/ U; o. Q5 D4 I- a% W! `- x7 @
7 K: P) Q0 f7 x/ K* b ' Constructor for a dialog object
! U' P! t% W# b9 ]9 A- Y Public Sub New()
$ j" Y( ^5 `: d! T! s& K$ o4 b- P# A. u% i8 m y. k2 V. F5 ?
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog; `. J6 l3 d: \- y8 T( W
Me.Cue = "Please select some locations" ' Text to be shown in cue line* t6 Z" p6 h" `$ C. p7 f: n/ i
# e/ y; G+ L1 p/ S3 F; |# { ptsBlock = New UI.Block.SelectObject/ W/ J; Z5 @8 c5 @( R7 _4 v
ptsBlock.AllowMultiple = True. J t8 }0 _: S/ q- `$ g
ptsBlock.MaskTriples =
4 y4 X6 \6 _" | {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}& n4 F5 c M$ Q" D0 Q& @: a3 _
ptsBlock.LabelString = "Select locations"/ {% K6 B9 z% w* A. I; G
ptsBlock.PointOverlay = True
0 p& l& F" O" [. Y3 w$ A ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)' S* \# e: r; @* F- ]; K t* U
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
- P/ |) M, w5 i' [; m0 ~. h+ K" ~; E7 H; n8 [! i
' Add the block to the BlockForm' A0 E3 o# ~) m
Me.AddBlocks(ptsBlock)$ ?; y; `6 G5 {* l" z3 c
9 v- H/ q1 Z5 Y1 h7 {; ?9 E
End Sub
, _- N+ w/ C' t9 |6 d5 T0 n4 C& L- e' w* K
Public Shared Sub Main()
7 M/ y; I$ a9 B
& U2 G! c* U( m ' Create and display a dialog
1 [) T# g2 s# C, r1 f Dim myForm = New SnapBlockFormApplication2()! }$ [# m7 m5 V0 C8 [. {
myForm.Show()
8 ~! v$ ^8 t6 M5 t |2 ^6 ]6 o \4 K& q H. @; |
End Sub: X& M! w( M* f, {
* U1 f" Q' H, i8 G6 F3 X( P8 {/ Z
Public Overrides Sub OnApply()
! w3 L# x8 [& w. M" r1 r+ B1 u( S$ L" W4 {# r& ~& d3 M
InfoWindow.WriteLine("You selected these locations:")5 }! K8 Z! t) f4 P% m' W) v( v
; f7 h% K2 c7 h( M$ d( w
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
. Q% Y- M2 [' z3 k$ x InfoWindow.WriteLine(anObj.Position)
' r5 R4 ~7 k# f Next
* I1 [0 h8 i v7 L" {! @6 ~. V h# y }* `& C# B# t( U* I0 h1 U
End Sub" J+ M8 t" g2 g( ]$ K$ T
' e5 d9 S) w3 g* A3 G* r Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)# g; M/ a; M% E. A9 G' ]4 s2 ]
: d6 b: P4 _3 S5 W0 t
' This is going to be annoying so don't really do it!
! O4 F1 {, k4 H If changedBlock = ptsBlock Then- z0 j- ~2 _% s: {% O
If ptsBlock.SelectedObjects.Length = 1 Then; Y/ F1 e7 c7 H
InfoWindow.WriteLine("You picked a Location")
d; E4 F* k J! ^' e8 c n5 { Else
/ |+ r4 ]2 Q* }/ S: j8 [9 h$ e5 K InfoWindow.WriteLine("You picked another Location")! F, J7 r0 U5 `1 N
End If$ x7 X% B8 u* T5 s2 M9 m
End If! ^7 d( C/ N$ @ N% j
! o9 [% {' O C5 D$ N
End Sub
3 u, y# N' |, B7 `9 N! [! R. t5 G/ M. E" r4 I
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
/ }6 A% J* E; K! j* [ Return Snap.UnloadOption.Immediately- ]2 l9 m8 }. W1 Z
End Function
% i1 p! v8 w3 G) _+ m$ \! t6 T
+ W0 _0 d/ G9 ?1 s: kEnd Class
; u/ ~8 o5 [9 _# ~" R1 m |
|