|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例) I2 g/ D" F0 w+ j: p b( Z
4 Z. D" V d% d( [" L" U
: ?% \, m9 [! i0 c7 z8 I7 fOption Infer On9 q5 C& y! P: C( W# T+ h
Imports Snap, Snap.Create
! I2 F) m* \$ G u5 L+ W
4 x3 q0 ^) D1 C& _1 u5 v' This is a very simple example showing you how to use a Snap.UI.BlockForm
( v+ j# h. x6 A4 z; g+ S5 e' to create a dialog that enables the user to select multiple point locations at once.+ p# M; e' ^7 r3 D3 |6 _; @% L+ ~4 Q
' i$ z. c0 l! t
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
8 Z. v0 ~0 k) Z3 F& d6 K3 A' O6 J! E( p4 T! b1 y
' Declarations of the blocks on the dialog
2 w5 X: i. T U+ t+ f& _- @3 h+ V: l. n/ b* W! ~% W
Dim ptsBlock As UI.Block.SelectObject) t, O$ J- B" C8 j
) ~3 s: `1 }4 U, m9 @! t' L ' Constructor for a dialog object
# R F, [5 @/ D) E Public Sub New(), `9 U, `% ^! T5 M- ~& B2 I' u
$ @/ l) G* L' V& V Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog
, f" ~5 t3 R+ o8 p) B Me.Cue = "Please select some locations" ' Text to be shown in cue line4 d1 k% n, D( a/ c$ e# m
4 m; }+ Y( Z4 p+ y' b7 g& `
ptsBlock = New UI.Block.SelectObject
! r- d/ |& L5 } ptsBlock.AllowMultiple = True/ J# x' s% p f4 ^: A
ptsBlock.MaskTriples =
$ M" t! \$ q6 u7 f9 Q9 k G {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}+ g9 v& g& D+ M; P2 V( v
ptsBlock.LabelString = "Select locations"6 W9 C; U; \- _" o/ b
ptsBlock.PointOverlay = True
8 _+ n+ K; F0 l/ [% ` d& F: _ ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected); a9 V) M* o J0 V2 J6 A# [
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
8 V4 ~+ Y' m, D- Q- z; `4 m# l% O5 V9 o6 p) ]* i# ^
' Add the block to the BlockForm
, c! v/ D0 i- m Me.AddBlocks(ptsBlock)" T; i6 X8 N; Q& h! d# U" G
8 f7 @0 u( _& X, L/ p4 ]3 y$ X# { End Sub
3 f; M; K1 x: @( P7 ]* T! P
9 }: b; I, o9 r5 n, J. [/ J Public Shared Sub Main() b/ A* i# i. ^3 A
# P y2 [- W$ i- A! P
' Create and display a dialog
2 t7 r9 H2 z8 a) q Dim myForm = New SnapBlockFormApplication2() i. J) E% v A5 k2 b* Y
myForm.Show()
0 |0 _0 W3 {# C; e1 s2 x( K# ?4 h! B0 b" M
End Sub
5 k: u7 [$ s, F6 e7 V: c9 g) Z- o5 l! O- T) _! R% q, }
Public Overrides Sub OnApply()
; b* G$ A9 R, c. t+ Q
; ^; u# u. m0 ?) q/ H" v InfoWindow.WriteLine("You selected these locations:")
3 I( V4 r. I( ~* i0 P1 N; O- i; R2 b9 W) P2 P( _
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
; T0 j8 s' K, r* [& p& b$ I8 i- W InfoWindow.WriteLine(anObj.Position)
7 x, U; p- N% Q3 k Next
* F7 M1 S4 I% Z; G( S6 C6 ^/ f
End Sub1 u$ z: ?$ @+ w; H; P& @$ I
# b% s0 ]5 t9 l }$ v Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)8 [4 n# \$ F- ^6 T. T; w) A3 o
& v8 h0 C, V. x$ q, o% y
' This is going to be annoying so don't really do it!
' o7 ?+ \7 r- P6 a9 ^$ b0 H9 q& ] If changedBlock = ptsBlock Then
$ r: I2 e/ ]! E# @) {1 m4 G- m5 p If ptsBlock.SelectedObjects.Length = 1 Then4 }# B' W# Z+ d- F$ M
InfoWindow.WriteLine("You picked a Location")1 u: p# u" k6 e
Else, q! |! s! p7 f# ?
InfoWindow.WriteLine("You picked another Location")# Z2 }3 i; m1 p
End If7 ?8 x& ^9 @' ^: ^/ ^, G
End If& \- U- ]7 a: M1 N; Q2 M8 N
# S, F0 b4 i& y7 x( F0 I* | End Sub
0 S. v) @# q D% q! ^' S) |9 ^7 Y3 J* H: x2 `' f+ } k/ L; I& T
Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
1 }7 h5 I _. G, K; @% z Return Snap.UnloadOption.Immediately- S& g3 a* E: `! @8 R
End Function
# ]+ B5 v( c* s' S% ]# T4 k
- ~, N, _, z( q# j# w1 [End Class
: O5 o- I8 B3 x5 W |
|