Opening Autocad with visual basic

Discussion in 'AutoCAD' started by czugelder, Sep 15, 2004.

  1. czugelder

    czugelder Guest

    Is there a way to open up autocad from visual basic and then run a lisp routine. I want my lisp routine to create a drawing and then save it out.
     
    czugelder, Sep 15, 2004
    #1
  2. czugelder,

    In addition to any replies you might receive or already
    received, you may find more information or responses
    by posting future VBA related questions in the following
    discussion group:

    By NNTP discussion group reader at
    news://discussion.autodesk.com/autodesk.autocad.customization.vba

    By HTTP (web-based) interface at
    http://discussion.autodesk.com/forum.jspa?forumID=33

    --
    Autodesk Discussion Group Facilitator



    routine. I want my lisp routine to create a drawing and then save it out.
     
    Jason Piercey, Sep 15, 2004
    #2
  3. czugelder

    ECCAD Guest

    Czugelder,
    Basic Sub to call ACAD, run a script.
    In your script do:
    (load "mylispprogram.lsp")
    or such.

    Private Sub Call_AutoCAD()
    ' Notes: Variable ACADPath is Global
    ' Place 'script' name into Variable Script

    ' Call up AutoCAD and run the Script ecbatch

    Dim CkFile As String
    Dim MyAppID, ReturnValue
    Dim AcadExe As String
    Dim Script As String

    AcadExe = ACADPath & "\acad.exe"
    Script = "my_script_name" ' No .scr needed

    On Error Resume Next
    CkFile = ""
    CkFile = UCase$(Dir(AcadExe))

    If CkFile <> "ACAD.EXE" Then
    MsgBox "Could not locate ACAD.EXE,....Run my_script_name.scr in AutoCAD..", vbExclamation, "."
    GoTo NotFound
    End If

    If Dir(AcadExe, "") Then
    Me.WindowState = vbMinimized
    MyAppID = Shell(AcadExe & " /b " & Script & "", 1) ' Run Acad, and script
    AppActivate MyAppID ' Run ACAD and Script...
    End If

    NotFound:

    ' And Exit program
    Close

    End Sub

    Bob Shaw
    www.bobscadshop.com
     
    ECCAD, Sep 15, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.