DRBJR45 Posted November 21, 2014 Posted November 21, 2014 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);CLAYER;Dim;_dimlinear;\\\ CLAYER;$M="$(getenv,CURRENTLAYER)"; Thanks DRBJR45 Quote
BIGAL Posted November 21, 2014 Posted November 21, 2014 Its easier to make lots of little lisp defuns and autoload them or put them on a menu or toolbar. ; 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) ) Quote
DRBJR45 Posted November 24, 2014 Author Posted November 24, 2014 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! Its easier to make lots of little lisp defuns and autoload them or put them on a menu or toolbar. ; 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) ) Quote
BIGAL Posted November 25, 2014 Posted November 25, 2014 (edited) This is revised version with prompts ; 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) ) Edited November 26, 2014 by BIGAL extra bracket Quote
DRBJR45 Posted November 25, 2014 Author Posted November 25, 2014 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 Quote
hmsilva Posted November 25, 2014 Posted November 25, 2014 (edited) Extra parenthesis (setq ans (getstring [b][color=red]([/color][/b]"\nEnter H V or A")) EDIT: I would suggest something like this (defun c:ddd (/ clay) (setq clay (getvar 'CLAYER)) (setvar 'CLAYER "DIMENSIONS") (command "_.dimlinear") (while (> (getvar 'cmdactive) 0) (command "\\") ) (setvar 'CLAYER clay) (princ) ) Henrique Edited November 25, 2014 by hmsilva Add code Quote
DRBJR45 Posted November 25, 2014 Author Posted November 25, 2014 Henrique, Works perfectly! I'm excited about learning more about lisp, this should help get me started. Take care and thanks. Don Quote
hmsilva Posted November 25, 2014 Posted November 25, 2014 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. (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 Quote
DRBJR45 Posted November 25, 2014 Author Posted November 25, 2014 Henrique, Thanks for the tips....Ive found some sites for beginners in LISP. Some of the basics look easy (famous last words!) Don Quote
hmsilva Posted November 25, 2014 Posted November 25, 2014 Ive found some sites for beginners in LISP Don, you don't have to look far, try here @ CADTutor Henrique Quote
DRBJR45 Posted November 25, 2014 Author Posted November 25, 2014 Don, you don't have to look far, try here @ CADTutor Henrique Henrique, Looks like i can get a good start there..thanks! Quote
BIGAL Posted November 26, 2014 Posted November 26, 2014 Thanks Hmsilva code amended you do simple things not tested and forget to double check the most obvious the mismatched brackets. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.