dreams Posted March 14, 2014 Share Posted March 14, 2014 Can someone help me to fix this issue? Is it possible to set an alert (with using particular text in inside the CAD file) while opening CAD files each time? Example: The alert will be “You have used IBM in this drawing”, if we have a text noted as “IBM” inside the CAD file. Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 14, 2014 Share Posted March 14, 2014 One example for text/mtext entities in active tab - should be placed in a start-up resource (i.e. acaddoc.lsp): (setq ssText (ssget "_X" '((0 . "*TEXT")))) (while ssText (if (wcmatch (cdr (assoc 1 (entget (setq entTemp (ssname ssText 0))))) "*IBM*") (setq ssText (alert "You have used IBM in this drawing!")) ) (setq ssText (ssdel ssText entTemp)) ) This may be extended to verify all tabs, support other entities or check for a list of words. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 14, 2014 Share Posted March 14, 2014 (if (ssget "_X" '((0 . "*TEXT")(1 . "IBM"))) (alert "You have used IBM in this drawing") ) Quote Link to comment Share on other sites More sharing options...
dreams Posted March 14, 2014 Author Share Posted March 14, 2014 Hi MSasu/Tharwat..Thanks... I have added in that lisp file (acaddoc.lsp)...but its not working...I am not familiar in lisp settings..Please help me... Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 14, 2014 Share Posted March 14, 2014 Where did you placed the said file? This article by Lee Mac may be of help to you. Quote Link to comment Share on other sites More sharing options...
dreams Posted March 14, 2014 Author Share Posted March 14, 2014 acad2007doc.lsp Here is the file which i edited one...I was added in the last line.. Please correct this file if i am wrong.. Quote Link to comment Share on other sites More sharing options...
fixo Posted March 14, 2014 Share Posted March 14, 2014 You haven't use acadxxxx.lsp use instead acadoc.lsp or acad.lsp Quote Link to comment Share on other sites More sharing options...
dreams Posted March 14, 2014 Author Share Posted March 14, 2014 Oh..thanks Fixo..I will try this one.. Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 14, 2014 Share Posted March 14, 2014 Please check the tutorial from my previous post to create an user auto-loader. Isn't a good practice to use the system one (acaddoc20##.lsp) since may be overwriten, so may want to avoid this. Also, you will need to add only one solution there to don't get two warnings in a row; I suggest to use Tharwat's one since is faster. Quote Link to comment Share on other sites More sharing options...
dreams Posted March 15, 2014 Author Share Posted March 15, 2014 Hi MSasu/Tharwat..Its working fine..thanks for the help.. It would be very helpful to my work...Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 15, 2014 Share Posted March 15, 2014 Very good , Good luck . Quote Link to comment Share on other sites More sharing options...
dreams Posted November 20, 2014 Author Share Posted November 20, 2014 Hi Tharwat, I need your help again. Is it possible to add a list of different texts for Alert while opening CAD file? Please refer my sample notes.. 1.The text is IBM - Alert should shown as "You have used IBM in this drawing" 2.The texts are Coupler/Thread/Threading/Threaded/Threading – Alert should shown as “You have used COUPLER/THREADED BARS in this drawing 3.The texts are Form savers/End preparation - Alert should shown as “FORM SAVERS are used" The code is below, (setq ssText (ssget "_X" '((0 . "*TEXT")))) (if (ssget "_X" '((0 . "*TEXT")(1 . "IBM"))) (alert "You have used IBM in this drawing") ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 20, 2014 Share Posted November 20, 2014 I guess it depends on how you feed the filter for the ssget function so you can have the same string in your alert function . Quote Link to comment Share on other sites More sharing options...
dreams Posted November 20, 2014 Author Share Posted November 20, 2014 Hi Tharwat, Thanks for the reply. .. I tried already but its not working. FYI, I will have to add more text alert in future... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 20, 2014 Share Posted November 20, 2014 FYI, I will have to add more text alert in future... Show me the way you are feeding your strings and functions , to allow me and the other users to know how to make it work for you and try to give you the best solution . Quote Link to comment Share on other sites More sharing options...
dreams Posted November 20, 2014 Author Share Posted November 20, 2014 I am not familiar with lisp codes.. Here is the below code details which i tried... ((setq ssText (ssget "_X" '((0 . "*TEXT")))) (if (ssget "_X" '((0 . "*TEXT")(1 . "IBM"))) (alert "You have used IBM in this drawing") ) (if (ssget "_X" '((0 . "*TEXT")(1 . "COUPLER"))) (alert "You have used COUPLER/THREADED BARS in this drawing") ) (if (ssget "_X" '((0 . "*TEXT")(1 . "Form savers"))) (alert "FORM SAVERS are used") ) (if (ssget "_X" '((0 . "*TEXT")(1 . "coupler"))) (alert "You have used Coupler in this drawing which we have to provide separate material list") ) (if (ssget "_X" '((0 . "*TEXT")(1 . "THREAD"))) (alert "You have used COUPLER/THREADED BARS in this drawing") ) (if (ssget "_X" '((0 . "*TEXT")(1 . "THREADING"))) (alert "You have used COUPLER/THREADED BARS in this drawing") ) ) Quote Link to comment Share on other sites More sharing options...
dreams Posted November 20, 2014 Author Share Posted November 20, 2014 Also it's not finding same text in other cases (Upper, lower & Title case)... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 20, 2014 Share Posted November 20, 2014 Try this . (if (setq ss (ssget "_X" '((0 . "*TEXT") (1 . "IBM,COUPLER,Form savers,coupler,THREAD,THREADING") ) ) ) (progn (repeat (setq i (sslength ss)) (setq st (cdr (assoc 1 (entget (ssname ss (setq i (1- i))))))) (if (not (member st lst)) (setq lst (cons st lst)) ) ) (if lst (progn (setq l (vl-remove-if-not '(lambda (u) (member u lst)) '("IBM" "COUPLER" "Form savers" "coupler" "THREAD" "THREADING" ) ) ) (alert (strcat "You have used < " (substr (setq s (apply 'strcat (mapcar '(lambda (x) (strcat x ",")) l) ) ) 1 (1- (strlen s)) ) " > in this drawing" ) ) ) ) ) (alert "Couldn't find any of these strings < IBM,COUPLER,Form savers,coupler,THREAD,THREADING > in drawing " ) ) Quote Link to comment Share on other sites More sharing options...
dreams Posted November 21, 2014 Author Share Posted November 21, 2014 Hi Tharwat...It’s working awesome & super..This is what i expected.. Thanks again Quote Link to comment Share on other sites More sharing options...
dreams Posted November 21, 2014 Author Share Posted November 21, 2014 Hi Tharwat, i have an issue while using this lisp, It's not finding the text in the combined sentences. Example: Male Coupler at one End FYI, It's finding only separate text only. have you got my point? Do you have any suggestion on this?? 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.