|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
通过对话框选择多个点实例5 Q* \/ b: A9 |
5 U3 w" m; v, L( T E; m8 u) J9 d2 r! w2 D
Option Infer On
5 b; J! u' L3 F7 L9 X/ d# FImports Snap, Snap.Create t; ~1 A* U7 w3 L L5 O$ m' j
P- h3 K. t* r) R$ i. A' {4 G! K
' This is a very simple example showing you how to use a Snap.UI.BlockForm
5 l2 z; z3 q/ L0 ^. A, d' to create a dialog that enables the user to select multiple point locations at once.
* K* x7 \% ~/ Z' C& K3 z d, H& a: G# Q. Q& O4 }
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm3 X* _2 ?3 W4 Z$ I4 y! [
/ I( x% b7 R3 R
' Declarations of the blocks on the dialog
8 h5 t- }8 g: T: e2 E3 ^. P, A) E- d2 M0 b& c/ f1 n, V
Dim ptsBlock As UI.Block.SelectObject# ^% B, [' I" [/ `7 m
! f, F7 r- ]9 \! b5 I; w0 {
' Constructor for a dialog object9 k) D: t4 b8 R- k! D8 q$ e0 @/ D
Public Sub New()
8 H$ y( p/ t' W- c8 ?: } o. R. A
Me.Title = "Select Multiple Locations" ' Text to be shown in title bar of dialog9 _+ v6 N: Q1 l5 C. y; U0 M$ \
Me.Cue = "Please select some locations" ' Text to be shown in cue line
* e- G+ ^) s& }7 k6 I- m/ S, f! t* ^% L# O6 N. G0 p% T7 @
ptsBlock = New UI.Block.SelectObject
2 E1 C) T- v7 c0 s ptsBlock.AllowMultiple = True
1 I+ |8 u0 ~& S' v2 U/ E( B& j' i ptsBlock.MaskTriples = R0 n& x, {8 \( W) |7 j
{New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}: U" d6 f; Z$ \ P: e) L5 J4 c6 o
ptsBlock.LabelString = "Select locations"" v8 q `; x$ R% E0 u. c3 y. ~
ptsBlock.PointOverlay = True7 G" Z- E* c5 C; }, V5 V. D4 v
ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)& L8 K" i3 A8 ]6 |8 R
ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
9 l: o6 b2 q3 _3 \2 Q: h# h! y! N
6 Q0 C$ G6 `7 |4 l. N. C# s( c ' Add the block to the BlockForm
) C* a& L/ c0 X% F! i1 u; u. [ Me.AddBlocks(ptsBlock)- c1 Q6 d; ~; V6 V
d: A1 M1 V$ F ?( v& b" D/ S End Sub
& F) p# D s4 b/ E1 ~4 Z/ c& R {: F, [0 G1 ?
Public Shared Sub Main(); _4 S/ ]0 g2 r7 A0 c3 y
8 m7 F7 V9 G+ C$ W; M) X
' Create and display a dialog4 v; J) R# m1 a {
Dim myForm = New SnapBlockFormApplication2(); g9 M* R7 M, C% U9 M, U# d
myForm.Show()% ^7 Y9 ]; \* }% `* [& t4 }( }
. ~4 [( D! i% h* {9 B& X End Sub$ W4 i. J4 |0 H ?4 Z0 R
h% I, D' T1 C5 h" A3 I Public Overrides Sub OnApply()* d6 ]: D/ C' P" @, k1 U, r7 X
3 |) w! m- C/ f1 D
InfoWindow.WriteLine("You selected these locations:")
! C8 c- t& _# G" ^. [$ P$ c" d4 I8 D/ S8 ?2 _: J3 J9 F0 z) q
For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects/ J- ]$ ]- A/ F
InfoWindow.WriteLine(anObj.Position)
: c/ S1 u+ ~3 n+ g9 w- w Next& M) S6 [. j( E7 B
' G% s; c5 w; p: Q/ L+ u
End Sub
8 j* @& h0 |+ I. N- f( ?! K; g4 r6 N* u2 O5 U1 z
Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
3 g% o! _& B# F9 R; d3 z
* a# z* H. F) m5 c% @ ' This is going to be annoying so don't really do it!. {0 ]( Q# `. c5 D$ Z" R$ f- e6 `
If changedBlock = ptsBlock Then; N. ]4 P4 T5 x H
If ptsBlock.SelectedObjects.Length = 1 Then7 j" F# }2 S1 e. @0 T
InfoWindow.WriteLine("You picked a Location")9 b3 P2 _, l) Z# Q. R) H) Q I
Else9 r" k) A3 n7 v( A% |
InfoWindow.WriteLine("You picked another Location")
0 w. {9 K. a; C2 C3 t2 q End If
9 P8 Q" m7 G3 r8 T( @ End If
/ r8 k4 P; e6 a2 }5 n! e
) b' ~# d8 @4 O7 j1 x. q% n! Q End Sub; C* z$ o( _0 a6 }, [
# ^3 A G3 l6 D( n0 a& @! t7 } Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer, @) F. I1 k: `6 C( `
Return Snap.UnloadOption.Immediately; w: u+ i. V' l5 {/ s) o
End Function
2 b7 w" j5 [8 J5 D8 m
& z' ^* X4 ?9 E4 k8 U( T M4 t5 XEnd Class: m5 ]1 x& { ?
|
|