Set unique attributes values to variables

Set unique attributes values to variables

djurk_haas
Advocate Advocate
2,301 Views
22 Replies
Message 1 of 23

Set unique attributes values to variables

djurk_haas
Advocate
Advocate

Hello,

 

The code belows works fine and prompts a list eg:

1 6504
1 6504
1 6512
1 5628
1 5219
1 6512
1 6512
1 6504

 

Can anyone help me to modify the code so that only the unique attributes values are stored into variables?

From the list above the adjusted code must store only the unique attributesvalues into serveral variables:

 

(setq kostenplaats01 "6504")

(setq kostenplaats02 "6512")

(setq kostenplaats03 "5628")

(setq kostenplaats04 "5219")

 

(defun C:FSDA (/ blkss ent foundit att comment); = block FSD's Attributes
  (vl-load-com)
  (if (setq blkss (setq ss  (ssget "_X" '((0 . "insert")(66 . 1)(2 . "`*U*,FM_RM3")))))
    (progn ; then
      (prompt "\nComments:")
      (repeat (sslength blkss)
        (setq
          ent (ssname blkss 0)
          n 0
        ); setq
        (while
          (and
            (not foundit)
            (setq ent (entnext ent))
            (= (cdr (assoc 0 (entget ent))) "ATTRIB")
          ); end and
          (setq att (vlax-ename->vla-object ent))
          (if (= (vla-get-TagString att) "KOSTENPLAATS")
            (progn
              (setq
                foundit T
                comment (vla-get-TextString att); value [= "" if none specified]
              )
              (prompt
                (strcat
                  "\n" ; new line
                  (itoa (setq n (1+ n))); step integer upward and convert to text
                  " " ; space separator
                  (if (= comment "") "NO COMMENT SPECIFIED" comment)
                ); strcat
              );prompt
            ); progn
          ); if
        ); while
        (setq foundit nil)
        (ssdel (ssname blkss 0) blkss)
      ); repeat
    ); progn
  ); if
  (princ)
); defun

 

Thanks

0 Likes
Accepted solutions (2)
2,302 Views
22 Replies
  • Lisp
Replies (22)
Message 21 of 23

dlanorh
Advisor
Advisor

OK, do you want it blanked or deleted?

 

I am not one of the robots you're looking for

0 Likes
Message 22 of 23

dlanorh
Advisor
Advisor

Ignore my last question, a rushed reply. Try the attached. I think this is what you want. Briefly tested only.

 

I am not one of the robots you're looking for

0 Likes
Message 23 of 23

dlanorh
Advisor
Advisor

@djurk_haas wrote:

Hi Dlanor,


It works almost perfectly.

However, if a drawing now changes and there are less "KOSTENPLAATS" then the current data will not be deleted and a duplication will occur.
I think it can be "easily" solved by making sure that at the beginning of the code all existing tag values ​​(KOSTENPLAATS) are deleted (start from scratch).

 

To make it completely awesome it would be great if the tags "BEDRIJFSORGAAN, RUIMTEFUNCTIE and RUIMTESOORT were filled with values ​​as set in the lisp in the attachment.

 

Greetings


OK. Attached is the updated lisp. This Fills in the "KOSTENPLATTS" tag as well as the "BEDRIJFSORGAAN" , "RUIMTEFUNCTIE" and "RUIMTESOORT" tags, and also clears any previous "KOSTENPLAATS" tags that are no longer needed.

 

I am not one of the robots you're looking for

0 Likes