+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Full Member
    Computer Details
    enemigoman's Computer Details
    Operating System:
    Windows 7 Pro SP1 64 bits
    Using
    AutoCAD 2013
    Join Date
    Apr 2006
    Location
    Bogota, Colombia
    Posts
    65

    Question Multiple block, attribute tag value change needed

    Registered forum members do not see this ad.

    Hello:

    In an ACAD 2007 drawing, I have one block with a single text-attribute line copied hundreds of times. It is a furniture tag, so that the same block is used to refer to all of the furniture in the drawing and the value of the tag is changed according to what is needed. Example: Chair is tagged as 101, Table is tagged as 201, etc.

    The problem is that the numbering format has changed and now chairs need to be tagged as 1101, Tables 2101, etc.

    So far, as superficially as I have searched this site, I have found scripts that modify the Tag. But that is not what I need.

    I can't qselect by block name because all blocks are the same. Neither can I select by Tag, because the tag is -and needs- to remain the same.

    What I need is a way to filter and select by the value of the attribute tag.

    Thanks in advance.

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,899

    Default

    Yeah easy done, your mixing 2 things in your question a block has tags which are a description and then you have an attribute which is a value. what you want is a lisp or vba that searches all common named blocks reads 1 attribute and adds the 1 to the value then updates the block etc

    Give this a try its in VBA found it good for block attribute handling just paste it into the vba editor its cut out of another program but should work.

    Code:
    Public Sub issued_for_construction()
    ' This Updates the Issued for construction and sets rev 0
     
    Dim SS As AcadSelectionSet
    Dim mynewans as string
    Dim Count As Integer
    Dim FilterDXFCode(1) As Integer
    Dim FilterDXFVal(1) As Variant
    Dim attribs As Variant
    Dim BLOCK_NAME As String
    On Error Resume Next
    FilterDXFCode(0) = 0
    FilterDXFVal(0) = "INSERT"
    FilterDXFCode(1) = 2
    FilterDXFVal(1) = "Your blockname"
    BLOCK_NAME = "Your blockname"
    Set SS = ThisDrawing.SelectionSets.Add("issued")
    SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal
    
    For Cntr = 0 To SS.Count - 1
       attribs = SS.Item(Cntr).GetAttributes
     myoldans = attribs(0)    ' attribs(0) is first attribute next attribute is attribs(1) and so on
    ' needs your code here
    ' also may need some form of test to check actual number returned so add correct 1000 2000 3000 etc  
    ' also again the attribute can be a number or a string      
    mynewans = "1" & myoldans     ' this should work as a test   
            attribs(0).TextString = mynewans
            
            attribs(0).Update
            
    Next Cntr
    ThisDrawing.SelectionSets.Item("issued").Delete
    
    MsgBox "Drawing blocks now changed to 1000 +"
    End Sub

  3. #3
    Full Member
    Computer Details
    enemigoman's Computer Details
    Operating System:
    Windows 7 Pro SP1 64 bits
    Using
    AutoCAD 2013
    Join Date
    Apr 2006
    Location
    Bogota, Colombia
    Posts
    65

    Default

    Hello Bigal:

    I should have have post this on the beginners forum.

    Sorry, but I don't know how to do this. I have never worked with VBA before.

    I've reached as far as the Visual Basic Editor, but I don't see where I can paste your script.

    Thanks, again

  4. #4
    Senior Member
    Computer Details
    Glen Smith's Computer Details
    Operating System:
    Win XP
    Computer:
    Dell Studio XPS 1645
    CPU:
    Intel i7 Q720 @ 1.6Ghz
    RAM:
    8 Gig
    Using
    Electrical 2010
    Join Date
    May 2008
    Location
    Cary, NC
    Posts
    418

    Default Express tools solution?

    Your post does not say what version you are using, hopefully you have express tools available. (You can install in from the full version install disks, I don't think it is available with LT.)

    Select all your blocks and click Express - Blocks - Export Attribute (or type attout on the command line) give it a file name and then open the text file in Excel. Change the attributes to the new value and save it as a text file. Go back to AutoCAD and click Express - Blocks - Import Attribute (or type attin at the command line). All your blocks now have updated values.

    Hope this helps.
    Glen

  5. #5
    Full Member
    Computer Details
    enemigoman's Computer Details
    Operating System:
    Windows 7 Pro SP1 64 bits
    Using
    AutoCAD 2013
    Join Date
    Apr 2006
    Location
    Bogota, Colombia
    Posts
    65

    Default

    Hello Glen:

    My apologies for not responding sooner.

    Your solution did work perfectly. Having the data all grouped in Excel allowed me to avoid wasting time looking for each tag (with a high probability of missing many), while allowing me to use Excel's find/replace tool.

    Many thanks

  6. #6
    Super Member Ryder76's Avatar
    Computer Details
    Ryder76's Computer Details
    Operating System:
    Windows 7
    Computer:
    Dell T7500
    Discipline
    See details...
    Ryder76's Discipline Details
    Occupation
    Electrical Designer - Oil & Gas
    Discipline
    See details below.
    Details
    Subsea Solutions
    Using
    AutoCAD 2010
    Join Date
    May 2009
    Location
    Houston, Texas
    Posts
    570

    Default

    Autocad has a find and replace as well...
    "Great spirits have always encountered violent opposition from mediocre minds." - Albert Einstein

  7. #7
    Forum Newbie
    Using
    AutoCAD 2009
    Join Date
    Jul 2014
    Posts
    1

    Default Hi Glen Smith

    I tried your way and its gr8 altough I have small issue :
    I export the block attributs and values I need to excel and did excatly what you wrote but when I go back to cad and try importing ( I need to write the file path) not the whole values are showing , some are missing like it didnt took them from the file ( cause in the text file they showen)
    any solution?
    Thanks and sorry for bringin this up from then

  8. #8
    Full Member
    Using
    AutoCAD 2013
    Join Date
    Jul 2014
    Location
    india
    Posts
    33

    Default

    try this may be useful..............this script selects only particular attributes in block...........load this command is "TT" it will select and keeps in previous selection then apply P and make changes..........I got this from cadtutor only.
    Code:
     
    ;__________________________________________________________
    (defun C:TT ()
    
      
       (RT1) 
    ;  (setq e1 (nentsel "\nSelect attribute to filter: "))
       (setvar "cmdecho" 0)
       (setq eget (entget (car e1))) 
       (setq EX_STR (cdr (assoc 1 EGET)))   ;EXISTING TEXTSTRING
       (setq ex_tag (cdr (assoc 2 EGET)))   ;EXISTING tag
    
      (SETQ PT1 (CADR E1))
      (SETQ SS0 (SSGET PT1))
      (SETQ BLKNAME (CDR (ASSOC 2 (ENTGET (SSNAME SS0 0)))))
     
      (prompt (strcat "\n Block: " blkname "   Attribute tag: " ex_tag "   >: " ex_str))
      
      
    ;______________ SELECTING BLOCKS "BLKNAME" _________________
    
      (SETQ LST1 (LIST '(0 . "INSERT") (CONS 2 BLKNAME)) )
      (SETQ SS1 (SSGET "X" LST1))
    ; (SETQ SS1 (SSGET LST1))
    ; (IF (NULL SS1) (SETQ SS1 (SSGET "X" LST1)) )
    
      (setq SSM (SSADD))
      (setq len1 (sslength ss1) n1 0 ssx (ssadd))
    
    
      (WHILE (< n1 len1) ;WHILE 1
        (setq ename1 (ssname ss1 n1) eget1 (entget ename1) CTRL1 nil COUNTER 0 str1 "") 
        (SETQ en1 ename1)
        ;____ Find Tag Level
        (while (and (null ctrl1) (/= (CDR (ASSOC 0 (ENTGET (setq en1 (ENTNEXT en1))))) "SEQEND"))
               (setq tag1 (CDR (ASSOC 2 (ENTGET en1))))
               (if (= tag1 ex_tag) (setq str1 (CDR (ASSOC 1 (ENTGET en1))) ctrl1 T))
               (setq counter (1+ counter))
        ) ;end while2
        ;_____
     
        ;(if (= str1 ex_str) (princ str1))
        (if (= (STRCASE str1) (STRCASE ex_str)) (setq ssx (ssadd ename1 ssx)))
        (setq n1 (1+ n1))
      ) ; end WHILE1
                  
    
      (setq lenx (sslength ssx))  
      (command "select" ssx "") 
      (PROMPT (strcat "\n Match found : [" (itoa lenx) "].   Selected objects are stored in Previous Selection."))
      (setvar "cmdecho" 1) 
      (princ)
    )
    ;_____________________________________________________________
    
    (prompt "\n Start command with  - by Raymond Rizkallah -  April 06. ")
    (PRINC)
    http://www.xtracad.com/forum/index.php?topic=8458.0
    Last edited by SLW210; 28th Jul 2014 at 01:29 pm. Reason: Code Tags

  9. #9
    Full Member
    Computer Details
    jarr3tt88's Computer Details
    RAM:
    8GB
    Graphics:
    NVIDIA Quadro K600
    Discipline
    Architectural
    jarr3tt88's Discipline Details
    Occupation
    Draftsman
    Discipline
    Architectural
    Details
    New high end residential, townhouses, and commercial buildings
    Using
    AutoCAD LT 2014
    Join Date
    Nov 2013
    Location
    Long Island
    Posts
    86

    Default

    What about using the Select similar command (which will select all blocks that are the same). Then go into the properties panel and you should be able to change the attributes there, all in one shot.

  10. #10
    Luminous Being RobDraw's Avatar
    Using
    MEP 2017
    Join Date
    Apr 2007
    Location
    Connecticut, USA
    Posts
    5,169

    Default

    Registered forum members do not see this ad.

    Psst, see the OP:

    Quote Originally Posted by enemigoman View Post
    I can't qselect by block name because all blocks are the same.
    Drafting is a breeze.

Similar Threads

  1. Replies: 40
    Last Post: 19th Aug 2016, 02:11 am
  2. Multiple Attribute change
    By Bennymac777 in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 41
    Last Post: 26th Oct 2009, 10:12 pm
  3. Attribute/Block Help Needed
    By muddbutter in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 7th Aug 2008, 06:07 pm
  4. Block Attribute answers ability to change block Physical Attributes??
    By Kaidoz in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 19th Mar 2008, 10:25 pm
  5. Multiple block attribute change
    By enemigoman in forum AutoCAD General
    Replies: 2
    Last Post: 7th Oct 2007, 01:48 pm

Bookmarks

Posting Permissions

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