iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 24544|回复: 1
打印 上一主题 下一主题

VB.NET与UG 二次开发问题4

[复制链接]
跳转到指定楼层
楼主
发表于 2006-9-27 18:43:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

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

x
请问一下下面的.VB文件怎么样才能在VS中运行,应该在哪个模板下(windows应用程序..等)
我知道问题很傻瓜,请好心人指点了。



' ===================================================================
'
'             Copyright (c) 2004  UGS PLM Solutions
'               Unpublished - All rights reserved
'
' ===================================================================
' *******************************************************************
'
'  Description
'    Handles access to NX and delegates spell checking to the
'    WordSpellChecker class.  This class also defines the main
'    routine for the application and defines a routine that
'    NX looks for on how to handle the application after
'    execution.  In this example the application is setup to
'    unload immediately after execution within NX.
'
'  
' *******************************************************************
Imports System
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF


Public Class NXSpellChecker

    ' Description: Allows the selection of notes and labels
    '              and outputs them in an array of NXObjects.
    '              Objects are scoped to the work part.
    Private Sub SelectNotesAndLabels(ByRef selectedObjects As NXObject())

        'Gateway to the NX User Interface
        Dim ui As UI = ui.GetUI

        Dim message As String = "Select notes and labels to spell check"
        Dim title As String = "Select notes and labels"

        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim keepHighlighted As Boolean = True
        Dim includeFeatures As Boolean = True
        Dim response As Selection.Response

        'Set selection filter to pick only notes and labels.
        Dim selectionAction As Selection.SelectionAction = _
            Selection.SelectionAction.ClearAndEnableSpecific
        Dim selectionMask_array(2) As Selection.MaskTriple
        With selectionMask_array(0)
            .type = UFConstants.UF_drafting_entity_type
            .subtype = UFConstants.UF_draft_note_subtype
            .SolidBodySubtype = 0
        End With
        With selectionMask_array(1)
            .type = UFConstants.UF_drafting_entity_type
            .subtype = UFConstants.UF_draft_label_subtype
            .SolidBodySubtype = 0
        End With

        Try

            response = ui.SelectionManager.SelectObjects(message, title, scope, _
                                                            selectionAction, includeFeatures, _
                                                            keepHighlighted, selectionMask_array, _
                                                            selectedObjects)
            If response = Selection.Response.Cancel Or response = Selection.Response.Back Then
                Return
            End If

            Dim info As String = "Number of selected objects = "
            info = String.Concat(info, selectedObjects.Length)
            System.Diagnostics.Trace.WriteLine(info)

        Catch e As Exception

            System.Diagnostics.Trace.WriteLine("Problems selecting objects.")
            System.Diagnostics.Trace.WriteLine(e.ToString)

        End Try

    End Sub

    ' Description: Select notes and labels
    '              and perform the spelling check.
    Public Sub SpellCheck()

        'Gateway to the NX applications
        Dim session As Session = session.GetSession

        'Select notes and labels in NX
        Dim selectedObjects() As NXObject
        Me.SelectNotesAndLabels(selectedObjects)

        Try

            Dim sda As Annotations.SimpleDraftingAid
            For Each sda In selectedObjects

                Dim wd As WordSpellChecker = New WordSpellChecker
                Dim nxText() As String
                Dim line As String
                Dim undoText As String = "Update Note"
                Dim undoMark As Session.UndoMarkId
                Dim i As Integer = 0

                'Get the text from the note or label in NX
                nxText = sda.GetText

                For Each line In nxText

                    line = wd.CheckString(line)
                    nxText(i) = line
                    i += 1

                Next

                'Set the text for the note or label in NX
                sda.SetText(nxText)

                'Update so the text changes are applied to the system
                undoMark = session.SetUndoMark(session.MarkVisibility.Visible, undoText)
                session.UpdateManager.DoUpdate(undoMark)

            Next

        Catch e As Exception

            System.Diagnostics.Trace.WriteLine("Problem with traversing selected objects array")
            System.Diagnostics.Trace.WriteLine(e.ToString)

        Finally

            'Unhighlight the object in NX
            Dim dispObj As DisplayableObject
            For Each dispObj In selectedObjects

                dispObj.Unhighlight()

            Next

        End Try

    End Sub

    Public Shared Sub Main()

        Dim sp As NXSpellChecker
        sp = New NXSpellChecker
        sp.SpellCheck()

    End Sub

    'Unloads the image immediately after execution within NX
    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Class
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2006-9-30 22:06:55 | 只看该作者

马上注册登录,享用更多网站功能!

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

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-11-24 17:01 , Processed in 0.009964 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表