See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: why doesn't this lisp work in a macro?

  1. #1
    Member
    Join Date
    2006-02
    Posts
    17
    Login to Give a bone
    0

    Default why doesn't this lisp work in a macro?

    Why doesn't this work in a macro?

    Using AutoCAD 2014

    Code:
    ^C^C(setq CE (getvar "CMDECHO"))(setvar "CMDECHO" 0)(setq DIST (getdist "Enter distance or <first point>:"))(setq DISTT (/ DIST 2))(command "offset" DISTT)(setvar "CMDECHO" CE)
    Last edited by BlackBox; 2014-09-08 at 10:45 PM. Reason: Please use [CODE] Tags

  2. #2
    I could stop if I wanted to
    Join Date
    2015-10
    Location
    Colorado Springs, CO
    Posts
    369
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Because it is a lisp routine... not a macro.

    Set your routine to a command. For example:

    Code:
    (DEFUN C:o2 ()
    (setq CE (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq DIST (getdist "Enter distance or <first point>:"))
    (setq DISTT (/ DIST 2))
    (command "offset" DISTT)
    (setvar "CMDECHO" CE)
    )
    Save the lisp file in your support file search path.

    Make sure the lisp routine is loaded.

    Then your macro can be:

    Code:
    ^C^Co2;

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    1

    Default Re: why doesn't this lisp work in a macro?

    Quote Originally Posted by Coloradomrg View Post
    Because it is a lisp routine... not a macro.
    Macros support LISP, FWIW.



    Quote Originally Posted by Coloradomrg View Post
    Make sure the lisp routine is loaded.
    I would use an IF statement in the macro, or an AUTOLOAD statement in AcadDoc.lsp, to demand-load the LISP in an effort to minimize how much memory is consumed at drawing open.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Quote Originally Posted by chuh View Post
    Why doesn't this work in a macro?

    Using AutoCAD 2014

    Code:
    ^C^C(setq CE (getvar "CMDECHO"))(setvar "CMDECHO" 0)(setq DIST (getdist "Enter distance or <first point>:"))(setq DISTT (/ DIST 2))(command "offset" DISTT)(setvar "CMDECHO" CE)
    FWIW - it works fine as a macro here in 2013, 2014, and 2015.

    What is it doing or not doing for you?
    R.K. McSwain | CAD Panacea |

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    You might also want to look into the PAUSE keyword/function.



    [Edit] - Or, given the simplicity of the macro, simply adding an OFFSET Command alias.
    Last edited by BlackBox; 2014-09-09 at 02:21 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    I could stop if I wanted to
    Join Date
    2015-10
    Location
    Colorado Springs, CO
    Posts
    369
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Didn't know that... learned something new You guys are good for that around here.

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Quote Originally Posted by Coloradomrg View Post
    Didn't know that... learned something new You guys are good for that around here.
    That is kind of you to say, Coloradomrg; we're always happy to under-promise, and over-deliver.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Member
    Join Date
    2006-02
    Posts
    17
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Quote Originally Posted by BlackBox View Post
    You might also want to look into the PAUSE keyword/function.



    [Edit] - Or, given the simplicity of the macro, simply adding an OFFSET Command alias.
    First off, thank you for all of your help and input. Secondly, it seems to work now after a restart of autocad. Sigh. Sorry for the hassle.

    But lastly, can you please explain what you mean by adding a command alias?

    Thanks.

  9. #9
    Member
    Join Date
    2013-08
    Posts
    23
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    You can specify commands to be called under certain keystroke aliases. I.E. I have the command MATCHPROP to QR such that when I type QR it knows to run matchprop. You can access the command alias interface by typing ALIAS at the command line. It's a critical tool for drafting and speed.

    HTH

  10. #10
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,505
    Login to Give a bone
    0

    Default Re: why doesn't this lisp work in a macro?

    Quote Originally Posted by chuh View Post
    ... can you please explain what you mean by adding a command alias?

    Thanks.
    What "Mr. Box" is suggesting (I believe)...
    This macro basically does what the "offset" command does**, so why don't you create an alias (shorter version of the command) of offset to do this?
    Some people use "Alias Editor" but I go right into the Acad.pgp file to create/edit my command alias'.

    **The offset command allows either a typed in distance or you pick a distance (2 points on screen) which seems to be what you're doing in the macro.

    Just a thought

    BTW, my alias for "offset" is simply the letter "o", you can't get much quicker than:
    (command "o" <pick two points> <select line> <pick side you want it to offset> done!)
    Last edited by tedg; 2014-09-09 at 04:39 PM. Reason: added example

Page 1 of 2 12 LastLast

Similar Threads

  1. Lisp routine doesn't work
    By boyerd492098 in forum AutoLISP
    Replies: 16
    Last Post: 2015-01-27, 10:13 PM
  2. 2014: Why doesn't this macro work?
    By chris.mackay434411 in forum AutoCAD General
    Replies: 10
    Last Post: 2013-11-04, 12:25 PM
  3. LISP to Explode Dynamic Blocks Doesn't Work
    By stusic in forum AutoLISP
    Replies: 35
    Last Post: 2013-06-26, 05:20 PM
  4. Copy LISP doesn't work when zoomed out!
    By brekkja in forum AutoLISP
    Replies: 2
    Last Post: 2013-04-02, 11:23 AM
  5. lisp worked in 07 doesn't work in 09?
    By Hammer.John.J in forum AutoLISP
    Replies: 9
    Last Post: 2009-08-07, 04:22 PM

Posting Permissions

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