+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Starting Lisp

  1. #1
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default Starting Lisp

    Registered forum members do not see this ad.

    I try to write a program in VBA, but I see now that I could use some routines I wrote previously in AutoLisp.
    First question: Is there a way to start a Lisp routine from VBA?
    Second: Is there a way to start a Lisp from VBA and after the Lisp finishes, to return to VBA?
    Third: How to start a Lisp from VBA and the lisp returns a real number in VBA that is used in calculations.

    Or maybe I should rewrite all the Lisp code to have everything in VBA?
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  2. #2
    Senior Member Kerry Brown's Avatar
    Using
    not applicable
    Join Date
    Jan 2006
    Location
    Brisbane, Australia UTC+10
    Posts
    195

    Default

    Did you know that VBA is being removed from AutoCAD ?
    Perfection is not optional.
    another Swamper

  3. #3
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    That is not a problem for me! I still use AutoCAD 2006 and from what I can see, "they" will not upgrade us during this life time. We use Catia now and AutoCAD is kept just for maintaining the old projects. I write programs just for my own pleasure -and to help myself and my colleagues in the daily routines.
    Thank you for answering me!
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  4. #4
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    Can anybody help me with this?
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  5. #5
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    To call an AutoLISP routine in VBA will have to use the SendCommand statement (don’t forget to add a final space = <ENTER>):

    Code:
    ThisDrawing.SendCommand "(load " & chr(34) & "MyLispFile" & chr(34) & ")(MyRoutine) "

    Unfortunately there is no way (or at least I wasn’t able to find one) to see from VBA when the AutoLISP interpreter is done, so the VBA code is not waiting for that processing to get done.
    I was tempted in the past to use your proposed approach but finally got to translate my AutoLISP to VBA.

    Regards,

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Quote Originally Posted by fuccaro View Post
    How to start a Lisp from VBA and the lisp returns a real number in VBA that is used in calculations.
    The first solution to communicate between AutoLISP and VBA is to use the USER*1-5 system variables:

    Code:
    (setvar "USERS1" "Hello World!")
    thisDrawing.GetVariable "USERS1"

    Second, may use a temporarily file to communicate between languages.

    Third, may check the solution proposed here.

    Regards,

  7. #7
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

    Many thanks msasu!
    I will try it these days. The Userr1 sounds good to me. Also I think to clear the Users1, start the lisp routine and wait in a loop until Users1 changes. After that the vba code may continue to run.
    Thanks again!
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

  8. #8
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    You’re welcome!

    Quote Originally Posted by fuccaro View Post
    Also I think to clear the Users1, start the lisp routine and wait in a loop until Users1 changes. After that the vba code may continue to run.
    This sound very promising! I have to make some tests, also. Thank you!

    Regards,

  9. #9
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,004

    Default

    Since just found that this may be interesting for other too, I want to confirm that the above proposed validation solution works.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  10. #10
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2013
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    870

    Default

    Registered forum members do not see this ad.

    A project I'm working on starts out with VBA and then launches AutoCAD and runs a LISP program. The easiest way I have found to get data between the two languages is to use temporary text files. I use them profusely and the process works well.
    It's deja vu, all over again.

Similar Threads

  1. just starting to look at lisp and just wondering why...
    By hazardman in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 3rd Aug 2007, 04:47 am
  2. Just Starting Out...Again
    By Charlie_Porter in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 8th May 2007, 04:27 pm
  3. Starting CAD
    By Duncan in forum AutoCAD Beginners' Area
    Replies: 0
    Last Post: 2nd Apr 2007, 10:33 pm
  4. just starting
    By jon in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 24th Nov 2006, 08:15 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts