|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例2 D5 X }0 r0 K" h; f' i4 F
1 K9 J* h3 L# l
3 H$ A- ]! h B6 I- ~# k
Option Infer On
, z' Q" @: s3 s, p7 O- S/ OImports Snap, Snap.Create, j) t% F6 a' ~$ a0 i, K5 |
9 g, J; e; g1 m& @' This is a very simple example showing you how to use a Snap.UI.BlockForm
1 ?# \( x1 C) D' M9 T, b! R+ G' to create a dialog that enables the user to select multiple point locations at once.' t, ^6 y. m2 g
/ J7 D% ?- n6 i8 f# MPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
& P0 K, B1 [/ C$ L% ]" S( ]
* z3 R* q0 I# m2 F ' Declarations of the blocks on the dialog8 ]/ |; \* r4 \0 K1 t7 O
# W0 d5 P$ H( x7 \6 K
Dim ptsBlock As UI.Block.SelectObject
7 R4 z1 k$ j8 Z
. ^3 `- G1 G9 p) W7 c; v0 N; O ' Constructor for a dialog object
, H2 ]; W4 @5 N0 V7 h6 a9 d Public Sub New()
8 G# s& M; |: v& O7 o3 V! K) z8 q+ r1 x* A; Y/ {5 |8 N
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
2 @* i, P7 ]% R1 T! @, T Me.Cue = "Please select some locations" ' Text to be shown in cue line2 H: N, `( j9 t) ~
2 }& S$ h" ?, t0 \- \8 ~- ]$ N3 } ptsBlock = New UI.Block.SelectObject" h# P9 q% C9 A4 V; R
ptsBlock.AllowMultiple = True
6 I' V: I) x- S3 f: V9 R ptsBlock.MaskTriples =* h$ K m/ V/ C7 F
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
1 w3 e" c% t# o6 m/ W: _ ptsBlock.LabelString = "Select locations"5 h1 `5 q2 \0 U0 D( S& L& X2 G
ptsBlock.PointOverlay = True
' r/ D/ }& o9 J) Q+ e ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
) S7 C9 D2 l. b3 ~8 p7 u4 L ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
9 U ^/ g- s. o1 X7 n: c; {& _- F
$ {% l, A) ?4 Q9 g7 t4 I; S5 d, k ' Add the block to the BlockForm6 Z- M% K3 ?0 ~0 O! J0 |! ^; q: O( C
Me.AddBlocks(ptsBlock)4 \( U4 F/ }8 n3 ^' Z
9 m* k" q9 X( f& x End Sub
; {' w+ g3 i3 w' C, k9 `- u- x. ^- F
Public Shared Sub Main()
3 W4 i( D$ Z2 m t0 r, [7 N5 L
m: [: O0 R7 U7 c! O: P; U$ ]' _ ' Create and display a dialog
1 Y) D8 E' X8 ~9 j6 u/ f& V$ o Dim myForm = New SnapBlockFormApplication2()
. a; }: l; b, \2 d6 @( a3 j myForm.Show(), L* n" S6 x5 w% v, n
* j q# F0 j% R8 x. F, y) Z- N End Sub' Q- r& z( g0 [! d0 J
* o- d3 N+ ]2 v! j) M, ]5 |
Public Overrides Sub OnApply()
4 }. ` c8 x5 W" D$ u W
5 f6 L: @8 V- }# h1 ]( ?5 C InfoWindow.WriteLine("You selected these locations:")# [4 c- q" N9 o1 i& \: n
. D' k! C4 l. T) W
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects/ H9 ]. Y x2 M M7 R6 ~0 Q2 {/ i
InfoWindow.WriteLine(anObj.Position)
7 l: M5 b+ z8 J. p' y0 F' i Next
: w2 l0 M( Q, o0 Z; Y! t; y
0 H6 j- g5 K$ i0 R End Sub
: Z1 }6 z3 K5 r9 d: K3 Y
4 H T+ W& ]! N; j! h% b" U Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)$ Z" B7 I- ?( `$ k; r' c- S( v% o
`; _: D: @2 N6 ?% q ' This is going to be annoying so don't really do it!5 H3 Y' k, b& l x
If changedBlock = ptsBlock Then
% H, _8 o2 U; r; b( G If ptsBlock.SelectedObjects.Length = 1 Then/ D" ]6 L& b% d3 v1 }" Q. {
InfoWindow.WriteLine("You picked a Location")$ V! b6 e3 u0 L5 }& t. i6 n2 R1 ~
Else
1 n- C; O/ F' w. D8 ^8 U; L- ^7 U InfoWindow.WriteLine("You picked another Location")
) Z2 Y4 k* Y. K) F& P ?) C End If2 Z# q8 M8 g6 G) _" p+ ~( W- D3 r
End If
9 u) G1 ^) K9 R9 M( K6 p
$ d; y% y2 }3 ]* K8 |& h. d0 D End Sub% L2 t6 N I' k/ ]! G7 F5 W8 p
# ^4 a, O0 ~4 `* I# l$ I9 g) m/ j4 a Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer2 m7 s4 v5 l Z
Return Snap.UnloadOption.Immediately
9 E: e5 s- o$ @8 a# u a End Function/ O6 U' i% _( f
% J% @+ U0 [; L& N, f9 f3 W3 `End Class0 ?5 Y/ v4 O0 c! w% Y) d, B4 x
|
|