PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2017-1-16 15:27:51

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

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

x
通过对话框选择多个点实例9 m! R. d, v6 |, Y/ c! h' ^6 E

% R! r3 _& l  O
  M% N6 R% W( F. `$ M: QOption Infer On
0 N* J' x& ^5 u8 ?4 n2 v0 j" dImports Snap, Snap.Create+ L2 d1 s8 O5 B3 X  J. J( |8 z
4 f9 ]5 o7 K8 c) r% y/ l
' This is a very simple example showing you how to use a Snap.UI.BlockForm
/ r0 \8 J( ^2 E2 I  i  o" I' to create a dialog that enables the user to select multiple point locations at once.  i, J0 R* @' |; }7 d

1 m, b( S* c8 {- P. PPublic Class SnapBlockFormApplication2 : Inherits UI.BlockForm
7 J5 s7 P" c( J- M( m7 G& S' o  o) r9 `$ p' B+ P
    ' Declarations of the blocks on the dialog. n( l. z  [( V

1 `. E% G- J# L7 G4 C    Dim ptsBlock As UI.Block.SelectObject+ H( F3 d; w; c* D) h4 K% M9 \

; F) @1 u9 K( ?5 J4 w3 x2 u    ' Constructor for a dialog object
: H5 T+ c- E# g  ~/ X    Public Sub New()
8 T2 [( |- }' D2 j+ x8 Q- m( l" o2 B7 B+ L, z# @
        Me.Title = "Select Multiple Locations"  ' Text to be shown in title bar of dialog- y8 E- J0 Z+ ]& C
        Me.Cue = "Please select some locations"   ' Text to be shown in cue line
+ I8 j, O6 D* A" x3 K7 v
. \# ]9 l) V: k' t0 ~! S        ptsBlock = New UI.Block.SelectObject7 \- ]) n- b5 @2 J; n
        ptsBlock.AllowMultiple = True+ a7 n4 x; P4 n6 h* x9 N3 v5 B
        ptsBlock.MaskTriples =  U# U9 n/ G# G/ N1 R: f
            {New NXOpen.Selection.MaskTriple(NXOpen.UF.UFConstants.UF_point_type, 0, 0)}8 ?* B7 l0 ^1 w5 h
        ptsBlock.LabelString = "Select locations"; Q& i7 F* y, i- k
        ptsBlock.PointOverlay = True
; |$ M) f4 q' |" s) z; e        ptsBlock.SnapPointStates.SetAll(UI.Block.SnapPointState.Selected)0 c8 m2 O( F  k3 _0 B8 t- L
        ptsBlock.MaximumScope = UI.Block.SelectionScope.AnyInAssembly( [9 a- V$ k6 x( i

0 S+ y8 A7 J" E2 _  ~        ' Add the block to the BlockForm
# d, L  q6 p' r) Y: ]; S        Me.AddBlocks(ptsBlock)/ d) `7 A5 [! _4 D; e  h

+ ?5 f4 r7 O0 U% F    End Sub; [; Q' \5 W3 E# c$ Y8 I3 x

  J2 c9 S& ?) I7 g2 b( Z6 `9 `* q' C    Public Shared Sub Main()  K) E& \; W7 N5 F( h  l
3 g0 K1 W& t7 J% d0 x4 `6 G5 S2 a7 X
        ' Create and display a dialog
" k% d3 |5 Q& Y7 r( [) q! W        Dim myForm = New SnapBlockFormApplication2()
! X* A9 h  U. [+ c* F        myForm.Show()
. P" a- T8 v. ~# U7 Y3 T; Z, |6 b  P8 B1 C
    End Sub
3 |2 T8 R- g+ K3 R* a- `+ t
' \  f6 [+ v5 v: W  G* a. c    Public Overrides Sub OnApply()
' ^2 }" X  {; w+ m
9 B4 c, h  ]' Z( q  _3 m        InfoWindow.WriteLine("You selected these locations:")
1 V: W+ x- u6 t- T9 ?: {7 ?% O/ W3 K1 M) t! X# X+ D
        For Each anObj As Snap.NX.Point In ptsBlock.SelectedObjects
) J" B1 K2 `  V# V            InfoWindow.WriteLine(anObj.Position)
- r  |  w( l/ b( g! x- Y8 e        Next
8 d5 E# T; `: _" N5 e& @* p
2 y  ~0 F4 j; W. Z    End Sub
  S0 `1 V% c9 M. m! C4 @; G! p/ o2 j
    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)4 Z: {: ^& u( f' b" L

( L: S+ Q1 q: r2 l9 D; s        ' This is going to be annoying so don't really do it!
5 k' h. N% y- k2 k# o( p. K$ \) o! D        If changedBlock = ptsBlock Then) t; T2 R8 w; ^. k
            If ptsBlock.SelectedObjects.Length = 1 Then* x: h8 ~4 S4 u* n+ N  G' f
                InfoWindow.WriteLine("You picked a Location")
% S  ?& f5 D* h6 T& ~2 N1 B( ?* }            Else
9 E% r7 X4 G/ ^7 s1 L' \) D+ @                InfoWindow.WriteLine("You picked another Location")! p0 O+ a, |( @2 v. k" @8 @8 z- b8 s
            End If
- K8 N& F3 G/ J/ A- m8 Z        End If8 A+ N' u' h; _4 [. C
! x0 y) `9 b9 ^
    End Sub
) f/ A  R. h5 i: p3 c3 y! j8 w
' Q5 w! b* a0 }$ J    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
. o( ]- o$ G. \# T: U4 k        Return Snap.UnloadOption.Immediately6 p4 S% S% I! \, X
    End Function. R$ f3 X  e+ ~# {! J1 \# W9 }/ H8 i5 a
/ m' `8 M: K& k* M& X9 I1 f9 P+ d8 a
End Class# d* H, }7 Y& a
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了