|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
" m5 c5 F( Y" Z8 b" F+ P5 u9 @. D' \2 |3 c
2 E% s5 p7 T; @) V* r4 _Option Infer On
" O4 O Q+ s6 ZImports Snap, Snap.Create
/ J% g0 p* A% j
3 l: C( \( |; }. P' K' This is a very simple example showing you how to use a Snap.UI.BlockForm$ C4 y" p. R- f* G6 T; i! Z
' to create a dialog that enables the user to select multiple point locations at once.
6 R( v8 l( P [( Q# ?
$ X9 X7 L# [, N8 e+ APublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm, j- k! k( M. @. n2 J
) |5 }, o9 M9 @; d ' Declarations of the blocks on the dialog" h% O: \, q8 u; I! x, z
( _9 O' Z2 l5 M7 P
Dim ptsBlock As UI.Block.SelectObject! Y; [" G- q( l5 t; b9 t
4 Y/ d& v9 d" y" v, |
' Constructor for a dialog object
; D- n5 N M5 m: ] Public Sub New()
- C( A: Z: B/ T. y
% q4 e" L. n7 K9 K6 y& W Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
6 _. i2 H% \0 Y6 c Me.Cue = "Please select some locations" ' Text to be shown in cue line1 q* o! W7 \, @7 H n# M" p
/ w3 _; e3 B3 H
ptsBlock = New UI.Block.SelectObject
# z: A+ Y# x" ~3 ~ ptsBlock.AllowMultiple = True. G/ T" D* e! B
ptsBlock.MaskTriples =
" v& V* @ h6 ?$ @1 a6 M/ o {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}( J' n( S& Q- j
ptsBlock.LabelString = "Select locations"* B) H% z# k- O
ptsBlock.PointOverlay = True
: {! M4 h9 Q1 w& f- Z3 H ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
- x8 h8 v8 a8 t" o ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly& J) d! C% O! [% q
9 w6 _/ B( N6 c+ t- d7 ^- W ' Add the block to the BlockForm
, h4 E8 y0 @' n* c3 p* ], ] Me.AddBlocks(ptsBlock)- k- ~4 i! R6 ]1 y. t
9 U! K) K& q2 g
End Sub
( r& o2 i5 [# Z4 l( D
0 F( Z! V/ Q1 Q Public Shared Sub Main(): y* |- g% C; Y/ L/ r* }3 u% P
- N/ C/ c) m( b
' Create and display a dialog; ~2 y3 ~5 {$ ^5 T- m/ z6 c, G1 {
Dim myForm = New SnapBlockFormApplication2(); F- S! H P% w' j
myForm.Show()5 h$ ?6 u" S+ T- ]- P8 O
; W! [) S: n) G8 g& A$ w
End Sub
4 f# q0 R9 k" [' N' y" Z9 ~8 `5 k/ V5 ?# L: Q( i" R& P6 r
Public Overrides Sub OnApply()# K) a: r* L2 h2 ^" b2 _, {
9 J; V ]; T' X8 J/ b: Y$ a+ H5 S' p/ B InfoWindow.WriteLine("You selected these locations:")1 N6 z( ~' z6 K( T1 u+ U3 B/ ^9 o4 \
% \8 H O4 H' \3 @; S$ o2 a a9 X3 k For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects! e: Y8 i2 s! Z) ~
InfoWindow.WriteLine(anObj.Position)
! J& `/ {" q l/ K9 _ Next
9 i8 R: u+ t% B
8 m% Y- I; r, M) Q. i( m3 P g End Sub8 l; \( G3 f$ p8 L1 H% Y, s
; ]6 |4 t) y1 K& m- F
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
7 g2 p' R' s: i, l a+ o
- G( T5 Q4 p% }2 K ' This is going to be annoying so don't really do it!% S0 h8 b' B% T" Q) d: @# I! |
If changedBlock = ptsBlock Then
# y! _+ C3 E `: T; Z! S If ptsBlock.SelectedObjects.Length = 1 Then
% N% J C- \' A6 D' a3 w/ k4 D InfoWindow.WriteLine("You picked a Location")
9 f. \0 M7 i5 S4 s* q, a Else3 y: P& n8 n: N3 M- c/ w: J$ [
InfoWindow.WriteLine("You picked another Location")5 ]6 x5 b: E" P% W
End If1 F2 q( O9 \& e" z# T7 e2 }
End If
3 Y) h8 [% ]) K* g3 j1 A0 K( f
. B" O$ {) g( m7 w W) h4 t End Sub
1 T! ?6 F; K5 i+ p# t' K) P+ \% b& @* l# X e9 d
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
0 ]9 J: T$ h$ p U5 r/ | Return Snap.UnloadOption.Immediately
/ s7 O8 e, Z) K2 s8 F; W End Function
5 R n5 w) e9 l+ y7 J$ L9 D- _2 i9 ?6 }- n5 E, P3 n7 K
End Class
1 z5 L# Q. L7 [ Y& W |
|