|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例/ n* `9 b# z9 q) m
# Q. e1 c H' R. Z) s1 i
: C* s) O' k* {) {! n3 }! HOption Infer On( l2 ]- p7 Y. }3 ^2 s
Imports Snap, Snap.Create9 u& z: l: h" _+ q8 T. I& h$ {
- H/ I5 n' j, S: [' This is a very simple example showing you how to use a Snap.UI.BlockForm+ u0 |( l0 u6 I" t/ P
' to create a dialog that enables the user to select multiple point locations at once.' Y; R3 `5 U+ E( T
4 H' ^! M. A* z9 L. uPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm! l7 A$ F1 }3 c2 Z/ q# s
) ?( `. v3 H/ o6 w% j ' Declarations of the blocks on the dialog( m( V3 ~: ?& k
b% |6 `6 X+ q! O/ N) ] Dim ptsBlock As UI.Block.SelectObject
4 j! h" a: P7 Z; {5 v9 \# M% j. |. t
' Constructor for a dialog object# |8 J6 F$ z' k9 F$ m1 l
Public Sub New()( k3 a; r3 |, f8 W! N& Q6 S/ j+ L
7 {* S' b Q& ^) \ Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
2 V, G: N, t6 F; {# S8 z5 j Me.Cue = "Please select some locations" ' Text to be shown in cue line4 R; s3 w4 Z) R X+ ~
; V; g& u9 ]* Z1 s
ptsBlock = New UI.Block.SelectObject
" ?5 R) C* G5 k" Y; m- h/ [" [( c ptsBlock.AllowMultiple = True3 S, u) u5 ~! u, O. {
ptsBlock.MaskTriples =( M: Q: h2 n/ P' u
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
. d; m- y- {$ T2 k ptsBlock.LabelString = "Select locations"
3 T5 j7 O- }: U" D& r. a2 I _' ~ ptsBlock.PointOverlay = True; I( W; T+ I: y2 h& S/ h/ M
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)1 c* k/ e5 F0 P% n; Z9 \
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly$ E1 H1 b* ~; \7 t' i
' a% s4 P+ @6 `0 r- f" T ' Add the block to the BlockForm" g# U7 I- T& O9 d! g, U
Me.AddBlocks(ptsBlock)7 S/ v1 G3 \7 f7 a& k* b
* S) j7 C6 M1 N8 t' e
End Sub
V! @9 s/ u/ w' b2 U$ T1 j/ l" `) {$ A/ [( C! p
Public Shared Sub Main()
0 u1 L3 W5 h! z1 s. H1 R
9 i+ ?# c0 s P4 ?6 } ' Create and display a dialog7 V; p5 V* F2 t" D: z3 x
Dim myForm = New SnapBlockFormApplication2(), @/ u$ r: z* L& O6 M
myForm.Show()! E4 R2 J* X6 s. Y
! s! G$ R# U" j) v* \/ {) _
End Sub
' v1 E! U/ y2 }" o2 j' B
$ p, E8 K+ k; q, ~: R. U Public Overrides Sub OnApply()
8 ^, X2 X5 v# x$ l0 e9 K- x }1 n( q$ i5 L! u/ _. O
InfoWindow.WriteLine("You selected these locations:")3 B4 ^) D+ Y; o6 ]# g% c
$ ~+ j& N7 ?; d) k) ?5 z# ]3 N For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
2 ? p" b/ Z5 o0 F InfoWindow.WriteLine(anObj.Position)0 O, m' F5 L3 }9 ^
Next
) p4 U# }1 ?2 C( ]7 |; H4 I P# T- M# `. W2 A; }1 K! C# y
End Sub, B7 U f% p& |
" M1 y6 w Y4 M3 ^ i Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)" E( `. `; R1 F! E: y4 {
% y, P, F$ b9 {' \1 W' Y ' This is going to be annoying so don't really do it! | w0 Z! Q4 B; ~5 F9 r/ o) A" n$ V
If changedBlock = ptsBlock Then
{8 a6 d" i) b9 L* s9 L0 ` If ptsBlock.SelectedObjects.Length = 1 Then
6 M! C& l4 h* W# ?. V9 n InfoWindow.WriteLine("You picked a Location"): ]) z+ v3 u$ B* p) Q+ [. k
Else
h# z i6 U( ~" r InfoWindow.WriteLine("You picked another Location"); W+ ~) a8 }) \* a: \
End If
: f2 C# g" J# b End If- F" ]: ]" A% ^ N
' I" C( T+ [# @6 s2 T8 z4 Q End Sub
' C: w$ R* g& v- g- C: z' j- ]& `7 v. a+ m7 O
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
4 H' ]' v1 g, @- R7 m+ D, u Return Snap.UnloadOption.Immediately
4 ]. Z% t3 X, M/ B End Function2 E o2 v9 k0 c- N$ [! P
* O+ \4 P2 M) o! D( {: XEnd Class
7 M+ L. V; E; x3 q9 L+ ^+ D1 H |
|