|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例; E7 K& ], _6 t
7 q% A, \3 q L* i, Z, }) x
5 T7 e( I M0 [; ]6 W7 \
Option Infer On
/ O+ i$ r6 Y! Z6 X+ }2 y+ R1 ?) c0 A7 tImports Snap, Snap.Create
) M9 D: w( l- b3 V7 m4 d% U" H0 v$ g6 r4 l
' This is a very simple example showing you how to use a Snap.UI.BlockForm
7 m/ S8 p/ g: N) I7 ^3 i; T" i' to create a dialog that enables the user to select multiple point locations at once.9 A* b" L# p, z
( e2 U3 T c6 y5 Y& [* I4 @5 Q/ `5 Q
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
7 K, k2 |: V! D2 K# [4 h! Z
2 y* m U, `) \. ^* ]6 k( ^: i ' Declarations of the blocks on the dialog
7 b7 X/ d# f& n$ M
( O) _" l$ P+ D5 f, x Dim ptsBlock As UI.Block.SelectObject1 A" ~! c1 x1 N3 v
6 I0 ~$ o1 O' L1 }' H, J ' Constructor for a dialog object) ^( u# p0 {( f: W+ `9 R0 q
Public Sub New()
" w8 a! d p. k. n
; `* \+ w9 o2 m0 m1 X; `3 W. I Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog; Z( r+ j Z8 B5 P3 Z/ B
Me.Cue = "Please select some locations" ' Text to be shown in cue line
6 p* V, _% B2 }+ V) V0 H
$ v: e7 g' S' y8 w ptsBlock = New UI.Block.SelectObject
M' Q! Z1 W; o. k ptsBlock.AllowMultiple = True
: m2 R1 _$ J9 l9 b: R+ c ptsBlock.MaskTriples =
0 p. ?3 m" J: b U* [ {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
" F, G1 ?9 _2 [% ?* F6 J: K ptsBlock.LabelString = "Select locations"
8 K% ^9 y8 }9 A; D ptsBlock.PointOverlay = True @/ H: a6 ?6 \- j2 k
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected) I0 t4 W- e2 O' O& A
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly6 B8 ] \$ j- P; u. P& ~, X# }8 X
2 i8 B! L0 |! _4 ?- F# w" ]* b" ~ ' Add the block to the BlockForm
8 \. a3 s) N8 P2 N, ~7 N Me.AddBlocks(ptsBlock)
+ a! I2 K r! C0 V$ T3 G7 [& }4 l$ x1 I' c
End Sub) c: a) u, j1 M
6 w" {3 p$ a# @) M! c9 c# i9 ` Public Shared Sub Main()& i3 L8 p) ]5 N: @
' J) w! q3 N, `7 V4 [# E, Z- N
' Create and display a dialog- G! l+ H" o1 q, p0 u
Dim myForm = New SnapBlockFormApplication2()" I1 U+ c/ p- Q
myForm.Show()2 O; e" M, ~5 V/ }' o6 p- t3 d
; y+ |# O U3 l. p% T. z End Sub
; k j% j6 z% O9 M+ a i z% P- k% _) z* w+ ?
Public Overrides Sub OnApply()5 F6 H1 p9 N2 f& n' o3 n7 V5 M
: w! \ D: C. ^7 b) B
InfoWindow.WriteLine("You selected these locations:")
1 L; |, i" h% O; o
O0 c" b3 {# J For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
9 K, k2 I) h) D: ] InfoWindow.WriteLine(anObj.Position)6 n- ?2 ]( i" [; M S: H
Next. L0 |3 {! [ w2 a! N
7 Q/ j/ @9 e5 o+ } End Sub- ]3 w5 i& ~* ]* I# U9 b
9 _0 x6 {. o) c: q2 e
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)& U" S3 p7 q# L |' L
}! K+ e; k/ s" V, ]9 h ' This is going to be annoying so don't really do it!
1 ?6 ^/ a0 x! T5 [5 h! \ If changedBlock = ptsBlock Then/ f; n* O j% F6 J5 o7 h4 N
If ptsBlock.SelectedObjects.Length = 1 Then
( V* p( B/ V4 [5 B InfoWindow.WriteLine("You picked a Location")
- r* I% r! L' L. [% Y Else
0 e9 X, @5 k4 p2 v InfoWindow.WriteLine("You picked another Location")) `+ a* d7 C. O
End If2 U! P' U- J5 z% Y6 s9 m$ c
End If
* p6 T6 @( p# R8 H, q* b' Q
6 P1 M l; m# u. ?* u" q% u End Sub
; f/ z+ P6 Z0 r- `
3 u# H& W- M n" \' z* z Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
1 K" B# L. g m4 b Return Snap.UnloadOption.Immediately8 O9 X2 h7 P- S6 K. L. Z1 P# T S* K
End Function
2 L- ^; @& W6 y9 U. x B9 J1 Q& [% d) t- c
End Class
6 s; g2 A- \. x- F: D |
|