Author Topic: Loading LISP from Excel  (Read 5533 times)

0 Members and 1 Guest are viewing this topic.

debgun

  • Guest
Loading LISP from Excel
« on: March 16, 2010, 11:45:11 AM »
I'm trying to get Excel VBA to load a lisp routine and then run the routine.  Currently, I'm able to load AutoCAD.  Any suggestions?

Here is the code to load AutoCAD.
Code: [Select]
Sub GetAutoCAD()

    On Error Resume Next
    Set AcadApp = GetObject(, "AutoCAD.Application")
    If Err Then
        Err.Clear
        Set AcadApp = CreateObject("AutoCAD.Application")
    End If
   
    AppActivate AcadApp.Caption
    AcadApp.Visible = True
    AcadApp.Application.WindowState = acNorm
    AcadDoc.ActiveSpace = acModelSpace
   
   
    If AcadApp.Documents.Count = 0 Then
        AcadApp.Documents.Add
    End If
 
End Sub
Thanks!

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Loading LISP from Excel
« Reply #1 on: March 16, 2010, 02:44:24 PM »
Better to use AutoCAD as the application and the Excel workbook as the data file.  You might get away with a call to the SendCommand method, but its asynchronous which causes timing issues.  Perhaps you should have the LISP load through the acaddoc.lsp file?  Unless you were asking how to load LISP in Excel (which it can't).
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

debgun

  • Guest
Re: Loading LISP from Excel
« Reply #2 on: March 16, 2010, 03:30:35 PM »
Yes! I figured out how to load and call a lisp routine from Excel VBA.  Thanks for the response dgorsman.

Code: [Select]
AcadApp.ActiveDocument.SendCommand "(load ""C:/Documents and Settings/dguenthner/My Documents/Vlisp/Happyboy.lsp"") "
AcadApp.ActiveDocument.SendCommand "(c:HAPPYBOY) "