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

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

[复制链接]

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

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

admin 楼主

2017-1-16 15:27:51

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

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

x
通过对话框选择多个点实例/ E' i7 j1 V2 k& X- l; Z
5 X6 O  z- ~: X) Z; {
# d% E# ~* o- l: ^8 w2 U: L8 C* a
Option Infer On1 s2 l) J, p( x" @1 i4 p7 [
Imports Snap, Snap.Create+ X! w+ M+ f+ s: O7 N
3 z. \! x& z* J9 ?
' This is a very simple example showing you how to use a Snap.UI.BlockForm
: d+ \* r1 P. u! k* t6 }' to create a dialog that enables the user to select multiple point locations at once.! L9 E) r% ]8 g( P$ N! `2 U
7 y* U% i4 K5 {6 p* Y; h
Public Class SnapBlockFormApplication2 : Inherits UI.BlockForm
; O- w8 f5 q! ~2 `* M
+ s- U8 H* p& `0 K7 P    ' Declarations of the blocks on the dialog4 O5 g$ x  S/ W6 I& p( g  X0 B9 ~
+ ^/ h: p7 B4 ~0 D) d, n
    Dim ptsBlock As UI.Block.SelectObject
# B' v& l/ F4 w2 [3 g1 N2 [
- F% w8 l- L( J( @7 y7 v2 [9 M    ' Constructor for a dialog object1 e: v( T+ B8 D$ b2 F, x
    Public Sub New(); I7 n! C% Y5 f. T
! M- [( A) Q, F: n+ [- c  |  m& }
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog% M& z' A. F% R3 h. q, U
        Me.Cue = "Please select some locations"   ' Text to be shown in cue line8 v) C3 J) |. P, t$ N- M. \
( r: P1 n, @1 X
        ptsBlock = New UI.Block.SelectObject
* ~6 M3 U$ x8 d        ptsBlock.AllowMultiple = True
, m  I- V, P( s        ptsBlock.MaskTriples =
% e5 n: R) v, R4 s- K7 T6 {2 w            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}! t0 f( k: r$ }0 q/ `: H! [  }
        ptsBlock.LabelString = "Select locations"
: f4 Y" m8 s6 p- g; s4 f( V        ptsBlock.PointOverlay = True
* M/ q5 O8 l2 A) F        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)
$ ~# z+ J/ j. n  i% g        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly
* c$ y$ q& L- `6 ?  G& Z3 u6 k. S! @
! k8 k: L/ u- ]8 J6 |6 b9 I        ' Add the block to the BlockForm5 B  g/ G( @5 j; U+ O& u" l9 [
        Me.AddBlocks(ptsBlock)( U9 s! P8 w! U+ L! c" F- W

* d0 l5 [0 `: D# Y$ h    End Sub
6 o" ~2 X( O2 J. j0 S( J
0 M4 S$ v  v) Q% O    Public Shared Sub Main()
1 c4 O3 p; X, X+ v( Q: ?* E8 ^
& x' u# D7 l9 F. k0 V        ' Create and display a dialog
' @5 O" M# P: q# ~$ l        Dim myForm = New SnapBlockFormApplication2()9 w6 r6 h; e$ k% I6 r( ]
        myForm.Show()! P+ e% ]9 r1 G, X9 l4 ?1 m& _

8 |8 X9 y: [% ~4 ~    End Sub8 f2 j0 |. m# r- V. N# Y
# z+ q5 P5 y! V1 y
    Public Overrides Sub OnApply()
- t( n5 ?% j  n# }! D0 E9 h3 b+ z6 w8 D
        InfoWindow.WriteLine("You selected these locations:")# j% l6 u% A# i; L! i3 m5 F& ?) q
# E& P0 e) R* h$ p' V- B
        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects) ?" `- e5 F" Y9 f! e( S
            InfoWindow.WriteLine(anObj.Position)
8 X  p! K8 u5 ~& k1 e9 _$ h6 g# u' A        Next
' G5 r# S1 j; D0 h3 y1 K* U% \1 ^6 g! l5 L; [
    End Sub* ~" |. {+ N( i; ~( R5 _9 `( n" V

" G7 K8 z( C9 a0 N" R    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General). W5 f# R  n7 d: I

. O4 K5 h4 h9 \9 x        ' This is going to be annoying so don't really do it!
1 V' ^$ |5 ?# D% r        If changedBlock = ptsBlock Then# o! [7 N) x8 d
            If ptsBlock.SelectedObjects.Length = 1 Then* s# ]# x8 e7 M8 p
                InfoWindow.WriteLine("You picked a Location")
/ W+ P- v: Q/ S7 }$ p8 u            Else
1 K4 N/ O0 k4 u( G# g) q0 ~                InfoWindow.WriteLine("You picked another Location")3 Y4 ]0 r+ `8 A; c; g# u: s7 c
            End If5 C) c- ~; Y5 q6 R: _
        End If
4 S/ ^8 l9 y/ k6 P% @  N$ G0 w  M. n# s
    End Sub$ p6 Y3 {/ I. t6 S6 N) e3 [. @

, _) W9 d3 N! w4 V9 {+ _) n) Y5 x* c9 f    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
' p+ L* G; `- A+ x9 A0 f        Return Snap.UnloadOption.Immediately
: d8 L; H" s" Q    End Function
- v, E+ B; @  Y. T# T/ [0 |
* @/ z" R- E6 p4 aEnd Class
5 b( M8 }& S: p+ Q
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了