|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例
; v: y1 K4 l f- @( c1 [) I3 ~/ D' @ M$ P K0 {7 U
3 }6 i) S1 [' _- ZOption Infer On
* U0 y2 ^8 ^+ k/ M/ r. s5 _Imports Snap, Snap.Create4 r. u6 f# I0 X; a/ {$ F* [
/ A* x ?; `& `
' This is a very simple example showing you how to use a Snap.UI.BlockForm
1 H3 C. m8 n1 C$ _7 m5 \' to create a dialog that enables the user to select multiple point locations at once.
" C, w1 G( O4 r) N- Q+ k
- z/ v; t2 v* L8 e q* K- bPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
! f+ l( S# o1 j% T9 r7 }% @1 t2 {, l1 S1 R+ b, M9 i5 H$ ]* X
' Declarations of the blocks on the dialog0 G8 J2 Y8 G" W9 G3 g. k7 D; z
6 h; g0 q$ u$ M
Dim ptsBlock As UI.Block.SelectObject+ O* l/ d1 O. n4 G2 {8 }
+ l7 z8 Y# U4 n6 R- \/ k ' Constructor for a dialog object
: X( }0 W# y1 X" l, @8 c Public Sub New()
/ v0 w# [- i3 _' f3 ]) C! G, R4 ^7 J
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog, |+ m- C& ^" E, O- r
Me.Cue = "Please select some locations" ' Text to be shown in cue line
i7 [0 q+ C. F; C% F1 N5 \3 y9 U& {1 a5 r! Z
ptsBlock = New UI.Block.SelectObject7 T+ C: d2 w. C2 k2 [6 O
ptsBlock.AllowMultiple = True- D3 _' V+ W# i' l4 ~
ptsBlock.MaskTriples =" N/ Z' Y1 j; j5 A
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}% x0 g' w( h0 x
ptsBlock.LabelString = "Select locations"
: o# Q5 `5 I( W7 { ptsBlock.PointOverlay = True' e: |) g5 a- F, S* C6 H. z
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)# n% Z7 n9 N4 V8 m: ]+ n- [- B8 O
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly" T& D- x3 k7 T$ J
' `6 n/ B+ a* H. s
' Add the block to the BlockForm# I' M/ @5 n! c& S" f
Me.AddBlocks(ptsBlock)
; K# E' M Z: z, e# y) H4 W _% d" u6 k) V
End Sub
& p! K8 `: w- w) S+ E
f: s' p0 s2 y' d: d# [0 B Public Shared Sub Main()& C3 R& }- |4 s" m
+ k" ~* u7 M& Z9 E3 ` T7 ^ ' Create and display a dialog2 Z1 x# {- J4 C4 g) b8 e0 S# S
Dim myForm = New SnapBlockFormApplication2()
+ [$ l/ e# ]* N5 v, o, u1 M5 y/ A" g myForm.Show()
: z2 O" y9 `2 H& D) k" Z! J& _$ R, s$ g4 c
End Sub
2 b; \# }: ^! ?# X, y) I; l1 s# Q& P
Public Overrides Sub OnApply()9 Z: t# E; H) a9 Q g( F
7 `- n0 X4 m& K0 c2 d' W InfoWindow.WriteLine("You selected these locations:")
( ?( ^! d5 h' P9 u/ l- U4 E/ `% l \' O: u4 p0 f# p
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects4 q6 @" M8 F2 h. b1 g
InfoWindow.WriteLine(anObj.Position)
& X4 s1 S2 l* c/ F- k) g5 H Next
" a! g: c- s2 e% z3 y4 d2 L) n( r: i, J
End Sub* g2 O4 P+ s2 j
. Q3 ^& `. |9 |- P1 L; K- ]: h Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
% O. G. o2 U) ?6 g0 T) S/ a; u ~/ g. ?+ U
' This is going to be annoying so don't really do it!# l- {. _* u# `4 h
If changedBlock = ptsBlock Then9 v, g/ }, o/ B5 _
If ptsBlock.SelectedObjects.Length = 1 Then$ j, @0 Q8 C+ M1 f! _
InfoWindow.WriteLine("You picked a Location")
% x2 O0 H' c: F" U' P- { Else
5 ] N6 j$ s% q0 ]0 i InfoWindow.WriteLine("You picked another Location")
8 D6 r% E3 D$ {! Q End If' k7 n6 r: ?' X8 j$ s* t) v
End If( G9 B& h) W) n3 S
' W* s; M- @% ]7 r% k7 i7 r8 o End Sub
/ _! g H) A' B4 \ o
- y! y- v9 H; P9 b2 p Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
& T# f* _6 ]- Z( I( S" ~+ U Return Snap.UnloadOption.Immediately7 H2 k: ~$ t" @1 K* c( A6 k3 X
End Function
: C* i' R% X" K) ~7 {/ P6 ~* B* K8 R0 n0 ~3 U9 D
End Class" X a1 Q1 J# I/ _4 |9 E: \
|
|