defun c: ... in VBA

Discussion in 'AutoCAD' started by Emmanuel A. Garcia, Nov 10, 2004.

  1. The help file shows the following analogy:

    defun
    The Visual Basic keywords Function and End Function



    between LISP and VBA. But how are defun c: ... functions defined in VBA,
    that is functions that can be accessed by simply typing their name at the
    command prompt.

    Thanks in advance. Regards from Los Angeles,

    Emmanuel Garcia
     
    Emmanuel A. Garcia, Nov 10, 2004
    #1
  2. Laurie,

    You've confirmed my fears. ;-) Thank you for your quick response. I hope
    somebody else chimes in to prove us wrong. <G>
    Regards,

    Emmanuel
     
    Emmanuel A. Garcia, Nov 10, 2004
    #2
  3. Emmanuel A. Garcia

    mccad Guest

    ;;Write by mccad (http://www.mjtd.com)
    (defun AutoVBALoad (app cmdliste / qapp)
    (vl-load-com)
    (setq qapp (strcat "\"" app "\""))
    (mapcar
    '(lambda (cmd / nom_cmd dot nodotcmd)
    (progn
    (setq dot (vl-string-search "." cmd))
    (if dot
    (setq nodotcmd (substr cmd (+ dot 2)))
    (setq nodotcmd cmd)
    )
    (setq nom_cmd (strcat "C:" nodotcmd))
    (eval
    (read (strcat
    "(defun " nom_cmd "(/ app)"
    "(if (setq app(fdvbfile " qapp "))"
    "(vla-runmacro (vlax-get-acad-object) (strcat app
    \"!" cmd "\"))"
    "(nodvbfile " qapp "))"
    "(princ ))"
    )))))
    cmdliste
    )
    (princ)
    )


    (defun fdvbfile (app)
    (if (not (findfile app))
    (if (not (findfile (strcat app ".dvb"))) nil (strcat app ".dvb")) app)
    )

    (defun nodvbfile (filename)
    (princ (strcat "\nFile " filename "(.dvb) not found¡£" ))
    (princ)
    )

    And use like :
    (AutoVBALoad "DrawLine" '("Draw2Line" "Draw.Draw3Line"))

    to add command to autocad.

    then you can type "draw2line" or "draw3line" to run vba program.

    ==========

    http://www.mjtd.com

    http://www.mjtd.com/bbs/dispbbs.asp?boardID=4&ID=28516&page=1
     
    mccad, Nov 10, 2004
    #3
  4. Thank you. I still would like to submit a wish for the inclusion of
    c:YourCommand type of VBA functions, to make them more easily portable.
     
    Emmanuel A. Garcia, Nov 10, 2004
    #4
  5. Emmanuel A. Garcia

    Ed Jobe Guest

    We've been asking for years. Not gonna happen in vba. But it is available in
    ..Net now.
     
    Ed Jobe, Nov 10, 2004
    #5
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.