PLM之家PLMHome-工业软件践行者

[图文教程] 通过对话框选择多个点实例

[复制链接]

2017-1-16 15:27:51 4253 0

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2017-1-16 15:27:51 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
通过对话框选择多个点实例
  F5 w# H5 X7 u# B: o/ w: G) c% {7 l' B4 K' X: S$ a( x

) Q  }' e' j& K/ m- POption Infer On
5 N' F8 U. f/ B  ~Imports Snap, Snap.Create
1 A8 I5 j' e, q+ O( ]
1 p8 Q) F/ e- B3 C5 v1 }/ d' This is a very simple example showing you how to use a Snap.UI.BlockForm
* |  a- L4 n# b+ Y, U0 O' to create a dialog that enables the user to select multiple point locations at once.+ g. X/ D8 C5 S8 y

% `6 Q: G. t' o4 ^5 m( w( ^Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm$ |4 Q- y# [' u7 p  U4 W  o8 q

6 D: @. ], o" n: I    ' Declarations of the blocks on the dialog+ Z: Y& N1 G( a! k& X
& @) T  M' i3 @: X. @3 ~  y
    Dim ptsBlock As UI.Block.SelectObject
# a. ~: ]3 j0 `7 S
! Q6 L! u* a6 g  ]    ' Constructor for a dialog object- t" H. D$ T) k7 w& [; S
    Public Sub New()
% P; e. \* K) F1 ^. C# g1 v. A' J$ t# K
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog$ r4 b, F% L+ l" g9 x6 g
        Me.Cue = "Please select some locations"   ' Text to be shown in cue line
% ]- \% c4 u" G# X+ N8 D' M3 Y# ?- X, O% R1 W" J- _" `. o
        ptsBlock = New UI.Block.SelectObject8 _7 [* U. z8 B( R4 g
        ptsBlock.AllowMultiple = True+ v$ j# S) b6 D- I
        ptsBlock.MaskTriples =
8 t: t) x: T; Q7 M. F% U            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
8 x* O, o4 t! o3 M. v$ h5 j4 G) k8 d) n        ptsBlock.LabelString = "Select locations"
" ?+ q! c& q8 l3 h' {        ptsBlock.PointOverlay = True
! r2 t  B* f6 y" k' j: O        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
# T% u% @8 [2 s% G' [) F6 N        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
/ j1 L& h0 x0 E2 y* p( T/ W0 ~4 l- v/ {3 p+ T0 U
        ' Add the block to the BlockForm
/ G  ^0 ^5 @" |        Me.AddBlocks(ptsBlock)
7 {* c6 I9 N. k
$ w& q" [6 t  x6 B7 l8 t    End Sub
/ n5 Z8 L( I4 g% ?
2 h* f& Q6 A  `8 P+ e    Public Shared Sub Main()" p$ y. G+ u& E, Y0 M2 A4 O" G

3 |# @# z- J6 f+ n        ' Create and display a dialog
' x$ t" k9 X; M2 N' w) h        Dim myForm = New SnapBlockFormApplication2(). X  R/ b' p. L# K, X% b1 j
        myForm.Show(), @& d# @& o7 ^6 T1 h( N( R# s

$ o/ M' V* Q, T* G& J    End Sub
! h! N1 A, G. b$ c
$ S4 x: @% r3 f3 }" w2 |% S    Public Overrides Sub OnApply()7 o/ @1 j" ^, u2 k) z

1 m$ `1 U' F& Z9 c6 |( m        InfoWindow.WriteLine("You selected these locations:")
6 g* O: y! u8 g
1 W) U; f4 g! h5 H0 F0 ?2 t# y! _4 F        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
1 G+ R' f% `. ^4 C; u( @            InfoWindow.WriteLine(anObj.Position)+ O- v& y5 f2 m" Y7 U. P7 x/ U, @1 r
        Next
; X' T+ H9 N6 w# o
* d. ]: G+ r- f  q5 b8 e    End Sub
# {  f) n$ ]2 K8 |% `/ b, x
; g8 C' V* K+ j    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
  i6 X& e; z- L5 V; d# [6 Y$ L; F6 [
        ' This is going to be annoying so don't really do it!
5 {. L/ T8 V$ k% ?" G2 f" E4 x, H        If changedBlock = ptsBlock Then1 Z. W. G* w: k  n- p4 f+ F! \
            If ptsBlock.SelectedObjects.Length = 1 Then( }. Y4 H! ~- g9 G
                InfoWindow.WriteLine("You picked a Location")
: }+ A1 O2 T7 D+ q  m0 u+ A            Else+ ^. p) S! @1 J' \' s& N! a" I
                InfoWindow.WriteLine("You picked another Location")) r& A! r5 C7 V) e) u
            End If
6 K6 v/ W3 r7 L* ?- T  X& D' \        End If: R, d0 R* q, N* P) h

. C& _: a& G# M! @: ?0 w    End Sub' Y3 }, e3 o6 o: s0 M& `
6 K3 o- i5 Y" A) c
    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
) i5 w; j& f# }0 ~! d& d, w        Return Snap.UnloadOption.Immediately
1 d5 X7 `. f* c$ C3 Y) l    End Function
' T# K6 J; p) X- @! c: ~# V% P
$ p* g+ N# g3 G* t8 a% k! oEnd Class
% b, e6 G8 Q2 s2 G3 j8 f% {" ^
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了