|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例2 z/ J! l- o. w: o8 n, u
n7 x# D! s5 k; X2 C
4 ?3 w4 o8 q) | [6 p2 ` f3 b" x8 c, VOption Infer On; m( u. Z& C" ^- [0 g
Imports Snap, Snap.Create4 [* [* {( f. c
7 K6 x& G0 j- s$ N& J( R }+ ~' This is a very simple example showing you how to use a Snap.UI.BlockForm( N5 s) v' z" h$ r
' to create a dialog that enables the user to select multiple point locations at once.
0 ]+ w7 t' o: |+ Z+ Y) b& X
& \; L; E+ G$ \- CPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
, m2 f" n; l9 p# e5 |" Z/ Z2 i6 R
6 R9 @- A6 o! G, T6 r ' Declarations of the blocks on the dialog
% o) V8 Y1 Z& R( `% v! Y; \7 B E! s2 p( u3 A; ]& M
Dim ptsBlock As UI.Block.SelectObject
( Z% [/ G; J2 E2 O
( u: T6 ]/ F2 B- g1 v0 S ' Constructor for a dialog object
, _2 b- @: \7 r' c Public Sub New()
" p6 @, L7 [9 J# P" q
: |, O; j: V$ c6 h Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog9 O% X5 B3 C% M" [5 }( o, c# h( R
Me.Cue = "Please select some locations" ' Text to be shown in cue line7 j4 H7 |* k& k: y
0 Z, E, j s# K0 ?& S" m& o$ z! [
ptsBlock = New UI.Block.SelectObject
" o( ?$ D0 ?: S$ { ptsBlock.AllowMultiple = True& [ p& @7 ~$ s9 x) m
ptsBlock.MaskTriples =
j6 d" C# x+ i- V0 I0 r" c! H: m8 a {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
, M0 L# e5 X+ R! W: R/ \1 p ptsBlock.LabelString = "Select locations"; P9 A4 d6 R& l- e0 f6 f+ o
ptsBlock.PointOverlay = True
: b9 a# o0 C; L+ t' @8 p; l ^ ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)5 y) K6 J7 Q8 u
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly; J! j" _+ B: G |/ Q0 V1 w+ a
7 `5 n* v. M/ l4 k" {4 Y, ` ' Add the block to the BlockForm/ t6 p' m Y% ~0 c. Y
Me.AddBlocks(ptsBlock)* u# t9 u" n. I' {
1 R' w* _* u' [, r End Sub( P) c; r- R/ O g7 z4 w
H( C% h9 \1 N% e8 ^* h
Public Shared Sub Main()2 |: Q# r- y W4 w! `
) s3 x5 z, U: C3 d8 N' h p Y4 o ' Create and display a dialog, Y& s) Z0 k2 n
Dim myForm = New SnapBlockFormApplication2()
7 o. |- I. M) O5 N myForm.Show()9 ^. g) z; n) f! F8 w r/ M
* g& c0 T, W& t% s
End Sub1 ?% ~8 E. }4 x2 |# a
$ f- a p7 x# Y( \; Q5 f
Public Overrides Sub OnApply()- S% [* @5 Y) `! D6 j. q5 ~9 g0 M
6 L1 l( J7 j" }- c
InfoWindow.WriteLine("You selected these locations:")
& f3 y2 c$ v) W/ v. Q& B- F' C1 ]5 ]
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
* L/ W5 p/ ^3 {3 Z InfoWindow.WriteLine(anObj.Position)% r. V. v# s! E/ k5 t# U$ T2 [
Next
I- e9 Z. N% ~4 r: b6 ]; o/ ?: L3 N
End Sub
8 P* P2 s. T# L7 a" K! A! [4 Z3 c1 W
& s9 l4 V9 F2 c& c$ ? Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)8 b N( Q Y3 k' J& i+ @* m( c, Y% O, H
9 H% z" e! g4 t4 V( N ' This is going to be annoying so don't really do it!
3 B, [. ~# N1 z. N7 e9 s If changedBlock = ptsBlock Then
; i/ z# p, U7 G8 g6 p If ptsBlock.SelectedObjects.Length = 1 Then
2 W* Y i; ]; V$ i. \+ F InfoWindow.WriteLine("You picked a Location")
& C6 ^; _8 z5 T$ x9 n7 }: c) D Else
h; o* { u8 }0 L/ f/ \ InfoWindow.WriteLine("You picked another Location")
8 {2 S, a8 [1 U2 ?) g: W/ \ End If
% T$ k- I5 H+ @* B End If( V. S/ @4 ]4 N( @% u8 |) Y: k+ F, T
1 Q! ^- Y }$ \; r e/ f
End Sub, [* ?/ P( N! a! r
0 w* S" y& q: ?2 \7 h- y1 ]
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
* P) U3 U& k. d# y- A G Return Snap.UnloadOption.Immediately1 _' Y0 R1 M+ t) f# t0 Q
End Function. D7 ?: H6 Y/ j. H8 }. x2 t
0 j f# J. t. C1 `1 o( ?6 uEnd Class
% R9 `* A$ \' ~1 O |
|