Jump to content

Macro from keyboard shortcut


oldsoftboss

Recommended Posts

Hi all,

 

I have a macro

 

^C^C^P(if (= C:FLXDCT nil)(load (strcat dct_drltr "/dct10/flxdct")))(princ) ^PFLXDCT

 

that runs from a click on on an icon in the toolbar. I would like to call this from a keyboard shortcut - say N - (doesn't seem to be used for any thing else).

Ideally I would like to tag this macro to the end of an AutoLisp, but that may be a task for another day.

 

Have played around with customising keyboard shortcuts in the CUI but they all seem to require the shift or ctrl key combinations.

 

Any feedback would be greatly appriciated.

 

Dave

Link to comment
Share on other sites

Once again Lee Mac - works a treat. Thankyou

 

How would I go tagging to the end of this lisp?

 

 
(defun c:FF (/ *error* LastEntity OldLayoer pt eLast ent)
;;
 (defun *error* ( msg )
   (and OldLayer (setvar "CLAYER" OldLayer))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))    
 (setq LastEntity (entlast) OldLayer (getvar "CLAYER"))

 (or (tblsearch "LAYER" "flex-cr")
     (command "_.-layer" "_M" "flex-cr" ""))  
;;
 (setvar 'filletrad
         (cond ((getdist (strcat "\nSpecify radius of flex bends <" (rtos (getvar 'filletrad)) ">: ")))
               ((getvar 'filletrad))
         )
 )
 (if (setq pt (getpoint "\nSpecify start point: "))
   (progn
;      (setq eLast (entlast))
     (setvar "CLAYER" "flex-cr")
     (command "_.pline" "_non" pt)
     (while (= 1 (logand (getvar 'cmdactive) 1))
       (princ "\nSpecify next point: ")
       (command PAUSE)
     )
     (or (equal eLast (setq ent (entlast)))
         (command "_.fillet" "_P" ent)
     )
   )
 )
 (setvar "CLAYER" OldLayer)
(princ)
)

.

 

This lisp creates the flex line. The n lisp puts a zig-zaggy line along it.

 

It would be great to have this all in one hit.

duct.jpg

Link to comment
Share on other sites

I suppose the easiest way would be something like this:

 

(defun c:FF ( / *error* LastEntity OldLayoer pt ent )

 (defun *error* ( msg )
   (and OldLayer (setvar "CLAYER" OldLayer))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )
 
 (setq LastEntity (entlast) OldLayer (getvar "CLAYER"))

 (or (tblsearch "LAYER" "flex-cr")
   (entmake
     (list
       (cons 0 "LAYER")
       (cons 100 "AcDbSymbolTableRecord")
       (cons 100 "AcDbLayerTableRecord")
       (cons 2 "flex-cr")
       (cons 70 0)
     )
   )
 )

 (setvar 'filletrad
   (cond
     (
       (getdist (strcat "\nSpecify radius of flex bends <" (rtos (getvar 'filletrad)) ">: "))
     )
     ( (getvar 'filletrad) )
   )
 )
 
 (if (setq pt (getpoint "\nSpecify start point: "))
   (progn
     (setvar "CLAYER" "flex-cr")
     
     (command "_.pline" "_non" pt)
     (while (= 1 (logand (getvar 'cmdactive) 1))
       (princ "\nSpecify next point: ")
       (command pause)
     )
     
     (or (equal LastEntity (setq ent (entlast)))
         (command "_.fillet" "_P" ent)
     )
   )
 )

 (setvar "CLAYER" OldLayer)
 (princ)

 (or c:flxdct (load (strcat dct_drltr "/dct10/flxdct") nil))
 (if c:flxdct (c:flxdct))
)

Link to comment
Share on other sites

Yet again you have come to the rescue. Thankyou

 

I was trying to add the function at the bottom of the code, then call the n function after the other lisp finished, but just kept getting an error no matter which way I tried it.

 

Who would of thought of simply adding the code to the bottom. :?

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