Jump to content

How can I distinguish a "title-block"?


bababarghi

Recommended Posts

Hi,

 

I have heaps of drawing in front of me right now (500 almost). They all contain one Layout but with different layout naming pattern. The titleblock also doesn't necessarily sit in Layout space (they are in Model Space in some drawings) and they may also have different names e.g. "A3" or "HPT-A2" etc.

 

My problem is, some of the title-blocks are exploded i.e. they do not contain attributes anymore (text objects only). How can I know what number of this drawing pile have exploded title-blocks and how many haven't?

Link to comment
Share on other sites

if (tblsearch "block" "title-block") returns nil (after a purge) or (ssget "x" (list (cons 0 "insert") (cons 2 "title-block"))) returns nil your title-block is kaput... if there are many names you can put them in a list or use a comma (cons 2 "title-block,A3,...") or a little more advanced use vl-some to try each name in a list.. many wayz

 

 

gr.R.

Link to comment
Share on other sites

if (tblsearch "block" "title-block") returns nil (after a purge) or (ssget "x" (list (cons 0 "insert") (cons 2 "title-block"))) returns nil your title-block is kaput... if there are many names you can put them in a list or use a comma (cons 2 "title-block,A3,...") or a little more advanced use vl-some to try each name in a list.. many wayz

 

 

gr.R.

 

"title-block" string can be literally anything ! I just mentioned couple of samples in my first post. I don't have the list of available title block's names.

Link to comment
Share on other sites

No way a programm can guess a name so you have to feed it something... it can be a long list but the list is not endless.

 

 

(defun tst ( / blk )
 (if (setq blk (vl-some '(lambda (x)(if (tblsearch "block" x) x nil)) '("title-block" "A3" "term_1b")))
   (alert (strcat "found block " blk))(alert "Not any valid block was found")))

That being said, I did (do) have the same problem were I work and I made a plan b were I scan every block and compare it against a template and look for centain key attributes but thats also is a lot of work and needs constant updating so there is no miracle cure for this problem , just hard work i'm afraid. Upside is , every time you update your list your routine gets more accurate.

 

 

gr. R.

Link to comment
Share on other sites

How about purging all drawings first, and then extract the name of blocks which have say 10+ attributes in them (considering the fact that usually titleblocks hold 10+ attribute definition). What do you reckon? :unsure:

Link to comment
Share on other sites

How about purging all drawings first, and then extract the name of blocks which have say 10+ attributes in them (considering the fact that usually titleblocks hold 10+ attribute definition). What do you reckon? :unsure:

 

 

Assuming certain attribute tagnames are always present , like 'revision' or 'drawing-number' you can loop trough all blocks and test if one or more attributes name are present. For me this alone does not always work because not all titleblocks have the same number of revision fields nor do they always have the same name. Only the drawing name field and main revision letter are almost always the same. So if you know just one attribute name that is always the same you would only have to look for that one.

Link to comment
Share on other sites

something 4U to play with :

 

 

; test (setq lst (RlxBlk_GetBlockList (vla-get-ActiveDocument (vlax-get-acad-object))))
(defun RlxBlk_GetBlockList ( $doc / fn O-Name B-Name A-Team B-Team)
 (if (vlax-property-available-p $doc 'Name) (setq fn (vla-get-name $doc)))
 ;(vlax-dump-object $doc)
 (vlax-for layout (vla-get-layouts $doc)
   (vlax-for object (vla-get-block layout)
     (setq O-Name (vla-get-objectname object))
     (cond
((and (eq O-Name "AcDbBlockReference")
      (not (assoc (setq B-Name (vla-get-effectivename object)) B-Team)))
 (if (eq (vla-get-hasattributes object) :vlax-true)
   (setq B-Team (append B-Team (list (cons B-Name (mapcar '(lambda (x) (vla-get-tagstring x))
         (vlax-invoke object 'getattributes))))))
   (setq B-Team (append B-Team (list (cons B-Name (list "No Attributes")))))))
((eq O-Name "AcDbAttributeDefinition")
 (setq A-Team (append A-Team (list (vla-get-tagstring object))))))))
 (if B-Team B-Team (if A-team (list (cons fn A-team)) nil))
)

it's part of a much larger routine I'm currently working on but it might be of some use. This will list all blocks with all tagnames for any document so it also works with an odbx document

 

 

gr.R

Link to comment
Share on other sites

something 4U to play with :

 

 

; test (setq lst (RlxBlk_GetBlockList (vla-get-ActiveDocument (vlax-get-acad-object))))
(defun RlxBlk_GetBlockList ( $doc / fn O-Name B-Name A-Team B-Team)
 (if (vlax-property-available-p $doc 'Name) (setq fn (vla-get-name $doc)))
 ;(vlax-dump-object $doc)
 (vlax-for layout (vla-get-layouts $doc)
   (vlax-for object (vla-get-block layout)
     (setq O-Name (vla-get-objectname object))
     (cond
((and (eq O-Name "AcDbBlockReference")
      (not (assoc (setq B-Name (vla-get-effectivename object)) B-Team)))
 (if (eq (vla-get-hasattributes object) :vlax-true)
   (setq B-Team (append B-Team (list (cons B-Name (mapcar '(lambda (x) (vla-get-tagstring x))
         (vlax-invoke object 'getattributes))))))
   (setq B-Team (append B-Team (list (cons B-Name (list "No Attributes")))))))
((eq O-Name "AcDbAttributeDefinition")
 (setq A-Team (append A-Team (list (vla-get-tagstring object))))))))
 (if B-Team B-Team (if A-team (list (cons fn A-team)) nil))
)

it's part of a much larger routine I'm currently working on but it might be of some use. This will list all blocks with all tagnames for any document so it also works with an odbx document

 

 

gr.R

 

Tnx for sharing.

I am thinking of modifying your code a little bit to write to *.TXT file and then apply that to the drawing package. Importing the final text file into something like Notepad++, I should be able to grab the list of drawings with titleblocks 8)

Link to comment
Share on other sites

Tnx for sharing.

I am thinking of modifying your code a little bit to write to *.TXT file and then apply that to the drawing package. Importing the final text file into something like Notepad++, I should be able to grab the list of drawings with titleblocks 8)

 

 

Youre welcome :-) you could, like you indicated earlier, first filter out all those blocks with less than 10 attributes , so you can keep your txt file as small as possible. Shouldn't be too difficult.

 

 

gr. Rlx

Link to comment
Share on other sites

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