|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
& B4 l+ H# s! o6 F* E; G! ^0 `( Z
3 @" H2 m- c. d
; e5 L) `8 [# _ O6 ^Option Infer On* l1 {3 D4 c1 W" U
Imports Snap, Snap.Create
+ h; W: N- g% V8 r! ?
z5 G+ j( T/ {2 b' This is a very simple example showing you how to use a Snap.UI.BlockForm1 q' z* A7 O6 R& H
' to create a dialog that enables the user to select multiple point locations at once.
, `" X7 M! i( s
+ D/ Y) W u2 APublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm+ L J4 K- g3 |5 t2 l
5 o- Y% I+ J1 ?7 d9 N ? ' Declarations of the blocks on the dialog
# I7 a/ ]5 c! i( P B
. D; I/ V# s; M7 q& I: s/ F& \- \0 U Dim ptsBlock As UI.Block.SelectObject
2 A% |: G# s, z; Z, Y
/ w& H- ^7 Q: y) x1 I0 p ' Constructor for a dialog object
$ o5 O" L6 z5 o* n( b. _& { Public Sub New()9 J# x/ `# k% |% Z3 N
* H; J4 C5 ?* z0 g- k* S( j- c2 y Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog) H4 }' u- Q$ a# j& G4 i# F" \
Me.Cue = "Please select some locations" ' Text to be shown in cue line
: X4 R& g6 ~8 u+ }" J0 q8 k# k7 w9 e U8 y; W/ s
ptsBlock = New UI.Block.SelectObject
! n$ P. c2 Z% F" P ptsBlock.AllowMultiple = True3 q5 h1 _* d1 O- a+ D
ptsBlock.MaskTriples =) u2 M1 j2 ~$ ? E
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
# r( c- {# ~! i- G2 K5 j ptsBlock.LabelString = "Select locations"
- N+ g" u' n$ t Y2 i ptsBlock.PointOverlay = True1 {' g% V+ _% \) p
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
K/ L5 c) Y+ O4 v2 ] ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
( R1 b5 s7 J, N j) m5 a7 Q! U4 n" `0 z7 o
' Add the block to the BlockForm0 _( N B$ {) _& ?
Me.AddBlocks(ptsBlock)# X9 S4 N4 ^# B* X
8 v8 k- Z" d* S2 f$ [/ ]& Z
End Sub
# [( i- Q; e+ U9 r( |8 Z) F1 T$ t
Public Shared Sub Main()
% `1 V( ?0 E. X/ V. D( |( W9 c; r; J; C# S- p1 ^
' Create and display a dialog
! `9 E$ |; k# j) g; E0 ^ Dim myForm = New SnapBlockFormApplication2()
# O: X0 O2 s" I- _* K5 x myForm.Show()) x) N$ B2 m3 J" a5 x
- z$ u$ V8 q" s! z9 Y* W End Sub9 v" T; P8 S+ W$ H7 Q
! f& L8 g) Q! V8 |8 B
Public Overrides Sub OnApply()
! x0 z3 R' ]# Q; E; ~- z. Q- b: N& y* U- `& \
InfoWindow.WriteLine("You selected these locations:")
2 y2 _& e/ V0 c( \& l/ s J A% z5 H# Z$ Q" Z$ m
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
6 f2 t" z- ^9 l9 _7 ~# s InfoWindow.WriteLine(anObj.Position)
% k3 Z+ g: c' u Next
; B& l0 E- V. O9 {3 V% g6 N5 o1 r" E. w% e0 Z8 j6 i$ L
End Sub. ?* K; Y6 r$ X) ^* f
, q6 o" u+ K" C/ {6 b1 j& S
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)" d* Q8 Z0 B `0 T+ x) V" f8 Q
: w% B- x2 j9 y+ \7 M, y" K; x ' This is going to be annoying so don't really do it!
t. j/ }8 r; r- F* A F6 e If changedBlock = ptsBlock Then
* W5 @3 e4 |( n) d/ Z If ptsBlock.SelectedObjects.Length = 1 Then, j! s: j; |% I) U0 @4 a4 F
InfoWindow.WriteLine("You picked a Location")
$ g% e! v$ t7 n$ I% k Else
% D* u3 {, i. l6 Q, [2 r$ m InfoWindow.WriteLine("You picked another Location")
0 g" h ?. ^( b: `1 P# T2 P7 ~ End If
; K& k& X8 d" I End If
% n8 ]) o0 a; C& |( ^8 ~# L* W( u3 J2 I! ]: g
End Sub
+ S ~9 L" P# o0 K3 G4 d
4 E# l* F9 O9 f Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
- y6 D* |8 L) ]4 f( i# U# k* o N Return Snap.UnloadOption.Immediately
+ `: O& ^# v$ ^2 L1 B/ R End Function9 z3 R1 t$ ~" k0 {
* S% F0 {& S& P4 H0 I% t
End Class
/ t/ i: X% y; r |
|