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

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

[复制链接]

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

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

admin 楼主

2017-1-16 15:27:51

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

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

x
通过对话框选择多个点实例
8 I/ O) h/ x) @6 D  N! g, b2 w. W& K
5 S2 Z. W7 U. O4 O2 M
Option Infer On
3 ~- U+ B" m7 r7 U3 LImports Snap, Snap.Create
- W7 j) ~! K7 t+ w: g- Q4 P$ A
+ o8 ^: D' w  Q: {* A) e0 n' This is a very simple example showing you how to use a Snap.UI.BlockForm
6 R: z- T& r& T) O/ Y' to create a dialog that enables the user to select multiple point locations at once.
  h- a# m: a8 n" Z* e6 S7 ^7 r: m- l# a
$ t- {& h# D; V# fPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm1 J  P  C9 b; f) ^6 `! v
7 k5 u. y9 ?1 H8 p# W  B
    ' Declarations of the blocks on the dialog' X; y- {# ^( q3 K0 t8 O

, C( o  G0 A' s, {# p    Dim ptsBlock As UI.Block.SelectObject
: {  S4 x2 h, t: h& F4 N$ S: ~9 N8 @
    ' Constructor for a dialog object
$ r, g# @# T! ~" |, _' u    Public Sub New()
- Y) E* H* M" h/ {% n+ Q2 p) c) J3 _3 ~: b) K
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog+ k' a1 b) j" b0 a& ?
        Me.Cue = "Please select some locations"   ' Text to be shown in cue line6 z- [) f" y# _, ]; m! H$ G
" N) K" F4 K& R
        ptsBlock = New UI.Block.SelectObject" p  w9 W5 L# Q/ b& {3 s
        ptsBlock.AllowMultiple = True" v: L* E4 k: d2 ^
        ptsBlock.MaskTriples =( ]5 Q# b! O: K4 ~; [+ G
            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}' @2 @( I2 V9 g6 m5 ~; D
        ptsBlock.LabelString = "Select locations". {8 q0 z+ e. w# }# y, {& i
        ptsBlock.PointOverlay = True' r" ~; R$ c2 x  u+ u
        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
+ l, E2 _  M) B! Z; U6 J# B        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly( M9 c+ j1 D  Z

, z  L7 p7 n% w, G* [0 @2 j0 H        ' Add the block to the BlockForm9 V4 N- N, j. b- w! ]
        Me.AddBlocks(ptsBlock)
: _1 \% `5 c9 y# @8 O5 I8 w/ z+ x$ `. Z/ j5 t, p  V1 j
    End Sub
5 W/ p' J0 d  }3 [  h, {
& s' v# v/ ?( f! m0 d: ^$ s5 }    Public Shared Sub Main()
" R8 a$ E1 f& Z) i
: J$ K3 f, G7 K& q: J+ i% g) E* {6 q- ?        ' Create and display a dialog7 a9 \# B1 M- H4 s( }
        Dim myForm = New SnapBlockFormApplication2()
2 F/ a( L( }6 |3 R* A) M7 B        myForm.Show(). s: [& K: G7 l1 _4 b, v  Q
8 u- `1 y) v' h3 Z
    End Sub: k5 F" W2 x( k; a/ j

* Z! x3 T% X! P1 f5 J    Public Overrides Sub OnApply()
' ~2 j  h* W2 S$ Y, i! \8 X
0 Z& s( L* N: g7 a1 i        InfoWindow.WriteLine("You selected these locations:")+ m2 `: [( D. R% R) Y7 U0 J

; I' v* D3 z  r  d( ~: R% U        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects3 c  D. p8 s: @0 y& l
            InfoWindow.WriteLine(anObj.Position)- V8 v0 Q! I5 R9 \/ [! Q0 _
        Next
8 M9 ]$ p4 K$ H  L" J) Y
3 f1 P2 }" z/ b    End Sub
. Y" B* t; }# d* d% o7 B9 y) `5 J3 F( k4 x
    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)$ T/ B* f: }9 U9 g! i
% L! N) j( G- ?) p9 i
        ' This is going to be annoying so don't really do it!! H$ E1 K6 u' q
        If changedBlock = ptsBlock Then
3 X$ D( P/ X7 L( F% o: u2 S            If ptsBlock.SelectedObjects.Length = 1 Then4 c: C) `4 ^; h" W& D
                InfoWindow.WriteLine("You picked a Location")! P/ K4 e* Z' Q: W; h2 ?
            Else* ^' X4 `: P( z, x# G6 A* s6 q
                InfoWindow.WriteLine("You picked another Location")
; f1 _% d( A0 T. ~: I$ _            End If
3 S4 H2 U, o2 M8 @        End If
! T" j$ T# p6 u% X; K* w5 J# W7 Y; }* E( r7 W& A4 b1 O/ H
    End Sub
- W# o$ B) y0 \; q4 T
6 |" p' v6 z' ^' d6 G% c8 U0 H    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
; E! t- a# p+ j8 l, ]$ Z        Return Snap.UnloadOption.Immediately
) A0 n. t. g" z+ @& k    End Function. G% s: M; R/ A, f2 h: Z
4 m8 b9 ~1 x9 H: J# o; @
End Class
4 O. U/ g7 t. ^
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了