|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例& Y9 j0 D8 _% O: X0 v q
: h% A( u& w- n! C2 t
& N3 {: ]! U3 ~4 n* `Option Infer On
' w r- B+ s( } L; JImports Snap, Snap.Create
# r2 Z' i6 b! C/ s. K2 x( R1 [& Y6 n- b* B/ m% O
' This is a very simple example showing you how to use a Snap.UI.BlockForm
2 M3 }6 m+ h2 M( L! d! u, C' to create a dialog that enables the user to select multiple point locations at once.2 X5 o' ]; X, Z
: d' G' S2 v( k# _4 c2 U- JPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm' A9 `+ h& P: P- B' ~# ^
, ^2 q( \& G" p( j6 u) ]4 } ' Declarations of the blocks on the dialog- L2 D6 d# S/ o2 }& y5 k0 y; ~5 m' w
R' E0 B' p# }1 h% R! ?5 Y
Dim ptsBlock As UI.Block.SelectObject3 G# b3 j* P! l7 r% d% \) {
. j' L( t$ g0 E
' Constructor for a dialog object' {; f! e4 N' Z* g0 Z
Public Sub New()
- L( k5 r& H% d$ Y& g& w( ]8 T4 e$ I& X) z. M" F
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
x, @9 N' X; y, q% {( i* U4 w Me.Cue = "Please select some locations" ' Text to be shown in cue line
2 j4 j1 d! R: b& w: z: Y i
( ` k# j- Y6 i: n) W ptsBlock = New UI.Block.SelectObject
D8 w' O0 V, s# }8 H ptsBlock.AllowMultiple = True
* l7 Z: l1 g; v& \: p: Q ptsBlock.MaskTriples =
3 G0 D# U9 k8 Z2 h8 y5 d {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}4 o; `4 |' _/ Z) z7 b j( {: Q
ptsBlock.LabelString = "Select locations"2 _7 D% `1 ~, b* L8 a" L
ptsBlock.PointOverlay = True- P, W( R8 U( v! {9 \
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
/ R' w7 Z$ g$ x ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly* v; z. R+ X9 p# j A" V
+ s! O8 q) C9 R: e8 Y5 i
' Add the block to the BlockForm& u5 C' E% q3 s6 T: J! d
Me.AddBlocks(ptsBlock)
; l4 U1 m# a+ s3 ]# z+ @5 `2 w& h. [3 X) U
End Sub+ `) ?9 k/ f/ z6 e* K, }
0 L X! O: T* g8 s+ [8 u$ h
Public Shared Sub Main()
, X+ i. f9 b$ v$ ~7 w3 K% W; H, }! A( }6 U, Z- t+ n# C, c
' Create and display a dialog& |7 ]: s! E& o, A9 P
Dim myForm = New SnapBlockFormApplication2()
: G# r: i! h) U3 ?1 Y$ r" x$ d myForm.Show()- I2 _7 j# A3 w+ i, b
/ ]! [, @' k- t7 O# G E
End Sub& R+ z$ n$ A W$ N* U. b0 ~! e% D
. z- e! Y/ e0 Z Public Overrides Sub OnApply(); P* R3 K- `" I, O. o3 S. H" W
+ ~& e: @) h2 ^4 z3 b1 O7 a
InfoWindow.WriteLine("You selected these locations:")
( j! |8 u1 z% G' P0 Y C3 t& Q4 T5 }9 \: f' ?' q$ U2 ?* a
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects: [/ [; n8 b; c# Z1 C# ^8 ], f& q
InfoWindow.WriteLine(anObj.Position)
; k* Z9 l- } V! K# U- N3 \' f2 E' q Next
/ X/ h* X# h c, o. O1 _2 U" V, n8 Y+ e& f2 s: f
End Sub
8 y6 ^1 l" ?. b# z9 J2 j& S1 m* `1 v. h
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)5 g( K$ Q1 d1 _" _/ i, G
) C3 q5 P% k. S9 m. P F. J8 y ' This is going to be annoying so don't really do it!
1 V4 o; }3 I4 y* g If changedBlock = ptsBlock Then
+ {; d* f) l q3 \7 z$ ~( ^# F If ptsBlock.SelectedObjects.Length = 1 Then: `% \& g _! ]% d. [9 x# J4 g) j
InfoWindow.WriteLine("You picked a Location")1 F6 a8 {+ {7 P1 ?9 \1 g
Else* L, F, {+ V8 O: B' a
InfoWindow.WriteLine("You picked another Location")# L+ Y$ E' n3 J, n0 C- T
End If9 A( w! v" s5 P
End If) _' N% N6 r4 {
0 X% m }9 Q& T1 ^5 P1 E
End Sub
* {( g( S# T/ P' J g$ k8 I- D' W4 J9 L; z/ M# P. [+ `
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
% @* I8 n2 E5 M% q) g* g/ q8 P0 X. X Return Snap.UnloadOption.Immediately/ E% m" @1 ] @, A
End Function& Y' [) z- x \; o& G; p6 ^
6 q1 p2 B @9 c* O
End Class" T; T& Z% C; h( W/ b0 _
|
|