|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
" _% V$ N8 x6 Z+ O3 w1 M: F7 S
) G) D: {% x, N. t# j5 Q& Q- Z2 J( @0 n
Option Infer On1 Y. u* u2 {/ }5 K( z. J4 d
Imports Snap, Snap.Create, [2 f2 y5 X- a2 j7 t i" n5 U
( e3 J( D* i; F/ v; {% ?% J5 M! q' This is a very simple example showing you how to use a Snap.UI.BlockForm
8 L$ ~( u7 J" d1 e2 i! l* ?3 T1 W' to create a dialog that enables the user to select multiple point locations at once." I* p' j- e' g/ C" r7 T
1 W1 |# Y' p1 ~8 a& M" g
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm8 | E: t/ J. H# k
- H0 j& L0 M5 M" L" x" F
' Declarations of the blocks on the dialog. i2 @, @+ n* O: D
$ P2 E) V; L2 |4 z" A5 G7 T# H- m( D- a
Dim ptsBlock As UI.Block.SelectObject' M# k- [* X& N" T$ i F- s
2 I2 H5 ?4 M- p+ `( ~
' Constructor for a dialog object
# O9 w+ D1 ^, [4 I6 d5 ]: |# A! h Public Sub New()
1 f7 [6 y' \* p0 s% X2 ~- Q$ x7 i3 r2 F/ r) ]
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
. S5 a$ J7 ]$ ~, N5 C Me.Cue = "Please select some locations" ' Text to be shown in cue line
3 M$ @0 C. _; n( V
- }7 U% H/ J' Q0 \7 }0 G: y ptsBlock = New UI.Block.SelectObject5 U2 Z' r2 K& {2 V
ptsBlock.AllowMultiple = True* z3 R4 Y; z% B& P: y: f# a# w
ptsBlock.MaskTriples =
" K3 E1 \, k: t9 S7 r- Z, j {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}7 Y* d4 W! t3 G% k! y( q
ptsBlock.LabelString = "Select locations"
! R# J, q2 i' p& m/ o6 X' T6 i9 q ptsBlock.PointOverlay = True' `/ V/ q; R% u" ], I5 f0 {2 p
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)/ A: t) l) b" b3 c
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
3 T$ h, U' R5 W- o
1 W/ B6 h" Z7 g' d ' Add the block to the BlockForm
- y7 A" k1 b/ |, W/ r Me.AddBlocks(ptsBlock)
% M8 r2 K$ c" L; u) {; j7 }! d# v) [) |9 j& R3 X Y0 g
End Sub
1 l5 }( t2 b4 l. c# s& A
# ?+ w2 F' J# `; A Public Shared Sub Main()
9 X+ E4 A- w* k9 s/ B F$ i% l+ c- c9 ^+ O, m* _6 H
' Create and display a dialog2 u' M% H- E9 [+ g) ?
Dim myForm = New SnapBlockFormApplication2()
$ z4 k% p& ~. K0 v" l6 R myForm.Show()9 J2 F4 | j3 s6 n, S* q& \: U( Z: H
8 [. Q! K; T$ x6 e# c2 [! c- `
End Sub5 q% T6 l8 E) P& \& u/ f
8 D- z, l& \! ]$ y) v1 X, R' b Public Overrides Sub OnApply()) N, c- m% u& b! R
) x" d4 a' `$ n2 Z0 ^4 x+ _
InfoWindow.WriteLine("You selected these locations:")
7 Y' F+ f) [) m0 R
. b; \+ o7 b) K" `& h For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects# \: J, Q( E' t8 t
InfoWindow.WriteLine(anObj.Position) F. u, N- M2 D/ x
Next
4 R/ x1 U. i5 X- `4 P* c$ k
+ K5 ]+ } K" q( o1 y End Sub! Y& Y* \7 F# T6 G- m
2 Z) t: E- K* p$ J; R# X/ h
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
( ]& g* `$ x$ P/ c+ F H# G. k5 m8 b0 D
' This is going to be annoying so don't really do it!. R. u; V- b0 U1 y7 ]( w3 H( P
If changedBlock = ptsBlock Then6 k' I! B4 b$ v$ W# u7 ~% c
If ptsBlock.SelectedObjects.Length = 1 Then
: \- k6 a z/ ^4 m) K4 [ InfoWindow.WriteLine("You picked a Location")
+ i3 Q- [; S$ r# Z2 p, d" `5 O( [ q Else' v H: C2 @; [) q8 X
InfoWindow.WriteLine("You picked another Location")
# @( x2 ?: x( Q4 d' Z* Y End If7 n% {7 t: m$ C5 w% P0 u0 g
End If. B1 q( r1 w% ~% n
, r6 f1 C. h, P/ |1 _5 P End Sub
# Y: |/ U! x# [( ?/ _) y) M! s" l4 M
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer- @. F% J! k$ g% T3 q+ S
Return Snap.UnloadOption.Immediately
4 ]. g3 @8 o- ~# I- i End Function' c; T% R5 a$ d8 Z2 N
7 o* c+ L$ X4 d' Q6 o1 Z* s0 q
End Class6 E! s3 l2 E o5 [# ~
|
|