|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
# R4 E$ N, R. |0 \5 t) `9 c$ {, {. ^
8 ?: J7 c) \& \+ fOption Infer On
% [6 s9 q9 O. W, H" W" }" l( JImports Snap, Snap.Create
, v. Q# u* y0 y, H4 N" ]8 `
7 M: p) a0 ?6 X& y7 R" G; h' This is a very simple example showing you how to use a Snap.UI.BlockForm
4 q& @. z/ U/ u$ }" z$ Q' to create a dialog that enables the user to select multiple point locations at once.4 H. V4 ^+ O+ |9 P
; q# m8 I- e$ I# F/ `: ~% ]
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm0 Z3 k* E3 F5 U- a5 o% R; H1 [
; A2 l! v) E# s# o
' Declarations of the blocks on the dialog: {3 [) g! E1 n2 M% P
v5 _2 |7 Y# h Dim ptsBlock As UI.Block.SelectObject
6 b! P4 O7 y. ]7 f, B( Z5 J9 v5 f
2 M' C; T1 ?9 [8 a ' Constructor for a dialog object
" c6 v( d. c9 {) m! l) U Public Sub New()
' M- m( M3 w- ~1 O" E4 s; O0 Y( U( P+ Q2 R) j1 U* U% G, X
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog/ u4 C8 K/ w' M G. h6 ^& `
Me.Cue = "Please select some locations" ' Text to be shown in cue line
: Q) V1 }7 `- L* `3 ?' t; Y5 g: d
4 A2 c# E9 Q5 ~' S: m ptsBlock = New UI.Block.SelectObject/ B% \- x7 x4 e9 l n6 h* }
ptsBlock.AllowMultiple = True
l' d$ l3 y+ d, i& V ptsBlock.MaskTriples =2 J/ J% X2 O4 ~. L5 T: I- O# }2 e( @7 g
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}8 ?, f5 T3 s+ |5 q1 p# d2 f
ptsBlock.LabelString = "Select locations"* n& Q# m: a4 ?' {+ L
ptsBlock.PointOverlay = True
% d( _1 W, C/ | ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)' o0 i" g" }/ e5 c, ^( l# ]3 F! E
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly: R% C; @" ]4 O: q
+ F- X$ r* J& a: ^+ d( `
' Add the block to the BlockForm1 y, i+ J- V. y8 v
Me.AddBlocks(ptsBlock)+ w3 L9 c% m R) p( {" C4 p, N
^2 S1 e' j Y g) _3 U! B" Y; j
End Sub
3 P$ ?2 K5 f: l0 t( R
6 Y# S4 A. y, u! }) ~ Q Public Shared Sub Main()
9 t7 y- V/ d9 S2 w4 S+ B5 U' ?! z+ P$ n4 ~' v& I; l
' Create and display a dialog( @+ b3 f& ], Q3 L: u9 a. D
Dim myForm = New SnapBlockFormApplication2()
" N6 P' A& F0 [3 @& I myForm.Show()
) c9 T, y5 l" y6 Q) c& T* U' M3 P5 [2 O3 j! F
End Sub
) \- E% u. P# W' ~% _) W
$ F6 N" H1 J; X& g; X3 h, ~ Public Overrides Sub OnApply()
( [. x3 D7 H, Y
1 Q" S$ K% n5 h" z" M+ W2 ~$ I5 ? InfoWindow.WriteLine("You selected these locations:")) z) Z' C+ t1 ~' H; u$ }6 @
0 f5 b6 N' P E0 [4 N9 _ For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects, C4 Q, z+ K' r4 Q/ j
InfoWindow.WriteLine(anObj.Position)
, R _3 N6 k) w- y. U Next
" q7 M) x: h9 d6 ?6 ]6 g" ^7 z' ?" ?# N
End Sub
) r! Y* J3 R7 K4 j. {8 s
: W$ r4 e$ i# }8 f) { Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
9 e: W: A+ S1 ~: W& Y5 y. A8 q8 [- W9 A
' This is going to be annoying so don't really do it!
9 X Q4 u0 S1 a4 P, T* I' X2 l# a$ a If changedBlock = ptsBlock Then
$ f) H% _8 U9 ]- Q; F) X If ptsBlock.SelectedObjects.Length = 1 Then
( a: U' y2 M# r) V9 p4 V InfoWindow.WriteLine("You picked a Location")# _# A G; N& x6 Q2 r( R
Else3 e2 x: U. V) r7 e! h& A8 d
InfoWindow.WriteLine("You picked another Location")* Q, u- T' T( Z9 F8 A
End If0 R8 U4 `9 F9 [4 q' ~
End If
3 Y5 Z z3 S2 [$ @! v6 i7 k) a4 x6 e, y7 _$ ~
End Sub7 ~- R# E* W( M% N4 r
. |! r$ C4 D2 ?/ Q _( v" l* t% p4 Y Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer2 p9 T. t& M! U( f5 s1 k6 d
Return Snap.UnloadOption.Immediately7 v" W- J1 a5 N% J/ ]2 B g
End Function! x+ H1 t2 {- L8 C+ Z: o) c9 S! P
/ i# }! C- m1 K o4 |End Class
4 l, {- o5 T/ {+ `; v! T3 W |
|