Results 1 to 4 of 4

Thread: Update Attribute text, basically flip the order of two values

  1. #1
    I could stop if I wanted to
    Join Date
    2003-09
    Posts
    381

    Default Update Attribute text, basically flip the order of two values

    Hello AUGI Members,

    I have a condition that exists in numerous locations on many drawings that needs to be corrected and I am looking for some possible assistance with this task.

    We have a block (Open-tag.dwg) that has one attribute tag (open-size). This tag is placed next to all slab openings on a drawing and displays the size of the opening such as 12x9, 18x12, 24x18, etc. The first number is the height of the opening and the second number is the width of the opening. The project manager wants to change the order of the opening sizes so that the first number would be the width and the second number would be the height such as 9x12, 12x18, 18x24, etc.

    Is there a way to automate this process (at least one one drawing at a time) via a lisp routine....??

    Any assistance would be appreciated....!

    Regards,
    Vince

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,706

    Default Re: Update Attribute text, basically flip the order of two values

    Hi Vince !

    This code flip the attribute text in the tag named "open-size" in all block named "Open-tag" automatically
    from "AAAAxBBB" to "BBBxAAAA". Run the code again to change the text back.
    If you want to select your block manually, look in the code, oterwhise all legal blocks are treated.
    Code:
    (defun c:FlipOpen-Size ( / Item SelSet BlName AttName EntDxf AttTxt xpos NewTxt )
      (setq Item 0 ) ;; Remove the "_X" at next line if you want to select your block manually
      (if (setq SelSet (ssget "_X" (list (cons 0 "INSERT") (cons 2 "Open-tag" ))) ) ; <-- Your block name
        (while (setq BlName (ssname SelSet Item ) )
          (setq AttName (entnext BlName ) )
          (while AttName
            (if (equal (assoc 0 (entget AttName )) '(0 . "SEQEND"))
              (setq AttName nil )
              (if (= (cdr (assoc 2 (entget AttName ))) (strcase "open-size" nil ) ) ; <-- Your Attribute name
                (progn
                  (setq EntDxf (entget AttName ) )
                  (setq AttTxt (cdr (assoc 1 (entget AttName ))) )
                  (setq xpos (vl-string-position (ascii "x") AttTxt ) )
                  (setq NewTxt (strcat (substr AttTxt (+ xpos 2 ) ) "x" (substr AttTxt 1 xpos )) )
                  (setq EntDxf (subst (cons 1 NewTxt ) (assoc 1 (entget AttName )) EntDxf ) )
                  (entmod EntDxf )
                  (entupd BlName )
                  (setq AttName (entnext AttName ))
                )
                (setq AttName (entnext AttName ))
              )
            )
          )
          (setq Item (1+ Item ) )
        )
        (princ "no matching block in drawing" )
      )
      (princ)
    )
    : ) Happy Computing !

    kennet

  3. #3
    I could stop if I wanted to
    Join Date
    2003-09
    Posts
    381

    Default Re: Update Attribute text, basically flip the order of two values

    Kennet,

    Thank you very much for your quick and excellent response to my post. Your code did exactly what I needed to accomplish and is very easy to utilize.

    Thanks again....!

    Regards,
    Vince

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,706

    Default Re: Update Attribute text, basically flip the order of two values

    Quote Originally Posted by vferrara
    Kennet,

    Thank you very much for your quick and excellent response to my post. Your code did exactly what I needed to accomplish and is very easy to utilize.

    Thanks again....!

    Regards,
    Vince
    Well I am just glad to help,


    : ) Happy Computing !

    kennet

    BTW
    thanks for the rep...

Similar Threads

  1. 2010: Enter attribute values by selecting text object
    By luuk_siemelink339880 in forum AutoCAD General
    Replies: 2
    Last Post: 2011-10-04, 02:52 PM
  2. Replies: 5
    Last Post: 2007-07-03, 02:52 PM
  3. Update Dimension text so it reads correctly ie Flip it
    By rustific in forum AutoCAD General
    Replies: 1
    Last Post: 2007-02-14, 01:53 PM
  4. Flip Text / Attribute Text in Visibility Mode
    By econlon in forum Dynamic Blocks - Technical
    Replies: 36
    Last Post: 2007-01-18, 05:15 PM
  5. Replies: 5
    Last Post: 2006-08-11, 01:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •