comcu Posted March 26, 2009 Posted March 26, 2009 Hi, is it possible to run a macro from the numbers (not numberpad). i am using all my F keys and want to set the keys up so the run a macro, even if it the number then enter? is the only way possible thru lisp, or vba? cheers, Col Quote
BIGAL Posted March 26, 2009 Posted March 26, 2009 Using lisp you can make programs and give them a number name we use 39 59 99 for setting osnaps. (defun c:39()(setvar "osmode" 39)) Quote
comcu Posted March 26, 2009 Author Posted March 26, 2009 Hi, i tried setting them in my pgp but it only seems to work with commands and not a actual macro? Quote
CarlB Posted March 26, 2009 Posted March 26, 2009 True, pgp can only contain shortcuts for a single AutoCAD command, not for lisps, not for a macro/group of commands. I believe you'll need to use a lisp routine that includes an 'enter' after typing the number, per BIGAL's example. Quote
comcu Posted March 26, 2009 Author Posted March 26, 2009 Cheers, i will have a play around. is the same thing possible in vba, i do not no lisp at all but i think i will start to learn as it is obviously handy. i have a vba module that sets the layer based on what commnad you pick eg if you select dimlinear the layer is set to "Dimension", xl selected then layer is set to "Construction" from that i would assume you could do set vba to wait for key strokes then activate a macro? cheers col. Quote
CarlB Posted March 26, 2009 Posted March 26, 2009 I believe you call a vba routine, in lisp, with (command "vbarun" "vba_module_name") So lisp routine that would be acticvted with "1" and that would run the vba code would look something like: (defun c:1 () (command "vbarun" "vba_module_name") (princ) ) Quote
CmdrDuh Posted March 26, 2009 Posted March 26, 2009 you have a couple of options. You could use a command reactor to look at last command and do layer manip from there, or you could put all you work in code and set layer from there. Depends on what your trying to do. Quote
BIGAL Posted March 27, 2009 Posted March 27, 2009 We have some software that must do "the look at last command" if you manage to sort of jump out of it midstream (we often manage to do it) then it keeps asking for an OK to continue in between every normal Autocad command its a bit of a pain. We have to close and reopen we will advise the vendor of the bug. I guess I am hinting at the pgp acad.lsp way calling vba's its simple and works. (defun C:1() (vl-vbaload "F:/VBA/MYPROG.dvb") (vl-vbarun "LAYDIM")) Quote
CmdrDuh Posted March 27, 2009 Posted March 27, 2009 I use the lsp method as well. Simple, easy to maintain, and pretty much foolproof Quote
comcu Posted March 29, 2009 Author Posted March 29, 2009 Hi, yes i have used the lisp method, never used lisp before but its very handy for creating new commands i am just transfering the macro i have wrote over to the lisp cheers, col. Quote
comcu Posted March 30, 2009 Author Posted March 30, 2009 (defun c:4 () (command "multiple" "dimlinear" pause pause pause) (princ) ) tried the above to allow me to use the key "4" to multiple command for dimlinear but not working, i tried ditching the "multiple" and put "" at the end but it returned command 4 not found? i understand it is trying to repeat the command 4 but it is autocad does not understand this? cheers, col. Quote
Lee Mac Posted March 30, 2009 Posted March 30, 2009 Why not just use a while statement to repeat the command? (defun c:4 (/ iPt) (while (setq iPt (getpoint "\nSelect First Point: ")) (command "multiple" "dimlinear" iPt pause pause)) (princ) ) Quote
comcu Posted March 30, 2009 Author Posted March 30, 2009 Lee, Why not indeed! that works really well, thansk for that will be able to modify it for a few other things Cheers, Col. Quote
Lee Mac Posted March 30, 2009 Posted March 30, 2009 Lee, Why not indeed! that works really well, thansk for that will be able to modify it for a few other things Cheers, Col. No probs, anything else Col, just ask 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.