Attributes upper and lower case lisp modification

Attributes upper and lower case lisp modification

Anonymous
Not applicable
1,969 Views
4 Replies
Message 1 of 5

Attributes upper and lower case lisp modification

Anonymous
Not applicable

Dear Helpers,

I got a lisp code that will update all attributes of single selected block to uppercase. But the lisp code I need is, it should update only single attribute to upper or lowercase for selected block. The code I have is below. It should work for multiple blocks.

(defun c:AUC ( / ent enx )

   (if (and (setq ent (car (entsel)))

            (= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))

            (= 1 (cdr (assoc 66 enx)))

            (setq ent (entnext ent)

                  enx (entget  ent)

            )

       )

       (while (= "ATTRIB" (cdr (assoc 0 enx)))

           (entmod (subst (cons 1 (strcase (cdr (assoc 1 enx)))) (assoc 1 enx) enx))

           (setq ent (entnext ent)

                 enx (entget  ent)

           )

       )

       (princ "\nNo object selected or selected object is not a block.")

   )

   (princ)

)

Thanks,

T.Brahmanandam

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

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

Do you asking for this.......

 

(defun c:AUC ( / ent enx )
(if (and (setq ent (car (entsel)))
(= "INSERT" (cdr (assoc 0 (setq enx (entget ent)))))
(= 1 (cdr (assoc 66 enx)))
(setq ent (entnext ent)
enx (entget ent)
)
)
(while (= "ATTRIB" (cdr (assoc 0 enx)))
(setq Att_Val (cdr (assoc 1 enx)))
(setq Ans (getstring (strcat "Do you want to Change tha Attribute value (" Att_Val ") to Upper? (Y/N): ")))
(if (or (= Ans "Y") (= Ans "y"))
(entmod (subst (cons 1 (strcase (cdr (assoc 1 enx)))) (assoc 1 enx) enx))
)
(setq ent (entnext ent)
enx (entget ent)
)
)
(princ "\nNo object selected or selected object is not a block.")
)
(princ)
)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
Message 3 of 5

Anonymous
Not applicable

Thank you Sir for reply.

0 Likes
Message 4 of 5

pbejse
Mentor
Mentor

Are you wanting to select an attribute string, change the selected item to upper/lower case then apply to all blocks with the same Block name and Attribute Tag?

 

Message 5 of 5

pbejse
Mentor
Mentor
Accepted solution

[ Took out "ACCEPTED AS SOLUTION" flag ]

 

I'm confused, the previous post is definitely NOT a solution but a query regarding the intended result tnvsb. 😄

[ I'm referring to MY post guys ]

 

I was thinking of an entirely different outcome.

 

(defun c:demo ( / mode att_str)
  (initget "L U")
  (if (null
        (setq
          mode (getkword "\nChoose option [Lowercase/Uppercase] <U>: ")
        )
      )
    (setq mode "U")
  )

  (if
    (and
      (setq att_str (car (nentsel "\nSelect Attribute")))
      (eq "ATTRIB" (cdr (assoc 0 (entget att_str))))
    )
     (vla-put-textstring
       (Setq att_str (vlax-ename->vla-object att_str))
       (strcase (vla-get-textstring att_str)
                (if (eq mode "L") T
                )
       )
     )
  )
  (princ)
)

AND/OR  apply the same to the rest of the blocks on the drawing. [ Not included ]