Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

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

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

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

Henrique,

 

Works perfectly!

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

 

Don

Posted

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

Posted

Henrique,

 

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

Don

Posted

Ive found some sites for beginners in LISP

 

Don,

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

 

Henrique

Posted
Don,

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

 

Henrique

 

 

Henrique,

 

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

Posted

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

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