amb2301 Posted October 3, 2018 Posted October 3, 2018 hi Friends I have a task like to check the availability of few blocks & text in bunch of drawings, all the drawings, which i check should contain that standard blocks & texts to be present, if it is missed in drawing, it should notify me the missed things. Kindly help me to complete this task using lisp. Thanks in Advance. Quote
BIGAL Posted October 3, 2018 Posted October 3, 2018 (edited) Its not that hard you just get a list of blocknames and compare say to a list in a text file. The standard texts may be a little more difficult but can be done the same I would suggest using a strcase as part of the compare so upper and lower is not a problem. this is not actual program but example bits of code (tblsearch "BLOCK" "Northn") ((0 . "BLOCK") (2 . "NORTHN") (70 . 0) (4 . "") (10 0.0 0.0 0.0) (-2 . <Entity name: 3af96230>)) (tblsearch "BLOCK" "Nort") nil (while read file (setq found (tblsearch "BLOCK" blockname)) (if (= found nil) (alert (strcat "block name not found " blockname)) (princ) ) ......................... ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for blk (vla-get-blocks doc) (princ (vla-get-name blk) ) ) Edited October 3, 2018 by BIGAL Quote
amb2301 Posted October 4, 2018 Author Posted October 4, 2018 hi Bigal, Thanks for looking on this post, its bit confusing for me to edit the lisp as i am new to this, i have attached the error screen shot, please check it. i have a 3 blocks named test1,test2 & test3, i just need to find this blocks using lisp & tell that "all blocks are available" if one block is missing, it should mentioned its name like " test2 is missing" Thanks Quote
ronjonp Posted October 4, 2018 Posted October 4, 2018 (edited) (defun c:foo (/ l) (setq l '("test1" "test2" "test3")) (foreach a l (or (tblobjname "block" a) (alert (strcat a " DOES NOT EXIST!")))) (princ) ) Edited October 5, 2018 by ronjonp changed and to or Quote
Tharwat Posted October 4, 2018 Posted October 4, 2018 @ronjonp You may need to replace AND with OR. Quote
amb2301 Posted October 4, 2018 Author Posted October 4, 2018 Thank you both ( ronjonp & tharwat), it worked like a charm simillarly is there any other way to check the text, like "CONSTRUCTION DRAWING" word is missing, it should alert in same way. thanks in Advance Quote
ronjonp Posted October 4, 2018 Posted October 4, 2018 1 hour ago, Tharwat said: @ronjonp You may need to replace AND with OR. Oops! Quote
BIGAL Posted October 5, 2018 Posted October 5, 2018 The code I posted was 3 parts of example how to do it not actual program. Ok a start this will write a text file of all your block names to a file in the Temp directory change it if you do not have one. Only run once its just to make the list of names. (setq fo (open "c:\\temp\\blklist.txt" "w")) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for blk (vla-get-blocks doc) (write-line (strcat (chr 34) (vla-get-name blk) (chr 34)) fo) ) (close fo) Open the text file and add (setq l '( as first line add ) as last line and replace the line in ronjonp code for the block names (defun c:foo (/ l) (setq l '( "*Model_Space" "*Paper_Space" "AeccArwClosedFilled" "Station Mark" "Utility Pole" "Existing Hyd" "Proposed Hyd" "Guy Pole" ) (foreach a l (and (tblobjname "block" a) (alert (strcat a " DOES NOT EXIST!")))) (princ) ) 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.