Jump to content

Run macro from pgp file


DRBJR45

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...