Jump to content
DRBJR45

Run macro from pgp file

Recommended Posts

DRBJR45

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

Share this post


Link to post
Share on other sites
BIGAL

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) 
)

Share this post


Link to post
Share on other sites
DRBJR45

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) 
)

Share this post


Link to post
Share on other sites
BIGAL

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 by BIGAL
extra bracket

Share this post


Link to post
Share on other sites
DRBJR45

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

Share this post


Link to post
Share on other sites
hmsilva

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 by hmsilva
Add code

Share this post


Link to post
Share on other sites
DRBJR45

Henrique,

 

Works perfectly!

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

 

Don

Share this post


Link to post
Share on other sites
hmsilva

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

Share this post


Link to post
Share on other sites
DRBJR45

Henrique,

 

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

Don

Share this post


Link to post
Share on other sites
hmsilva

Ive found some sites for beginners in LISP

 

Don,

you don't have to look far, try here @ CADTutor

 

Henrique

Share this post


Link to post
Share on other sites
DRBJR45
Don,

you don't have to look far, try here @ CADTutor

 

Henrique

 

 

Henrique,

 

Looks like i can get a good start there..thanks!

Share this post


Link to post
Share on other sites
BIGAL

Thanks Hmsilva code amended you do simple things not tested and forget to double check the most obvious the mismatched brackets.

Share this post


Link to post
Share on other sites
hmsilva

You're welcome, BIGAL.

 

Henrique

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×