【问题标题】:Programmatically running Autocad script file using vb6使用 vb6 以编程方式运行 Autocad 脚本文件
【发布时间】:2013-08-14 13:52:22
【问题描述】:

我正在使用以下代码打开 autocad 文件:

Dim DwgName As String
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
    Set acadApp = CreateObject("AutoCAD .Application")
    Err.Clear
End If

Set acadDoc = acadApp.ActiveDocument
If acadDoc.FullName <> DwgName Then
    acadDoc.Open DwgName
End If

Dim str As String, str1 As String
str1 = "_-insert" & vbLf & """" & "C:\AZ665.dwg" & """" & vbLf & "0,0,0" & vbLf & vbLf & vbLf & vbLf & "z" & vbLf & "a" & vbLf
acadDoc.SendCommand str1
acadApp.Visible = True

以上代码工作正常。但每次我必须创建“str1”字符串才能进行任何更改。因此我在“.scr”文件中写scipt。但无法调用这个文件。 请帮忙。

【问题讨论】:

  • 你能发布你的 .scr 文件吗?
  • 什么版本的autocad?

标签: vb6 autocad


【解决方案1】:

以下代码将读取 .scr 文件并为您的 SendCommand 创建所需的字符串

Dim strData as string
x = FreeFile
Open "myscript.scr" For Input As #x

Do
    Line Input #x, strData
    str1 = str1 & strData & vbNewLine
    If EOF(x) Then Exit Do
Loop

Close #x

【讨论】:

    【解决方案2】:

    我找到了以下解决方案:

    acadDoc.SendCommand "_script" & vbCr & ScriptFilePath & vbCr
    

    【讨论】:

      猜你喜欢
      • 2011-08-04
      • 2013-02-28
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多