Jump to content

Recommended Posts

Posted

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.

 

Posted (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 by BIGAL
Posted

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

 

 

error.PNG

Posted (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 by ronjonp
changed and to or
Posted

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

Posted
1 hour ago, Tharwat said:

@ronjonp

You may need to replace AND with OR. ;) 

Oops!

Posted

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)
)

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...