|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例" ?1 @1 ?: I* G8 A% x" a( e _1 f6 {7 S
$ @5 Y8 C% D- K: W% R- c% N( b! f( [9 R+ |- ^& ^4 `/ l
Option Infer On
" @* `' {6 |- A# ]0 [, ~9 i% k' yImports Snap, Snap.Create
7 G& \6 M7 y9 s. R ^5 N- K0 s! D' m' H* y* _; r1 }2 D% o) z
' This is a very simple example showing you how to use a Snap.UI.BlockForm
% o8 D7 |) W3 ]" e+ k' to create a dialog that enables the user to select multiple point locations at once.
2 d3 s% H& Q" W0 m& i
/ t5 M0 `% C6 d+ l# SPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
% y7 K/ |7 ?2 w6 J. c0 f0 u2 V/ K) _( Z: P
' Declarations of the blocks on the dialog
~' [8 r- I1 R1 k7 Z+ V" s/ O" Q; u8 ?
Dim ptsBlock As UI.Block.SelectObject
~( x' J& o A6 ~3 @ K" V
; ^+ h" M2 s* v7 P ' Constructor for a dialog object0 t- H$ q' F& j8 U
Public Sub New()
" b8 t9 k2 P2 w3 N6 h. v. |( ]' O" k, x* p
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
/ \( E8 s: V* ]5 h" Y Me.Cue = "Please select some locations" ' Text to be shown in cue line
; F1 a! S/ ^4 f3 f) g
) s' { T! L' q0 [+ c; L9 H& G ptsBlock = New UI.Block.SelectObject
9 |1 d" c" Z: f- _6 K8 x3 s ^ ptsBlock.AllowMultiple = True! J, q, m# V& | B. \, `' h, b
ptsBlock.MaskTriples =+ F6 Q9 C$ `( ^4 A+ ~- L
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
' E5 X+ ^+ q. d" @. y- l8 X ptsBlock.LabelString = "Select locations"4 ?& }# P1 Z) f5 S9 N. m
ptsBlock.PointOverlay = True
: P# i8 k; S' t9 B ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
6 I% h2 |# F9 z1 ]' h; {2 c6 u ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly+ F2 P4 V5 O0 g2 F6 z8 {( C# N2 i
" l8 @+ }8 Z! o' {" z) ? ' Add the block to the BlockForm( o, s1 W% E4 c7 k3 p( G
Me.AddBlocks(ptsBlock)
7 }, {7 {: R; v( H7 ~# L) g8 y# r1 W) r8 X3 O
End Sub
8 j. l* s0 l' I* M6 f( [4 X. z; `8 J9 {
Public Shared Sub Main()% e) Y1 s+ _3 v+ c* T
5 u. H/ d) o& g9 w ' Create and display a dialog
/ L; |9 K6 i' N$ V Dim myForm = New SnapBlockFormApplication2()5 b6 N5 q( y4 U6 C7 G9 a. K! `
myForm.Show()
8 N& q+ w" w, }! n- z. A9 T5 `, ^( H% U% c
End Sub
* O: V" y8 j* C" x% z" _+ K$ i7 `+ [
Public Overrides Sub OnApply()
1 m/ l w- A) h& k1 r
$ J" @+ h& ]( g; x, a" |6 i5 ?& j InfoWindow.WriteLine("You selected these locations:")
, q6 F$ V3 a% y- c/ I
0 p c4 g/ q6 `2 l: w6 q4 X) U( T For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects+ v% P+ P/ } ]2 B" Q" r6 ?
InfoWindow.WriteLine(anObj.Position)
- ^ p) @$ f, r3 M' m0 n- n Next' }- T; \9 C2 t) C) J0 m$ j7 C" A
% S' M: j7 K$ r1 W; W
End Sub+ J4 @$ D2 I* [, x/ J
2 v! K d; m1 ]) [% z& N
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)# i, y. x6 A: a
2 y6 d- l9 f+ Z) j- z) L5 C
' This is going to be annoying so don't really do it!( n9 G+ ?5 j: ^* T5 Q
If changedBlock = ptsBlock Then
8 g& }' G) W- O' e If ptsBlock.SelectedObjects.Length = 1 Then
# l' s! k; B0 {5 G InfoWindow.WriteLine("You picked a Location")
6 u7 J+ e$ l5 s ?- I Else" S: p$ E, f0 I6 s
InfoWindow.WriteLine("You picked another Location")
' S; y% h; O3 _5 N. W) } End If
+ W N) B9 s+ j' H End If
$ c# z4 s8 }% k( p1 A# ~3 w, ?* J0 X: z1 |/ Z
End Sub( \* D" U" q/ B6 R0 k; f
9 R: d; S2 U- X2 @3 K# r7 G( u* R Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer6 E# o0 S5 }1 K3 Y/ g2 A% u' v
Return Snap.UnloadOption.Immediately
2 N; f4 @$ W& e1 m5 [7 U6 O* b End Function
$ Z! ` v; {( g# s& k- W
/ K0 |% ]" G! H+ h5 e$ hEnd Class4 q6 j% z9 E0 N+ S
|
|