|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
" p& a5 Z4 `: }: T& g1 p. j1 m) k' u* o0 @6 A1 ` F1 ]* K* |' W0 B
( Q' P; T, Q9 h. R
Option Infer On
& }( m7 M; k( LImports Snap, Snap.Create& K* {0 r+ A1 O+ P( l3 T0 I
: r k( E7 x; O! N, t: E3 l
' This is a very simple example showing you how to use a Snap.UI.BlockForm
k! ?$ p8 w' |. d0 h- i! z' to create a dialog that enables the user to select multiple point locations at once.% F7 W5 I, C( T5 }7 ?: {
' } Y B! f& yPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
5 g5 |8 G! v7 C8 H# U1 S8 j; Q+ \9 W/ B; M+ e' H0 F
' Declarations of the blocks on the dialog( Z* A; J8 r- C1 u
) F. F: h( E0 H) ~0 a0 e
Dim ptsBlock As UI.Block.SelectObject
% s6 T3 s. T" w5 s
" L' ^* m& p& }# B+ |! D ' Constructor for a dialog object _) h+ O' [: D! s! s7 J
Public Sub New()! m/ y8 E% a, E" k4 [" t- _- M- T
- n | ?2 K: R: N7 [ Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog% Y3 K7 W7 f4 j& ~
Me.Cue = "Please select some locations" ' Text to be shown in cue line
, I( r# K$ U" ]4 v9 ^' U) B5 s7 @5 t( C0 N5 i8 s
ptsBlock = New UI.Block.SelectObject2 m% k2 O+ W- [4 R; f
ptsBlock.AllowMultiple = True E$ G6 x1 Z; `, m3 W# c/ j
ptsBlock.MaskTriples =* I3 L. t \& H# g9 ^$ [9 D6 X
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}2 W$ @+ n6 o# _% l0 w
ptsBlock.LabelString = "Select locations"5 k' k3 V; V! w" E. v0 i
ptsBlock.PointOverlay = True3 A5 p3 |7 O9 _1 b! P, G
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
3 W: j% A' @5 D. Z( \7 q ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly: j' `6 ?' w9 x4 Q) V$ Q$ J
. Z! a+ f0 ]- \- H- s ' Add the block to the BlockForm1 w3 W, z, P* Y+ G% m8 x
Me.AddBlocks(ptsBlock)' O) \: J e! F: F0 {! u" t
0 ?( o) o( i1 d
End Sub( B7 E- j# X1 K& M% ~9 M1 W
; }; O5 T# g) P2 {
Public Shared Sub Main()
P4 @ @* t5 r! m5 N# T0 I9 n4 a1 O1 a7 @: s: w
' Create and display a dialog
3 _6 N; W* B* V1 [, |& J Dim myForm = New SnapBlockFormApplication2()
6 @1 f% n0 y) e( y3 B myForm.Show()7 q, c% s+ t {+ `7 L' d
4 i+ v. T9 e; V End Sub$ y+ z- \, I% y2 E# R
( h3 i" r- P8 }
Public Overrides Sub OnApply()' ~4 {0 \( }) g0 \
5 t2 o# k1 g% H( a9 h G4 k
InfoWindow.WriteLine("You selected these locations:")6 D2 L$ }! r/ e+ }
0 ]( j0 ?! T" |8 W) M* g0 y/ z- d
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects8 b$ n% s2 E# t. G
InfoWindow.WriteLine(anObj.Position)
" t9 Y# L- {7 M. V8 M3 r# ?9 J Next
' {& l* D0 p+ t3 Z/ i% C$ l5 f" k7 D; Z9 N1 i
End Sub
7 j0 t9 M2 ~7 Z) F: q# ~% Q: J# l: a+ |- [8 g) v
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General), @2 o9 x8 l3 p$ ]! S* M
* L/ ^3 `0 l; [ @& q: y ' This is going to be annoying so don't really do it!, N o9 {! T/ z) e9 w
If changedBlock = ptsBlock Then
- p* x1 M+ l8 f9 ~5 X If ptsBlock.SelectedObjects.Length = 1 Then& w1 H2 v# X3 ], h& W+ `0 P
InfoWindow.WriteLine("You picked a Location")
* E E" y7 q' f+ n Else9 x! Z! I! T2 {) o; F( i+ e
InfoWindow.WriteLine("You picked another Location"): {* F9 A/ x5 B+ o( p+ a' E
End If
* I, k7 X- i3 y, e1 B End If
( [& j/ \+ n; Y; k: P
# V+ R6 S( Z6 s& k End Sub
$ d) n0 U9 t9 @; B# k! c
& X8 p- i% `; u! n2 w' f Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
. K3 c) Q& _3 m5 @! f8 R Return Snap.UnloadOption.Immediately* I( h0 U4 B/ x
End Function
! V) t6 f( h0 Q% x. n. j3 K: i$ g H# A+ m. F
End Class; D6 _7 {' P8 B9 @1 u9 a/ s4 P
|
|