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

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

[复制链接]

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

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

admin 楼主

2017-1-16 15:27:51

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

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

x
通过对话框选择多个点实例7 O/ u7 Z7 ?: U# y) ?' H

$ W7 `, f3 `; g: i! @- D% K# S1 x9 R8 Z8 a. \" E
Option Infer On
( b% c: ?7 m8 u3 _( G* BImports Snap, Snap.Create" }2 r; A# D3 D4 E" E
2 Y0 w5 o$ |0 e$ m& K
' This is a very simple example showing you how to use a Snap.UI.BlockForm4 w% ]/ o+ I( Y' k$ ]( N6 Z3 J
' to create a dialog that enables the user to select multiple point locations at once.& @/ f7 Q0 a' j. U3 y* K4 ~
: p% ~  X+ r$ F  p6 K) s
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
$ R* B* m9 _8 z+ t7 {3 x
  W6 m8 D8 ^% P4 {2 ~5 Z5 r% X( I# `, v    ' Declarations of the blocks on the dialog
2 [6 A- o# w" S/ M) M
! k8 c$ k* b8 g    Dim ptsBlock As UI.Block.SelectObject
! e" s' {- a/ K( t- J" J7 T7 `2 }; @4 L3 p9 \8 y0 z; T5 h; b* M' x
    ' Constructor for a dialog object
" e; N0 a( A, ]+ ^    Public Sub New()- V0 z, |" N- [) M
8 k* h8 b0 u' M1 x: K* a! r
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog
3 r7 k: z* Q" Y6 r* Y' v        Me.Cue = "Please select some locations"   ' Text to be shown in cue line+ L$ A. y# d$ n

! x3 ~# {: y3 W) @- L9 d$ {        ptsBlock = New UI.Block.SelectObject
1 m7 c! B. L! W) y1 E- M: R        ptsBlock.AllowMultiple = True) a0 c0 h2 p9 u( G% L
        ptsBlock.MaskTriples =: X# d' r) h) r& ?
            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}) B1 X4 `' d- k8 M* F6 M
        ptsBlock.LabelString = "Select locations"1 Y0 R" g6 @2 Y5 V- F  }( l
        ptsBlock.PointOverlay = True. b9 D: c; V4 H1 [* h9 j6 v3 P+ e% @! l
        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
3 l6 G! O3 Q% B8 u5 \/ a  I2 F% L5 p        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
3 `8 W, p; [) c, ?8 J  `6 @0 @* Y1 S3 J: T! e9 ]( {
        ' Add the block to the BlockForm/ B8 w3 Z1 v. @. M8 D" l
        Me.AddBlocks(ptsBlock)$ Y$ t( ]; j& _+ Y3 T' @
7 h) k$ k; F  p' z2 D
    End Sub2 H: p% |" Y  T1 q3 [
+ {6 o/ `  I& F+ Q! n8 m3 t! J
    Public Shared Sub Main()
5 `: h+ x. B/ V& _5 s( s5 h/ `  `; p# s1 u' ^& c8 v9 B3 Y$ T* t
        ' Create and display a dialog
! L  j7 C$ f5 m# F# q$ r        Dim myForm = New SnapBlockFormApplication2()
1 X8 C! C) L  G( X7 q& g9 l0 d        myForm.Show()9 Y$ h; r& s0 z5 X( j6 q

  J) l* L$ c4 p    End Sub6 O- d+ H; g0 ^0 o
8 E/ p/ \/ |/ g; L
    Public Overrides Sub OnApply()7 S$ w# i2 {/ t/ g( ^2 G. E

- m* u0 E& x& U6 Q        InfoWindow.WriteLine("You selected these locations:"): a% R2 I/ y1 I: Y
8 p# j, N8 a/ T' }
        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
& U5 ?- N' R. B( e            InfoWindow.WriteLine(anObj.Position)( Q$ W# a, x+ t- X$ Q
        Next
0 S3 W; r7 V: B$ f
$ Z4 ?4 J- C" o# }( k3 w    End Sub( R/ R+ v9 |+ C" n3 e! w

% e7 Q7 ?# u) X7 q* B$ E    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
2 z; v$ D9 R  Z7 Q8 ]$ B& l* G- e! N' a2 o6 r$ i* x
        ' This is going to be annoying so don't really do it!
! R7 \# ]$ v1 X8 L% T        If changedBlock = ptsBlock Then
3 r1 V0 o4 }6 f8 Q            If ptsBlock.SelectedObjects.Length = 1 Then
+ P/ z6 X6 h0 `7 i2 r; ^6 `                InfoWindow.WriteLine("You picked a Location"). i- |, v( U. \; a' q
            Else2 F+ u1 T( Z9 r0 B& l7 v
                InfoWindow.WriteLine("You picked another Location")
4 q. [! j+ Z5 t9 Q: S            End If$ O5 q* Q+ n2 L& l. z
        End If
8 X2 {: V& ?( c! h# f4 w
1 M3 M: P+ C' [    End Sub
, m1 B9 H1 v1 T8 ?2 K4 T+ w! x* T) ^) ~0 W
    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer& k) G9 P* V1 x# |% l# I8 T
        Return Snap.UnloadOption.Immediately
6 D- ^; L  j8 Q3 q5 p- p    End Function' J8 ]" F( L: m( f: U

' B# [6 h& B$ q( r( VEnd Class
3 O1 t8 ]3 F; X, o% Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了