|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
通过对话框选择多个点实例 c2 ~* J1 `" V& _- U
4 p0 c4 C4 U' i" s/ r7 L* U) Q" z
! j6 L3 y+ _( [/ G1 I& `; r0 TOption Infer On0 u9 T' ^0 ^3 \0 y+ t
Imports Snap, Snap.Create
. e! c; N2 V, L: ~5 N! x2 @9 x# b J: ]5 o8 u3 u: U2 }
' This is a very simple example showing you how to use a Snap.UI.BlockForm- W( i3 ]0 J4 r; [& P
' to create a dialog that enables the user to select multiple point locations at once.$ d4 H7 p' _( ^8 s& X0 X0 u V
4 p1 B" F( @$ z) W& }2 zPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
' y9 u0 ?( T7 [; C/ f
5 ]& V L8 C/ ]4 _+ p* C ' Declarations of the blocks on the dialog# ?4 _, V% k& b4 u. g) t% A
7 X" i+ Q; j; D1 t m Dim ptsBlock As UI.Block.SelectObject
7 ]" N- Q( N; ~$ [& t# ~$ s& ~
9 L. {$ a! [- | ' Constructor for a dialog object+ o, {0 g }. ^ ^6 u j8 z
Public Sub New(), O1 [ x; E& u5 k! `5 C7 x
$ t* q% j( r1 ~$ x7 b H& ` Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog0 j6 [; j8 Z @: r+ K0 B- l7 J
Me.Cue = "Please select some locations" ' Text to be shown in cue line
4 X2 A+ \* N/ B
% a% C: g: Q+ Q4 V6 H ptsBlock = New UI.Block.SelectObject+ m0 m c- P( j
ptsBlock.AllowMultiple = True
5 M: u4 k' R" {9 B6 b ptsBlock.MaskTriples =7 T C& P8 a0 O, R2 w3 H8 U5 R z
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}: H. z8 B1 o. x2 G
ptsBlock.LabelString = "Select locations"
! }7 X# L4 F& A) u! P/ H- |& O ptsBlock.PointOverlay = True
- i: N, L% _! T4 g, p0 y3 } ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)" U8 n# c) l$ L- ]& L
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
- I& b+ Y4 n+ U0 c- }; I1 c- V* r" r& S. r
' Add the block to the BlockForm
( ~6 \8 Z' Z# K" ^) r: x& { Me.AddBlocks(ptsBlock)
# _' Z+ o* k/ X8 J/ b& [: y- x: W, N6 Q$ ?
End Sub8 t; y8 h2 X/ B; Q# X# u
+ \5 t) r4 e9 d) j1 o
Public Shared Sub Main(). \* {1 K/ x8 \% j4 v5 h# z; F; H
$ k) t/ x. _+ G% b+ F, r4 [7 q7 ? ' Create and display a dialog1 X8 t* W# Z. w; q4 q! y
Dim myForm = New SnapBlockFormApplication2()
# F+ W/ A, G1 F7 @# @' x5 V myForm.Show()
7 z+ k1 [2 G* u! t0 h- R8 Z' ~) Z7 j5 x5 s$ J8 o2 C) B
End Sub1 x- N1 i, ^/ D; @5 Z
% w6 q7 Q' M% U9 c# l" }2 w Public Overrides Sub OnApply()$ U/ N" r. g! v1 X
5 ^2 F) f$ R# I) i InfoWindow.WriteLine("You selected these locations:")) T% [4 _! [- _+ k* c2 n6 ~
7 Z' z' c2 T$ P For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
' T( h, G, X7 l: @ InfoWindow.WriteLine(anObj.Position)$ F, F! n- j/ f5 ~" o, ~, H s
Next2 a# d6 g, g* l. M2 f8 r6 y/ L
. ?# d3 ]: X" }3 j& \+ p7 Z
End Sub
) x( Y) {/ H5 P: v5 d8 K5 G
$ J3 C! ~" ?( v Public Overrides Sub OnUpdate(changedBlock As UI.Block.General), E7 b! {; z0 f' n. R1 U/ w
$ F8 Y2 i' O$ H; ?6 N ' This is going to be annoying so don't really do it!
& {0 s( j" g5 ?/ H& i. P$ Q' r If changedBlock = ptsBlock Then- d& l8 v" U" V) O; P, O# F( q# }
If ptsBlock.SelectedObjects.Length = 1 Then4 F# U# w8 M+ L# `& x% J1 p
InfoWindow.WriteLine("You picked a Location")
, |$ G# a+ A. Z/ a/ I Else
- C5 M7 k% E) `& d InfoWindow.WriteLine("You picked another Location")$ [% [9 {& x2 u9 g( K
End If) I" j9 o3 F0 J- O6 x- U" v
End If. I0 |1 C+ l; ?2 t
1 E M9 ?' n* v9 h End Sub
/ S" k) ]5 w i5 m- t d2 T9 @; o; Q& t( W4 f4 ]' g
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer; B3 G0 z, i* T; g3 J* A
Return Snap.UnloadOption.Immediately; }$ |0 {( N2 C
End Function0 Q& ]. A9 i: i7 D: u Z- p
& ~, z2 S2 x) j8 r# L* IEnd Class
% B5 D# S; \5 R% h) I |
|