wrha Posted August 24, 2015 Share Posted August 24, 2015 I have data base for objects i need lisp when I write code of the object insert Description as text in autocad Example description Code M20 socket M20 M24 socket M24 M30 socket M30 What i mean when I write M20 lisp insert M20 socket. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 24, 2015 Share Posted August 24, 2015 It is just a matter of asking the user to specify a point and the text is inserted ! Is not the right time to try your own abilities to write this simple lisp ? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 24, 2015 Share Posted August 24, 2015 You must be lazy so have a play with this and let me know . (defun c:Test (/ kw st pt) ;; Tharwat 24.08.2015 ;; (if (and (progn (initget 6 "20 24 30") (setq kw (getkword "\nSpecify the insertion text key < M(**) socket M(**) > [20,24,30] <Enter = Exit>:" ) ) ) (setq st (nth (vl-position kw '("20" "24" "30")) '("M20 socket M20" "M24 socket M24" "M30 socket M30") ) ) ) (while (setq pt (getpoint (strcat "\nSpecify insertion point for text < " st " > <Enter = Exit>:" ) ) ) (entmake (list '(0 . "TEXT") (cons 10 (trans pt 1 0)) (cons 11 (trans pt 1 0)) (cons 1 st) (cons 7 (getvar 'TEXTSTYLE)) (cons 40 (getvar 'TEXTSIZE)) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
wrha Posted August 24, 2015 Author Share Posted August 24, 2015 thanks its working Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 24, 2015 Share Posted August 24, 2015 thanks its working You are welcome . Enjoy it. Quote Link to comment Share on other sites More sharing options...
wrha Posted August 24, 2015 Author Share Posted August 24, 2015 thanks again but I failed to add more descriptions could you help Quote Link to comment Share on other sites More sharing options...
wrha Posted August 24, 2015 Author Share Posted August 24, 2015 I Try To add M40 to insert socket 40 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 24, 2015 Share Posted August 24, 2015 I Try To add M40 to insert socket 40 Have a close look . (and (progn (initget 6 "20 24 30 [color=magenta]40[/color]") (setq kw (getkword "\nSpecify the insertion text key < M(**) socket M(**) > [20,24,30,[color=magenta]40[/color]] <Enter = Exit>:" ) ) ) (setq st (nth (vl-position kw '("20" "24" "30" [color=magenta]"40"[/color])) '("M20 socket M20" "M24 socket M24" "M30 socket M30" [color=magenta]"M40 socket M40"[/color]) ) ) ) Quote Link to comment Share on other sites More sharing options...
wrha Posted August 24, 2015 Author Share Posted August 24, 2015 thanks a lot Mr. Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 24, 2015 Share Posted August 24, 2015 thanks a lot Mr. Tharwat You're welcome anytime Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 24, 2015 Share Posted August 24, 2015 Here's another approach, to remove an extra step: ( (lambda nil (foreach x '("20" "24" "30" "40") (eval (list 'defun (read (strcat "c:m" x)) '( / ins ocs ) '(setq ocs (trans '(0 0 1) 1 0 t)) (list 'if '(setq ins (getpoint "\nSpecify point for text: ")) (list 'entmake (list 'list ''(0 . "TEXT") '(cons 10 (trans ins 1 ocs)) '(cons 11 (trans ins 1 ocs)) '(cons 40 (getvar 'textsize)) '(cons 07 (getvar 'textstyle)) '(cons 50 (angle '(0.0 0.0) (trans (getvar 'ucsxdir) 0 ocs t))) (list 'quote (cons 1 (strcat "M" x " Socket"))) ''(72 . 1) ''(73 . 2) '(cons 210 ocs) ) ) ) '(princ) ) ) ) ) ) The above will define the custom commands: 'M20', 'M24', 'M30', 'M40'. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 25, 2015 Share Posted August 25, 2015 A couple more suggestions. If your doing this over and over you could just type M20 with a series of little lisp defuns in one lsip file, (defun c:M20 () ...... Why not even a menu item "Bolts" 20 30 40 etc or a toolbar. A DCL list select. If I can get the old screen menu working another way. There are a lot of choices. Have a go at doing one of the others yourself. Quote Link to comment Share on other sites More sharing options...
wrha Posted August 25, 2015 Author Share Posted August 25, 2015 I ALREADY I DID BUT KINDLY TO CHECK WHATS PROPLEM IN M30 , M36 OTHERS WORKING OK . (defun c:socket (/ kw st pt) ;; Tharwat 24.08.2015 ;; (if (and (progn (initget 16 "M12 M16 M20 M24 M30 M36") (setq kw (getkword "\nSpecify the insertion text key [12,16,20,30,36] :" ) ) ) (setq st (nth (vl-position kw '("M12" "M16" "M20" "30" "36")) '("M12 810220 pcs" "M16 810221 pcs" "M20 810222 pcs" "M24 810223 pcs" "M24 810224 pcs" "M36 810225 pcs") ) ) ) (while (setq pt (getpoint (strcat "\nSpecify insertion point for text st " > :" ) ) ) (entmake (list '(0 . "TEXT") (cons 10 (trans pt 1 0)) (cons 11 (trans pt 1 0)) (cons 1 st) (cons 7 (getvar 'TEXTSTYLE)) (cons 40 (getvar 'TEXTSIZE)) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
wrha Posted August 25, 2015 Author Share Posted August 25, 2015 Kinly if you correct the lisp just refer to the inputs by diffrent color because i will add my data base and its huge . Thanks Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 26, 2015 Share Posted August 26, 2015 add my data base and its huge Just me I would setup a text file with all the data, even different ones, this would be easier than bloating the lisp file. You could have a shortcut for each type but run only 1 master file. Bolts, Bolts and length etc. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 26, 2015 Share Posted August 26, 2015 I ALREADY I DID BUT KINDLY TO CHECK WHATS PROPLEM IN M30 , M36 OTHERS WORKING OK . (vl-position kw '("M12" "M16" "M20" "30" "36") Is the above list the same as the one that I included in my program ? Quote Link to comment Share on other sites More sharing options...
wrha Posted August 26, 2015 Author Share Posted August 26, 2015 Sorry for delay in replying. Yes I changed according to what I wrote. Kindly check what is wrong Quote Link to comment Share on other sites More sharing options...
wrha Posted August 26, 2015 Author Share Posted August 26, 2015 kindly to refer by different color for input and output to got possibility to add my data base because for each object (socket) I have code number . for example when I select (M20)insert (812020) (M24)insert (812024) ... etc the objects which I need to add it is to much . I hope I got help thanks Quote Link to comment Share on other sites More sharing options...
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.