|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例" [' A+ Y2 B9 |
+ a/ [3 ~- N# P; l, P
/ ~- c7 p' e3 K3 oOption Infer On
7 H: v8 W) k/ e* w6 ^Imports Snap, Snap.Create( L$ t/ d+ z6 q" |
, _% D0 u5 s2 e( T- i1 D1 y
' This is a very simple example showing you how to use a Snap.UI.BlockForm4 }- H( R2 D" b( Z" m6 f3 E
' to create a dialog that enables the user to select multiple point locations at once.
! D7 o; N0 Z5 j/ O8 q! ^' ]
3 j) ^6 i V* DPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm, P5 G6 U: L3 O$ Z' d
8 g& o+ M- t8 t
' Declarations of the blocks on the dialog3 q% k7 m# G V5 S/ v1 F. p1 Z7 _
9 {6 n4 o' s5 t# q( j- A3 ~. ? Dim ptsBlock As UI.Block.SelectObject6 @* l1 A: A6 @5 X
7 G1 E, ^1 p6 a
' Constructor for a dialog object! `4 f% u+ y- `7 ^# q$ {
Public Sub New()
5 j. y; M! b7 c- ^9 T7 g( N
5 X7 z9 r: r2 g+ Z; f Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
% c) J9 H) v0 y# Y+ Q C' D Me.Cue = "Please select some locations" ' Text to be shown in cue line7 ?1 O4 m6 C- c1 K. M* b! K4 g
" r* H- V& K: T/ N ptsBlock = New UI.Block.SelectObject0 k% N4 W- T6 m, e. e3 f
ptsBlock.AllowMultiple = True
7 s9 ^5 y8 A& X ptsBlock.MaskTriples =0 b+ M+ o1 A# D* v1 V7 F2 h
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
) D9 N( t' I/ S! L2 O% G3 t ptsBlock.LabelString = "Select locations"
9 d$ }' J& }9 r: G9 X0 w7 X ptsBlock.PointOverlay = True
+ {* o6 f6 L0 i- E& t ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected), N$ U$ \1 ]3 t& t$ h
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly5 u* Q% C0 e# S+ F% p
, \ l2 T. H1 Q& `" O; c ' Add the block to the BlockForm, x9 h! U5 q" P2 C
Me.AddBlocks(ptsBlock)
( Y3 h. Z" E; q+ q* u- b3 N7 t8 Z6 N$ d% ?! n
End Sub
: G* d; D5 c6 f$ Z; t, _
" w$ P4 x, T4 x& t, }8 r# h7 p9 b Public Shared Sub Main()
z) H2 |/ {9 Y" T( V
4 u. m4 Y1 i- E. E ' Create and display a dialog
/ y C9 R! |+ w6 x/ S Dim myForm = New SnapBlockFormApplication2()& l% x& [- A' ]5 n5 e% c
myForm.Show()7 W8 z4 k- a; i4 J5 K
$ ?2 Y0 n. b/ x9 W" s. j
End Sub7 `5 j5 ^ {: G
7 k" X p: V' u, }1 K Public Overrides Sub OnApply()
& X' K0 e, K- A, G z( i5 ~7 D# O/ F6 ]( W& ^8 w K
InfoWindow.WriteLine("You selected these locations:")1 x4 t" A( _ S( I; K _! Q5 N0 p& W" v9 s
5 u/ p# P$ j/ Z7 m
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects) G( H9 t% d `3 N8 [% t
InfoWindow.WriteLine(anObj.Position)
( ?! c2 X; P# z% R( B6 I) L Next
4 n+ ^ ?$ U5 _5 R: k* a: u+ T6 f3 ]& O4 n3 g
End Sub- B! t* E/ {7 W# `9 ]
6 p: L$ o: `: t$ ^, S
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
* H$ ~- C J0 w
6 K7 I4 J" z! {6 g$ Y: w ' This is going to be annoying so don't really do it!' Q9 j2 n# Z: W# g m
If changedBlock = ptsBlock Then
4 M& E3 N: @$ Y7 T5 ` L$ w8 I. Z If ptsBlock.SelectedObjects.Length = 1 Then1 I. G4 d3 |9 |3 u$ N8 }
InfoWindow.WriteLine("You picked a Location")9 ?% C0 ^) M8 X$ e8 `! V/ ?
Else
1 K9 r. t8 i# q! y6 O InfoWindow.WriteLine("You picked another Location")4 S* S m: f$ O4 K; D" O
End If; s: X+ A; }" |7 I/ }8 f: Y
End If8 E- h" o% o, N5 a' Y3 K
8 a0 ^$ L: I, {# S1 z8 _
End Sub' M4 G" ~9 Z* T0 K
3 C2 o0 c) ^+ u Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer8 f! j0 g, @* a( H5 A! \ Z% J" l; s. m
Return Snap.UnloadOption.Immediately
( t- c) C, } q. @5 @ End Function
: |5 U, Z9 O, U
$ C: I O- g3 T8 F5 O4 v# YEnd Class% I4 [5 U9 g4 X% V+ i% x
|
|