PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

admin 发表于 2017-1-16 15:27:51 |阅读模式

admin 楼主

2017-1-16 15:27:51

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

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

x
通过对话框选择多个点实例
8 @3 _9 y6 }9 w/ C
; H0 F6 C' r- i; A0 {7 t
  }) E3 e5 V9 q4 LOption Infer On( I( D& V! N  g" x' T' V6 Y& r
Imports Snap, Snap.Create
$ t9 D1 h  _( }" N* |+ U9 ?+ n; z" E; t" n
' This is a very simple example showing you how to use a Snap.UI.BlockForm8 z; d$ q+ J$ j! ]
' to create a dialog that enables the user to select multiple point locations at once.& F3 a. ^! i' Y/ h# M$ W  R+ b1 |
- l- M! D! }( G/ O
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm! s- p3 ]( v! e1 |1 f# Z7 E: A
% [. c! F3 y' K4 K
    ' Declarations of the blocks on the dialog. p+ H2 I2 f3 |' `% C7 O
1 G+ o, `; g. B! @2 L
    Dim ptsBlock As UI.Block.SelectObject
; p" T; h( X( C( d2 J$ F0 S
& Y0 l# R& ]& h& g! N  p6 m, ^    ' Constructor for a dialog object/ a0 z1 U  E& C3 v& r5 W1 {% ^
    Public Sub New()
# P0 C6 u" [4 l+ b7 a" P6 o/ M4 [7 c8 {: L/ E, \+ ]
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog
/ {. m3 Y  I4 q* h# Q        Me.Cue = "Please select some locations"   ' Text to be shown in cue line( b6 c6 i+ D- Z; L
2 P+ D7 w9 n& Y9 f% `+ g
        ptsBlock = New UI.Block.SelectObject
1 G# n" @5 R6 r8 [; \. k( F        ptsBlock.AllowMultiple = True
1 N% E. u) f1 f9 u7 f4 V3 {        ptsBlock.MaskTriples =
6 g: \9 o( a  R. S/ |) o            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}
) c2 {/ Q5 M- l$ J6 i! y- @* Q+ _4 V        ptsBlock.LabelString = "Select locations"
5 {( l& P+ }) s# O        ptsBlock.PointOverlay = True5 h2 m# ]5 ^1 C" O0 _  u
        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
7 y' ^! E# k8 b( M( [5 M) z        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
0 d+ |7 p9 r' y) F5 S* ~  _6 a" p) s0 T% n
        ' Add the block to the BlockForm
# E# J; z* j% N, M        Me.AddBlocks(ptsBlock), G' @  {$ @# ]7 z1 D& I

: g3 s% t1 ~! _( K2 C    End Sub
1 a, C+ _4 Z- N* N, F7 \, A9 p, t: c1 G
    Public Shared Sub Main()
9 D- s0 J! B$ V+ R6 A/ A+ o/ c7 u( w' O/ P$ B: y: m
        ' Create and display a dialog* J# E" e# D# D9 X& c1 U" w
        Dim myForm = New SnapBlockFormApplication2()* J2 ~- E4 p5 ^" H& u9 h& I
        myForm.Show()
% U5 e  j, H: h0 p. R6 b' Z& B* z# c: Q. T& ?( s
    End Sub( a4 t8 e4 U- w, G  t2 y

- i8 G" d+ _  ^/ L    Public Overrides Sub OnApply()/ ]+ Y8 F) f  q: s! _

( q' |' o! C0 N# i5 ?        InfoWindow.WriteLine("You selected these locations:")% F. J9 b+ p4 B" _, X

+ f- A; E4 |5 B7 O  s& T        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
$ ]8 y3 C* g/ ^! y            InfoWindow.WriteLine(anObj.Position)3 O8 d; q* P& h( P
        Next
" _! g6 L5 H3 {& F
9 D0 V/ G; Z3 d5 f7 m    End Sub: d- f' B& V& J" s& Q! [

; |2 ]) v2 X' J    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)2 v' ~! F" Y" R4 g% U! r7 k2 q
& P6 S% k; b$ y1 w* E' u
        ' This is going to be annoying so don't really do it!4 K# M, H5 G7 Y3 I# @+ o( z7 n5 O
        If changedBlock = ptsBlock Then
/ B- l# M9 U7 s, h2 O# Q            If ptsBlock.SelectedObjects.Length = 1 Then( ~- D, ]) B2 P2 n" y% s/ g2 Z$ O
                InfoWindow.WriteLine("You picked a Location")! J" t4 q# x) B0 T% `
            Else
# U* q* w, ~- E; x* ?                InfoWindow.WriteLine("You picked another Location")9 U3 X; T: B: _+ v6 r2 T
            End If- v  f3 U1 f% x
        End If
) x% `( J, N6 [( D0 W5 n  ]" a' P/ C3 W$ g7 I; Z9 e" e. |
    End Sub3 \6 A& p+ f3 M( C- {; s1 `
+ W( T9 x$ D( W
    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer/ R5 ~% v6 W9 y; o( ?
        Return Snap.UnloadOption.Immediately5 X& ?& q* {) n9 o
    End Function" j$ a# ~) o- `+ w2 C& n8 G
, [8 c$ C7 h1 _8 _& O1 I
End Class' l2 M0 _! o9 J0 E. P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了