我使用下面的代码打开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上面的代码工作的fine.But,每次我必须创建"str1“字符串,以作出任何更改。因此,我在".scr“file.But中写入文件,无法调用该文件。请帮帮忙。
发布于 2013-08-14 05:52:22
我发现了以下解决方案:
acadDoc.SendCommand "_script" & vbCr & ScriptFilePath & vbCr发布于 2013-08-12 10:44:41
下面的代码将读取一个.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 #xhttps://stackoverflow.com/questions/18182265
复制相似问题