NX二次开发之VB.NET带参改颜色



Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
 
Module Module1
    Sub Main(params() As String)
        Dim theSession As Session = Session.GetSession()
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()
        Dim myBody As Body


        Do Until SelectBody("选择一个体", myBody) = Selection.Response.Cancel
           Dim displayModification1 As DisplayModification
           displayModification1 = theSession.DisplayManager.NewDisplayModification()
           displayModification1.ApplyToAllFaces = True
           displayModification1.ApplyToOwningParts = False
           displayModification1.NewColor = params(0)
           Dim objects1(0) As DisplayableObject
           objects1(0) = myBody
           displayModification1.Apply(objects1)
           displayModification1.Dispose()  
         Loop
        lw.Close()
    End Sub
 
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination
    End Function
 
    Function SelectBody(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
        Dim theUI As UI = UI.GetUI
        Dim title As String = "选择一个体"
        Dim includeFeatures As Boolean = False
        Dim keepHighlighted As Boolean = False
        Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
        Dim cursor As Point3d
        Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
        Dim selectionMask_array(0) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
        End With
        Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
         title, scope, selAction, _
         includeFeatures, keepHighlighted, selectionMask_array, _
         selobj, cursor)
        If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
            Return Selection.Response.Ok
        Else
            Return Selection.Response.Cancel
        End If
    End Function  
End Module

BEGIN_DROPDOWN Colors 
  BUTTON FlameColor
  LABEL FlameColor
  BITMAP D:\UG_Journal\Toolbar\11.bmp
  ACTION D:\UG_Journal\Toolbar\Color.vb("11")
 
  BUTTON BlankColor
  LABEL BlankColor
  BITMAP D:\UG_Journal\Toolbar\15.bmp
  ACTION D:\UG_Journal\Toolbar\Color.vb("15")
 
  BUTTON NCColor
  LABEL NCColor
  BITMAP D:\UG_Journal\Toolbar\50.bmp
  ACTION D:\UG_Journal\Toolbar\Color.vb("50")
 
  BUTTON WeldColor
  LABEL WeldColor
  BITMAP D:\UG_Journal\Toolbar\91.bmp
  ACTION D:\UG_Journal\Toolbar\Color.vb("91")
 
  BUTTON AluColor
  LABEL AluColor
  BITMAP D:\UG_Journal\Toolbar\3.bmp
  ACTION D:\UG_Journal\Toolbar\Color.vb("3")
 
END_DROPDOWN

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值