|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
2 ^ C& V- v g7 g3 R5 Y( f- ^( e
1 t, q' v3 y. i& G$ F; U0 V0 _; i' [# s
Option Infer On6 v1 p* H1 z$ y+ _2 U! q; f) q' b
Imports Snap, Snap.Create5 R5 L& P0 x( J5 J' F. j
7 E6 h5 e5 R/ [8 Z/ r! h, }1 j
' This is a very simple example showing you how to use a Snap.UI.BlockForm* e& s' P4 k4 d2 Q
' to create a dialog that enables the user to select multiple point locations at once.9 P3 a5 b/ g, f- A: X( S; g
. A: o5 X- q; |. A6 c0 F! d
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
3 {5 Q% V/ x% L3 [- n0 g1 [& W7 z3 |3 a# O4 H
' Declarations of the blocks on the dialog u( q: @% P7 h( w: e
# L8 ^! D V C Dim ptsBlock As UI.Block.SelectObject8 W, y E6 o* O2 u
* ?' c6 Y* |6 T7 k
' Constructor for a dialog object# T* m5 r4 `8 W/ i
Public Sub New(); ? A/ |. i; X3 {; M1 q" G
" _- P& z! r" b7 n3 O0 h ^
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
: {1 Z+ [! t% _) |1 A" u0 z Me.Cue = "Please select some locations" ' Text to be shown in cue line
2 H3 i* z7 U: Z* x. w/ }! t3 g% `
6 Q q/ s$ q4 U& z+ p6 _0 q) a ptsBlock = New UI.Block.SelectObject
' |# o$ Z: A2 \7 f$ \5 p3 }" c' C ptsBlock.AllowMultiple = True! m2 f( R5 K3 X+ C5 F
ptsBlock.MaskTriples =
4 e' a2 f6 d! g/ l1 C {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
7 l8 @7 Q6 g9 @9 w$ o; f ptsBlock.LabelString = "Select locations"& V2 t2 N: r/ ]) _1 D8 O; k
ptsBlock.PointOverlay = True
/ y: F7 ~# H+ n/ s# S2 \ x ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)& c$ ]7 Y* V& B: C/ k+ m& q' L7 ~
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly- ?" ?; B# [# T7 \& t9 q2 U
# j0 P' W% o- i* t ' Add the block to the BlockForm( ]8 l |/ I- x
Me.AddBlocks(ptsBlock)6 g0 B9 _/ j' r! y/ n1 Q
9 i: J: j( j0 g/ ]
End Sub
" E( }% T0 Q7 Q& e" H5 E4 K5 y1 L) f8 F- F
Public Shared Sub Main()
3 V7 m* {: d- A" ^' }% M& Z8 ?3 h; _' h X6 e- L
' Create and display a dialog
' e: g! t( m* g$ S- m- e% { Dim myForm = New SnapBlockFormApplication2(); x+ v, Q- \- q( n' u2 W# Y
myForm.Show()2 Z# q6 b: ?; P- ?2 T
& E6 F- k2 X; T3 n
End Sub4 N, C, j% R: A3 Z, B) p
0 O& s0 O9 D; X) }' I: P" ~7 Q Public Overrides Sub OnApply()
: z' i5 G7 i% {! L/ `3 u b1 X* k8 X' a( f# H7 e
InfoWindow.WriteLine("You selected these locations:")% E; E3 N; ^% ~! Q4 S& W
* ^1 {# z1 X& o% }
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
7 X( C: t# J7 @; ]7 B0 e; g- Q- _ InfoWindow.WriteLine(anObj.Position)! W* A" i% i. m/ [& |: G) Q9 e: |' a
Next
, [ _# w' a( |4 L8 O) |& k8 u9 U7 W# F1 ]9 T
End Sub2 T. W0 C1 L5 S/ I% Q2 t+ S- ?
8 d1 M3 w2 Y/ f; j# y% H: Z Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)' T0 k/ C r9 v6 D; U
# K& b: [2 ~4 m( s! h ' This is going to be annoying so don't really do it!
4 d1 V3 S5 t5 i) x# v If changedBlock = ptsBlock Then. l+ U1 f0 J F% S6 D/ T0 J+ H3 O7 L
If ptsBlock.SelectedObjects.Length = 1 Then
1 X0 y- {. s3 d InfoWindow.WriteLine("You picked a Location"): G3 \) t; z/ |, p. b" q
Else/ d. Q# R- h# {+ G, U$ W2 `& |8 o9 E
InfoWindow.WriteLine("You picked another Location")! d3 F' Y9 m2 O, a1 |7 y* W9 `) T J
End If* R; j b. [8 v5 E# ?0 L
End If
1 w: z+ a, Y+ V9 b
4 l: S$ q* _. X' _ L% t( O( i End Sub
& m, E3 R7 h3 D1 b) C
- }5 q( G9 p& { Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer7 u% u" r$ m+ \# x* t0 g
Return Snap.UnloadOption.Immediately0 G, B2 x8 Y7 D9 I4 p% P
End Function. Z3 m& W2 C$ L- o, P' H. j
8 V% s6 y/ |" Z! _* Y. YEnd Class
- B1 z6 u. l0 ^8 F+ } |
|