zlg258369 发表于 2011-3-31 10:19:42

能让AUTOCAD 听话的程序

本帖最后由 zlg258369 于 2011-4-1 22:09 编辑

别人发了个说话的,我发个听话的。Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices


Public Class wenzibiaozhu

    Dim WithEvents RC As SpeechLib.SpSharedRecoContext
    Dim myGrammar As SpeechLib.ISpeechRecoGrammar
    Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

    <CommandMethod("TH")> _
      Public Sub Ting()

      On Error Resume Next
      RC = New SpeechLib.SpSharedRecoContextClass
      myGrammar = RC.CreateGrammar
      Dim hostName As String = System.Reflection.Assembly.GetExecutingAssembly().Location
      Dim str As String = hostName.Substring(0, hostName.LastIndexOf(‘\’))

      myGrammar.CmdLoadFromFile(str & "\command.xml", SpeechLib.SpeechLoadOption.SLODynamic)
      myGrammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSActive)

    End Sub

    Private Sub RC_Recognition1(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult) Handles RC.Recognition

      Select Case Result.PhraseInfo.GetText
            Case "镜像"
                acDoc.SendStringToExecute("_mirror ", True, False, False)

            Case Else

                MsgBox("你说的是" & Result.PhraseInfo.GetText & ",再说一遍!")

      End Select
    End Sub

End Class

只包含一个命令


http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 zlg258369的微博

nxy_918 发表于 2011-3-31 10:25:17

晕!!!!

kwok 发表于 2011-3-31 20:41:05

牛..............

no13bus 发表于 2011-4-5 11:37:10

利用spi类库

aziz 发表于 2011-10-25 10:19:36

一楼代码有错误

zlg258369 发表于 2011-10-26 11:47:00

aziz 发表于 2011-10-25 10:19 static/image/common/back.gif
一楼代码有错误

在我这是没问题滴

cabinsummer 发表于 2011-10-26 20:37:18

aziz 发表于 2011-10-25 10:19 static/image/common/back.gif
一楼代码有错误

有错误就指出在哪里,怎么改。

aziz 发表于 2011-10-31 11:56:34

不好意思,我看错了的。没装.NET
页: [1]
查看完整版本: 能让AUTOCAD 听话的程序