+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Full Member DRBJR45's Avatar
    Discipline
    Manufacture
    DRBJR45's Discipline Details
    Discipline
    Manufacture
    Details
    ARCHITECTURAL METAL METALS, ORNAMENTAL IRON, PACKAGE DESIGN. LOTS OF SHEET METAL AND CNC, WATER JET, PLASMA AND LASER.
    Using
    AutoCAD 2013
    Join Date
    Jan 2011
    Location
    PHOENIX ARIZONA USA
    Posts
    38

    Default Run macro from pgp file

    Registered forum members do not see this ad.

    HI

    Is there a way to run a macro using keyboard shortcut key (acad.pgp)? I would love to add the following to the PGP file if possible.

    I added the following to the DIMLINEAR command button and it works:
    ^C^C-layer;Set;DIMENSIONS;;^C^C_dimlinear\\\\ ^C^C-layer;Set;0;;^C^C


    I found this one that is better than the one i made for the dimlinear button:
    ^C^C_setenv;CURRENTLAYER;$M=$(getvar,CLAYER);CLAYE R;Dim;_dimlinear;\\\
    CLAYER;$M="$(getenv,CURRENTLAYER)";




    Thanks
    DRBJR45

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,746

    Default

    Its easier to make lots of little lisp defuns and autoload them or put them on a menu or toolbar.

    Code:
    ; example appload this then type ddd
    ;^C^C-layer;Set;DIMENSIONS;;^C^C_dimlinear\\\\ ^C^C-layer;Set;0;;^C^C
    (defun C:ddd ()
    (setq oldlay  (getvar "clayer"))
    (setvar "clayer" "dimensions")
    (command "_dimlinear" (getpoint) (getpoint)(getstring)(getpoint)) ;  not tested
    (setvar "clayer" oldlay) 
    )
    A man who never made mistakes never made anything

  3. #3
    Full Member DRBJR45's Avatar
    Discipline
    Manufacture
    DRBJR45's Discipline Details
    Discipline
    Manufacture
    Details
    ARCHITECTURAL METAL METALS, ORNAMENTAL IRON, PACKAGE DESIGN. LOTS OF SHEET METAL AND CNC, WATER JET, PLASMA AND LASER.
    Using
    AutoCAD 2013
    Join Date
    Jan 2011
    Location
    PHOENIX ARIZONA USA
    Posts
    38

    Default

    Thanks,
    Never did have interest in lisp, guess its time. For some reason your example did not work. starts the dimlinear command and changes layer but thats it. I will use this as a starting point in learning some lisp......

    Again, Thanks!





    Quote Originally Posted by BIGAL View Post
    Its easier to make lots of little lisp defuns and autoload them or put them on a menu or toolbar.

    Code:
    ; example appload this then type ddd
    ;^C^C-layer;Set;DIMENSIONS;;^C^C_dimlinear\\\\ ^C^C-layer;Set;0;;^C^C
    (defun C:ddd ()
    (setq oldlay  (getvar "clayer"))
    (setvar "clayer" "dimensions")
    (command "_dimlinear" (getpoint) (getpoint)(getstring)(getpoint)) ;  not tested
    (setvar "clayer" oldlay) 
    )

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,746

    Default

    This is revised version with prompts

    Code:
    ; example appload this then type ddd
    ;^C^C-layer;Set;DIMENSIONS;;^C^C_dimlinear\\\\ ^C^C-layer;Set;0;;^C^C
    (defun C:ddd ( / pt1 pt2 pt3 ans)
    (setq oldlay  (getvar "clayer"))
    (setvar "clayer" "dimensions")
    (setq pt1 (getpoint "\npick 1st point"))
    (setq pt2 (getpoint "\nPick 2nd point"))
    (setq ans  (getstring "\nEnter H V or A")) ; use initget here
    (setq pt3 (getpoint "\nPick entension pt"))
    (command "_dimlinear" pt pt2 ans pt3 ) ;  not tested
    (setvar "clayer" oldlay) 
    )
    Last edited by BIGAL; 26th Nov 2014 at 02:33 am. Reason: extra bracket
    A man who never made mistakes never made anything

  5. #5
    Full Member DRBJR45's Avatar
    Discipline
    Manufacture
    DRBJR45's Discipline Details
    Discipline
    Manufacture
    Details
    ARCHITECTURAL METAL METALS, ORNAMENTAL IRON, PACKAGE DESIGN. LOTS OF SHEET METAL AND CNC, WATER JET, PLASMA AND LASER.
    Using
    AutoCAD 2013
    Join Date
    Jan 2011
    Location
    PHOENIX ARIZONA USA
    Posts
    38

    Default

    BIGAL

    I really appreciate your trying to help. Im sorry to let you know I'm getting this error:

    Command: appload DDD.LSP successfully loaded.
    DDD.LSP was added to the Startup Suite.
    DDD.LSP successfully loaded.


    Command: ; error: malformed list on input

    Command:
    Command: ; error: malformed list on input

    Command:
    Command: ddd Unknown command "DDD". Press F1 for help.

    Thanks again
    DRBJR45

  6. #6
    Super Member hmsilva's Avatar
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Dec 2012
    Location
    Cascais, Portugal
    Posts
    531

    Default

    Extra parenthesis
    Code:
     
    (setq ans  (getstring ("\nEnter H V or A"))

    EDIT: I would suggest something like this
    Code:
     
    (defun c:ddd (/ clay)
      (setq clay (getvar 'CLAYER))
      (setvar 'CLAYER "DIMENSIONS")
      (command "_.dimlinear")
      (while (> (getvar 'cmdactive) 0)
        (command "\\")
      )
      (setvar 'CLAYER clay)
      (princ)
    )
    Henrique
    Last edited by hmsilva; 25th Nov 2014 at 04:23 pm. Reason: Add code

  7. #7
    Full Member DRBJR45's Avatar
    Discipline
    Manufacture
    DRBJR45's Discipline Details
    Discipline
    Manufacture
    Details
    ARCHITECTURAL METAL METALS, ORNAMENTAL IRON, PACKAGE DESIGN. LOTS OF SHEET METAL AND CNC, WATER JET, PLASMA AND LASER.
    Using
    AutoCAD 2013
    Join Date
    Jan 2011
    Location
    PHOENIX ARIZONA USA
    Posts
    38

    Default

    Henrique,

    Works perfectly!
    I'm excited about learning more about lisp, this should help get me started. Take care and thanks.

    Don

  8. #8
    Super Member hmsilva's Avatar
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Dec 2012
    Location
    Cascais, Portugal
    Posts
    531

    Default

    You're welcome, Don.
    Glad I could help.


    EDIT: another way so set the layer DIMENSIONS as current, is using the command 'layer', that allows us to set as current even the layer does not exist, or if exist and is locked, or frozen or off,
    i.e.
    Code:
    (command "_.layer" "_U" "DIMENSIONS" "_T" "DIMENSIONS" "_M" "DIMENSIONS" "")
    If the layer does no exist, will prompt an 'No matching layer names found.' but the command proceeds and make the Layer 'DIMENSIONS' current.

    Henrique

  9. #9
    Full Member DRBJR45's Avatar
    Discipline
    Manufacture
    DRBJR45's Discipline Details
    Discipline
    Manufacture
    Details
    ARCHITECTURAL METAL METALS, ORNAMENTAL IRON, PACKAGE DESIGN. LOTS OF SHEET METAL AND CNC, WATER JET, PLASMA AND LASER.
    Using
    AutoCAD 2013
    Join Date
    Jan 2011
    Location
    PHOENIX ARIZONA USA
    Posts
    38

    Default

    Henrique,

    Thanks for the tips....Ive found some sites for beginners in LISP. Some of the basics look easy (famous last words!)
    Don

  10. #10
    Super Member hmsilva's Avatar
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Dec 2012
    Location
    Cascais, Portugal
    Posts
    531

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by DRBJR45 View Post
    Ive found some sites for beginners in LISP
    Don,
    you don't have to look far, try here @ CADTutor

    Henrique

Similar Threads

  1. Lisp or macro to select ctb file ?
    By sinnerboy in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 29th Sep 2011, 02:47 pm
  2. How to use a relative path in a Macro to run a .lsp file?
    By Alaskachick in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 1
    Last Post: 28th Oct 2010, 10:54 pm
  3. Open file and run lisp - macro
    By mdbdesign in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 26th May 2010, 08:08 pm
  4. Publish File Contain Macro
    By MR MAN in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 1
    Last Post: 25th Jun 2008, 08:24 am
  5. Macro Button for file opening
    By geoffc in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 17th Aug 2005, 06:41 pm

Tags for this Thread

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