ziele_o2k Posted August 25, 2015 Posted August 25, 2015 Hello, I'm working on pack of lisp routines not only for my use. I would like to make my own file with aliases definition for lisps (simmilar to pgp file) e.g. I have lisp functions defined as c:XXX (defun c:MYlisp_1 ... ) (defun c:MYlisp_2 ... ) (defun c:MYlisp_3 ... ) And now i would like to make file (e.g. .txt) with aliases aa MYlisp_1 ae MYlisp_2 qw MYlisp_3 But i don't know how to start with lisp that will translate to CAD: if user will type qw , CAD should start executing MYlisp_3 routine . I need to make possible that each user can apply his shortcuts. I hope that I explained well enough what I mean. Thanks in advance! Quote
BIGAL Posted August 26, 2015 Posted August 26, 2015 Maybe this (defun C:qw (if (not mylisp3 (load "MYLISP3")))(C:mylisp3)); expects that your calling a defun from within mylisp. Quote
ziele_o2k Posted August 26, 2015 Author Posted August 26, 2015 Maybe something like this I have lisp to read aliases from text file that will return something like this: !list_of_aliases (("aa" "MYlisp_1") ("ae" "MYlisp_2") ("qw" "MYlisp_3")) and now mayby something like this on CAD startup: (setq lst (mapcar '(lambda (%) (strcat "(defun C:" (nth 0 %) "() (C:" (nth 1 %) "))") ) list_of_aliases ) ) (setq file (vl-filename-mktemp "aliases.lsp")) (WriteFile file lst) ;WriteFile is my lisp that write list to file (load file) Quote
BIGAL Posted August 27, 2015 Posted August 27, 2015 This is almost the same as another post today and my answer was how to trap the command error and run a lisp, you type aa Autocad says unknown command, it then runs a look up list lisp and loads the correct lisp that matches aa, Sorry no idea how to do. It will be a reactor lisp. Quote
ziele_o2k Posted August 27, 2015 Author Posted August 27, 2015 I wrote this lisp: (defun LOADalias ( / data r res lst file) (setq data (cd:SYS_ReadFile nil "J:\\alias.txt"));alias file with path (mapcar '(lambda (x1) (if (or (= ";" (substr x1 1 1)) (= "" (substr x1 1 1)) (= "[" (substr x1 1 1)) ) nil (setq r (cons x1 r)) ) ) data ) (foreach line r (setq res (cons (cd:STR_Parse line " " T) res)) ) (setq lst (mapcar '(lambda (%) (strcat "(defun C:" (nth 0 %) "() (C:" (nth 1 %) "))") ) res ) ) (setq file (vl-filename-mktemp "aliases.lsp")) (cd:SYS_WriteFile file lst nil) (load file) (princ) ) And it's working Bolow example .txt file with aliases ;only spacebar allowed [v1.00] user_alias1 my_lisp1 user_alias2 my_lisp2 user_alias3 my_lisp3 [v1.01] user_alias4 my_lisp4 user_alias5 my_lisp5 user_alias6 my_lisp6 To run LOADalias you have to load attached lisp library Cad_pack.lsp Quote
eldon Posted August 27, 2015 Posted August 27, 2015 Just an idle thought - why do you need aliases for lisps? You can write the lisp with any command name you like, so make the command for the actual lisp something simple, then you would not need an alias. Quote
ziele_o2k Posted August 27, 2015 Author Posted August 27, 2015 Just an idle thought - why do you need aliases for lisps? You can write the lisp with any command name you like, so make the command for the actual lisp something simple, then you would not need an alias. Answer is in my first post I'm working on pack of lisp routines not only for my use. and I need to make possible that each user can apply his shortcuts. Quote
BIGAL Posted August 28, 2015 Posted August 28, 2015 A thing called company standards comes to mind one alias one command. All staff live with a common set. 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.