Jump to content

Recommended Posts

Posted

Hi I would like to find a certain tag value of a block in paper space. The tag's name is always the same - in this case 'REV' but the blocks (title block) names can vary. Generally there is only one attributed block in paper space. (ie the title block).

I have had a look for something that might work but I can't find something suitable for what I want.

To sum up :

1) find attributed block that has a tag called 'REV' in paperspace

2) Find the value of the tag called 'REV'

 

thanks for your help

Posted

Hi

 

An example

 

(defun c:test(/ att bl sel)
 (vl-load-com)
 (and (ssget "x" (list (cons 0 "insert") (cons 66 1) (cons 67 1)))
   (progn
     (vlax-for bl (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
   (foreach att (vlax-invoke bl 'getattributes)
     (and (eq (vla-get-tagstring att) "REV")
       (princ (strcat "\nBlock name " (vla-get-name bl) " with value " (vla-get-textstring att)))
     )
   )
     )
     (vla-delete sel)
   )
 )
 (princ)
)

@+

Posted

thanks a million Patrick - that's perfect! :D

Posted

I have taken it one step further by trying to find the revision letters in all the tabs.

I can not make the list not sure what mistake(s) I am making.

Can any point out what's wrong?

thanks

btw "dos_multilist" is a dos_lib function.

 

(defun c:RevLetter (/ layout_list RevLetterList RevLetter att bl sel LLN)
(setq layout_list (dos_multilist "Find revision letters" "Select tabs" (ListLayouts)))
(foreach LLN layout_list
   (ListLayouts)
(setvar "CTAB" LLN)
(and (ssget "x" (list (cons 0 "insert") (cons 66 1) (cons 67 1)))
   (progn
    (vlax-for bl (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
   (foreach att (vlax-invoke bl 'getattributes)
   (and (eq (vla-get-tagstring att) "REV")
  (setq RevLetter (vla-get-textstring att))
    )
    );foreach
     )
     (vla-delete sel)
   )
 );and
 (setq RevLetterList (append (list RevLetter)));make a list of rev letters
 );foreach
 (princ)
 );defun

(defun ListLayouts(/ oApp oDoc colLayouts LayList LayListSorted LayListWModel LayListinOrder)
     (setq oApp (vlax-get-acad-object))
     (setq oDoc (vla-get-activedocument oApp))
     (setq colLayouts (vla-get-layouts oDoc))
     (setq LayList nil)
     (vlax-for oLayout colLayouts
     (setq LayList (append Laylist (list (cons (vla-get-taborder oLayout) (vla-get-name oLayout)))))
     )
     (setq LayListSorted (vl-sort LayList '(lambda (x y) (< (car x) (car y)))))
     (vlax-release-object colLayouts)
     (vlax-release-object oDoc)
     (vlax-release-object oApp)
     (setq LayListWModel (mapcar '(lambda (x) (cdr x)) LayListSorted));Layout list with model tab
     (setq LayListinOrder (cdr LayListWModel));Layout list without model tab
     LayListinOrder
     )

Posted

Hi

 

Try this

 

(defun c:RevLetter (/ layout_list RevLetterList RevLetter att bl sel LLN str)
 (setq layout_list (dos_multilist "Find revision letters" "Select tabs" (ListLayouts)))
 (foreach LLN layout_list
   (if str
     (setq str (strcat str "," LLN))
     (setq str LLN)
   )
 )
; (ListLayouts)
;(setvar "CTAB" LLN)
;(and (ssget "x" (list (cons 0 "insert") (cons 66 1) (cons 67 1)))
 (and (ssget "x" (list (cons 0 "insert") (cons 66 1) (cons 410 str)))
   (progn
     (vlax-for bl (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
       (foreach att (vlax-invoke bl 'getattributes)
         (and (eq (vla-get-tagstring att) "REV")
           (setq RevLetterList (cons (vla-get-textstring att) RevLetterList))
;           (setq RevLetter (vla-get-textstring att))
         )
       );foreach
     )
     (vla-delete sel)
   )
 );and
;  (setq RevLetterList (append (list RevLetter)));make a list of rev letters
  (setq RevLetterList (reverse RevLetterList))
;  );foreach
 (princ)
);defun

(defun ListLayouts(/ oApp oDoc colLayouts LayList LayListSorted LayListWModel LayListinOrder)
     (setq oApp (vlax-get-acad-object))
     (setq oDoc (vla-get-activedocument oApp))
     (setq colLayouts (vla-get-layouts oDoc))
     (setq LayList nil)
     (vlax-for oLayout colLayouts
     (setq LayList (append Laylist (list (cons (vla-get-taborder oLayout) (vla-get-name oLayout)))))
     )
     (setq LayListSorted (vl-sort LayList '(lambda (x y) (< (car x) (car y)))))
     (vlax-release-object colLayouts)
     (vlax-release-object oDoc)
     (vlax-release-object oApp)
     (setq LayListWModel (mapcar '(lambda (x) (cdr x)) LayListSorted));Layout list with model tab
     (setq LayListinOrder (cdr LayListWModel));Layout list without model tab
     LayListinOrder
     )

My list of layouts in order

(defun ListLayouts(/ lay liste_lay lst n)
 (vlax-for lay (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
   (setq lst (cons (cons (vla-get-taborder lay) lay) lst))
 )
 (setq n 1)
 (while (assoc n lst)
   (setq liste_lay (cons (vla-get-name (cdr (assoc n lst))) liste_lay)
         n (1+ n)
   )
 )
 (reverse liste_lay)
)

@+

Posted

mercey! Patrick that works great!

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