|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例3 F) y* d8 P8 }' N' O. \/ J
/ C; ?( Y) f7 q. }$ @! I6 l: \
6 v5 D- P5 k5 [" v6 @Option Infer On
5 ]" m& ~+ p/ bImports Snap, Snap.Create4 n; G* B; [- O5 W6 ~% y p' v
, M# Y5 _& p1 z) |' This is a very simple example showing you how to use a Snap.UI.BlockForm. X. G1 |" e2 {4 h" A6 V( Z! R4 s; m
' to create a dialog that enables the user to select multiple point locations at once.; b, B3 [+ [8 p. G* Y
, r! V" g6 i2 J5 e" d1 \! D3 q
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
* ~" r, r# ]4 D" [0 B: K' n7 w6 V4 v! p# n
' Declarations of the blocks on the dialog
) m$ b9 V! J: W$ t& C& V. f# T) \# I
Dim ptsBlock As UI.Block.SelectObject+ D! A& U! w6 }' p1 F$ u! G
' y: ]9 S8 p6 y: k9 O% q6 o
' Constructor for a dialog object
" P& v* x9 D7 I/ C7 l1 y Public Sub New()4 h [# _6 Y( _6 C% x
" y1 @; _, n* i3 g+ i Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog0 b( t. M; ^0 B9 o H! t- }) z
Me.Cue = "Please select some locations" ' Text to be shown in cue line: {5 e5 W) X$ H- I
( i& U, `# c( T: G
ptsBlock = New UI.Block.SelectObject
9 M& W1 Y4 a9 {, q& _' T" s ptsBlock.AllowMultiple = True
2 w7 b8 w8 w% ^( V. S ptsBlock.MaskTriples =
* S6 v/ O3 `* g4 p6 T {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
1 F8 O8 U+ |. m5 `) e ptsBlock.LabelString = "Select locations". F1 u3 D6 `( ?+ _3 X8 o) y
ptsBlock.PointOverlay = True
# }: v' `$ ]* T% y$ ]1 e$ `& K ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)1 ^6 t" C" Z' r) V
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
L; W) T/ }+ |! Z; b( `5 B5 R$ {0 g8 W0 s8 ^7 T! M' g4 q
' Add the block to the BlockForm
" r9 L2 @& p3 ?. U: y Me.AddBlocks(ptsBlock)
4 X6 q+ T& h0 v+ ~4 o2 o( l$ t; }3 t/ j# `) i3 b
End Sub
5 q( W. }* Q- r" {* q4 g* j5 n" v3 v0 l; D
Public Shared Sub Main()1 G) ^5 i+ h0 J4 T. O+ a* U# C
. a" S8 I$ A5 M# p ?8 L) q* E$ w
' Create and display a dialog6 p9 r" s9 n) E& x' q
Dim myForm = New SnapBlockFormApplication2()$ d/ l# @+ M; S$ i z0 z
myForm.Show()) o: _) C' m/ }& i8 Q+ p
* G) t* q6 O: `# B4 K End Sub0 k- f+ P1 ~2 `3 E! @- U6 n4 O5 N# [
4 ?% [( c4 L# d5 v Public Overrides Sub OnApply()* I. N/ H" p5 _4 ]; ^6 N3 L O
( e b8 f8 P4 p& b% ?+ X! i! R InfoWindow.WriteLine("You selected these locations:")
$ y& {' Y2 d P) j! k7 `. D1 Z ^' X" B" M
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
) |. e. Z+ Y; J8 B n2 P InfoWindow.WriteLine(anObj.Position)6 w: J+ H, A5 o. [) `/ x
Next
# t, c1 s* c! @& _( E5 Q. c, i1 h/ Q+ ^$ K# V
End Sub9 J, W! X: u" J( A5 Y6 y
0 N3 _1 Y$ g2 s: T( I4 x Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)' {5 F1 |7 t) x' u% e. M# M3 f
6 m& f0 V6 h, y" g! f
' This is going to be annoying so don't really do it!6 ]* a7 H& X) @3 V7 V8 a
If changedBlock = ptsBlock Then; \- | G+ U; m" D
If ptsBlock.SelectedObjects.Length = 1 Then
- y) z9 ]- X3 Y7 A InfoWindow.WriteLine("You picked a Location")4 \5 R! `$ ^. U3 V4 `, Z/ P
Else% y' s/ i3 S5 O' Y# n+ k
InfoWindow.WriteLine("You picked another Location")7 Y# f3 f* Y3 o5 }% E; r; s6 S9 r
End If
9 O3 F, v9 s6 W; b. |( K& J End If% e: k7 L3 _$ Q( f) A' x
# m; ]9 E% R7 V End Sub" \0 C1 B1 w* I, L
5 B- B7 I e8 ~ o# j
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
8 |- D) l% z8 X9 x8 z Return Snap.UnloadOption.Immediately
6 e! m# T! I2 U1 K& ] End Function& Z5 b p, q5 q! x& I& A7 {1 u
5 @( T/ b) V. _$ K! @, O- w
End Class
6 Q3 G+ R, B8 f5 E |
|