|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
7 W( J9 Y+ \& Z, u8 Z! i
- D% r& K2 v# G2 ~
4 O: [+ ~6 m0 ~8 DOption Infer On
1 D4 j3 H; S; }: Z8 g& q1 y4 ~Imports Snap, Snap.Create ~% _2 F# o K+ B
+ q, r7 e0 P. N; I( P' This is a very simple example showing you how to use a Snap.UI.BlockForm
1 T! I. k6 _) T: `: k- t C' to create a dialog that enables the user to select multiple point locations at once.
# u8 o! N4 L3 M9 q6 @& S( f6 Y2 G4 |% u! k) J& ^/ P9 ?
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
4 W; r+ ~/ G- D" f( ~, K
; z, n5 |, a2 n! s5 { ' Declarations of the blocks on the dialog" D, S# V; h+ A7 Q3 g0 \, k
2 y! X5 |4 F# d9 f' s
Dim ptsBlock As UI.Block.SelectObject
8 h8 m( X- R* G' ?9 w6 ]! t0 F) L5 `, y% l( n( m( H( {
' Constructor for a dialog object3 u$ x! U3 r& @5 j3 ?' [7 }; k, C
Public Sub New()
5 r; I. C9 D6 J. o) E+ v8 K7 h2 ^6 A' h1 y1 Y N8 _
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
: c9 I* T' s7 ]; U; Z. U Me.Cue = "Please select some locations" ' Text to be shown in cue line2 A7 M; V: v& |
/ ?. H3 |9 l" }- S7 W ptsBlock = New UI.Block.SelectObject. i3 a! d% }: C# _* z3 w
ptsBlock.AllowMultiple = True; q7 ?' h, N2 {$ |6 ] U) ]5 J0 l
ptsBlock.MaskTriples =
# k' F, e, O) z% s5 r6 e {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
$ s& P) I2 Z9 W3 x ptsBlock.LabelString = "Select locations": l! |$ L& |2 Q* m6 J: l& d4 [
ptsBlock.PointOverlay = True5 }- n2 a2 } i" b" q/ m* c9 m
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)2 E, f' u$ ^4 I$ e s6 k- _- m
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly, i7 ?# z8 i; W, R( P4 z
% g5 G" g) s% D6 ]3 n# H ' Add the block to the BlockForm
. l2 i+ d0 P" S Me.AddBlocks(ptsBlock)
( O* d3 W- `0 G% D5 u# e6 I0 A) Q8 d1 }( ]9 Q
End Sub/ H- I* p# n& p4 r0 h
2 G- K7 x; W. }# o( ` Public Shared Sub Main()# ?# H0 l2 \" u4 A3 c0 ]! U0 H
) d( d0 F4 p+ k9 k# U7 F+ {2 r$ T
' Create and display a dialog8 I! a# r9 B) n. f
Dim myForm = New SnapBlockFormApplication2()
: c2 B3 B% i: J, c myForm.Show()
4 @0 e$ w- T2 L
2 |8 Y. u/ r& j End Sub& ?% B" u" c8 Q. a0 S
9 Z9 V( Q. U9 ]: @9 p
Public Overrides Sub OnApply()
/ B) M @' ?5 B- h1 E/ U1 B1 C$ ~- z+ _+ Y3 a% C" D8 D3 I
InfoWindow.WriteLine("You selected these locations:")
9 j& F" e) z' F9 [! m
% A1 U6 X& p- N$ A, x0 G: M For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects" @' I1 Q6 m: O- M: g% s9 t
InfoWindow.WriteLine(anObj.Position)
3 K! s. Y* U G0 N# ] Next
`" D7 L- t2 Z, ~% {4 R+ \. j; u6 O
End Sub' i. J& w; @. e; u& u2 i
( P( N+ X) n8 F Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
% @, A3 Z4 g6 }9 s6 z. { X
* _4 j) u% W' v ' This is going to be annoying so don't really do it!4 T- Z ~" w) q* B! o0 ~2 ^# Y) C" q$ a% m" X
If changedBlock = ptsBlock Then
: H# b& ^' W- e If ptsBlock.SelectedObjects.Length = 1 Then
# I" l0 }) Z+ K9 y( e( O InfoWindow.WriteLine("You picked a Location")" [! O0 U* w$ `% p1 _
Else- {; j) A* X7 k/ b8 }) @
InfoWindow.WriteLine("You picked another Location")' v% x2 B: C8 T m W) u
End If
$ `# Y$ w' m `1 s/ `3 N+ } End If+ t/ ~# e& Z! M" j% J+ Q4 W
j; Q1 n) Y" r! a& d6 i$ E End Sub
0 Z/ b O( q% p t# K# L" U! S' _# G' r7 `- H7 B) l
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer& M5 Q/ J+ M7 R2 t8 {0 [3 r7 r3 F
Return Snap.UnloadOption.Immediately
- W1 y$ o$ }3 i2 k- d/ l! b& M1 f End Function
' j @" f9 C9 ]) v6 a- `( n4 V+ i0 h& p
End Class
- y' w/ F# a: }6 S7 u6 p) S/ t |
|