Question

I am Using below code to open autocad file :

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

Above code working fine.But everytime I have to create "str1" string in order to make any changes. Hence I am writting scipt in ".scr" file.But unable to call this file. Please help.

Was it helpful?

Solution 2

I found below solution :

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

OTHER TIPS

The following code will read a .scr file and create the string you need for your 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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top