handling duplicate attributes in block

handling duplicate attributes in block

Patrick.De.Neef
Advocate Advocate
674 Views
4 Replies
Message 1 of 5

handling duplicate attributes in block

Patrick.De.Neef
Advocate
Advocate

Hello all

I "inherited a large number of autocad drawings where the title blocks have a lot of duplicate attributes (see block_attributes.png in zip file)

I thought I could get around the problem (replacing/renaming the duplicates) by using also the prompt which (for some reason) is unique but trying to extract also the tag name and the value results in returning the same twice for the duplicates or giving double output

I based all my attempts on two lsp files I found (one from Lee Mac and another from Kevin, thank you both)

I included the original lsp's and the output in the zip file

Hope someone here can help me out

 

Thanks & Regards

Patrick

 

0 Likes
Accepted solutions (1)
675 Views
4 Replies
Replies (4)
Message 2 of 5

marko_ribar
Advisor
Advisor

See if this post can help you...

 

http://www.theswamp.org/index.php?topic=55172.msg594767#msg594767 

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant

Not sure what your goal is, but this lists all atts/attd 

def-prompt def-tag ref-tag ref-value

 

(defun c:ListAtts (/ er ed d rl dl )

  (if (and (setq er (car (entsel "Select a block: ")))
	   (setq ed (tblobjname "BLOCK" (cdr (assoc 2 (entget er))))))
    (progn
      (while (setq ed (entnext ed))
	(if (= "ATTDEF" (cdr (assoc 0 (setq d (entget ed)))))
	  (setq dl (cons (list (cdr (assoc 3 d)) (cdr (assoc 2 d))) dl))))
      (while (and (setq er (entnext er))
		  (= "ATTRIB" (cdr (assoc 0 (setq d (entget er))))))
	(setq rl (cons (list (cdr (assoc 2 d)) (cdr (assoc 1 d))) rl)))))
  (foreach l (reverse (mapcar 'append dl rl))
    (princ "\n") (print l))
  (princ)
  )

 

Message 4 of 5

pbejse
Mentor
Mentor
Accepted solution

Replace this from GetAttributeTagPromptValue function [ at test_leemac.lsp ]

(mapcar
    (function
      (lambda ( attrib )
        (append (assoc (vla-get-TagString attrib) lst) (list (vla-get-TextString attrib)))
      )
    )
    (vlax-invoke block 'GetAttributes)
  )

With this

(mapcar
    (function
      (lambda ( attrib values)
       (list (cAR attrib)(cadr attrib)(Vla-get-textstring values))
      )
    )
    (reverse lst)(vlax-invoke block 'GetAttributes))

  

HTH

 

Message 5 of 5

Patrick.De.Neef
Advocate
Advocate

Hello pbejse

 

Thank You Very Much !!!

Awsome, this is exactly what I need, you saved me hours of work

 

Best Regards

Patrick

0 Likes