See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Updating Blocks with Attributes, use old Attribute values in newly inserted

  1. #1
    Active Member rcrabb's Avatar
    Join Date
    2007-02
    Posts
    99
    Login to Give a bone
    0

    Default Updating Blocks with Attributes, use old Attribute values in newly inserted

    Okay, here is an attached file.

    If you open it, double click the block, you can change the attributes.
    If I insert this drawing as a block, I lose the attributes, unless I insert the block and click "Explode" in the bottom left hand corner ...

    so if I am running a batch program to replace old blocks with this new block, and desire to pull the old attributes out of the replaced block and insert them into this new block, how would i go about inserting the new block so i can insert the attributes from the variant array which has the old values stored?

    i have everything figured out, except for how to insert this block and still be able to have the attribute definitions available to insert the attributes

    make sense? i hope so, haha, i can post my entire code if needed, but i just want to know how to insert this block, if possible

    thanks in advance
    Attached Files Attached Files
    Last edited by rcrabb; 2007-05-07 at 01:06 PM.

  2. #2
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    Use WBlock command inside the above drawing to save a block defenition of "MI Title Block". Then insert that block defenition wherever required using the VBA block insertion code. Now all the attributes will be available. I have attached the block defenition created using the WBlock command.
    Attached Files Attached Files
    har!s
    CADing && Coding
    AuotCAD 2010 on Windows XP Professional (SP3)

  3. #3
    Active Member rcrabb's Avatar
    Join Date
    2007-02
    Posts
    99
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    zh - thanks for your help, again ... i looked up the wblock command, so i'll know when to use it in the future ...

    anyone want another challenge?

    here is some "meat" from my batch program

    Code:
       Set CurSet = ThisDrawing.SelectionSets.Add("CutSelSet")
    
       SelCode(0) = 8: SelCode(1) = 0: SelCode(2) = 2
       SelValue(0) = "0"
       SelValue(1) = "INSERT"
       SelValue(2) = "BB*"
       CurSet.Select acSelectionSetAll, , , SelCode, SelValue
    
    For Each objBlockRef In CurSet
    
       pt1(0) = objBlockRef.InsertionPoint(0)
       pt1(1) = objBlockRef.InsertionPoint(1)
       pt1(2) = objBlockRef.InsertionPoint(2)
       scX = objBlockRef.XScaleFactor
       scY = objBlockRef.YScaleFactor
       scZ = objBlockRef.ZScaleFactor
       RotAng = objBlockRef.Rotation
       
        strBlock = "U:\MI Title Block.dwg"
    
       Set objNewBlock = ThisDrawing.ModelSpace.InsertBlock(pt1, _
                         strBlock, scX, scY, scZ, RotAng)
               
    
        varAttributes = objBlockRef.GetAttributes
        varNewAttributes = objNewBlock.GetAttributes
    
        For I = LBound(varAttributes) To UBound(varAttributes)
           Select Case varAttributes(I).TagString
            Case "JAMB"
               strJamb = varAttributes(I).TextString
            Case "FLANGE"
               strFlange = varAttributes(I).TextString
            Case "SERIES"
               strSeries = varAttributes(I).TextString
            Case "CUSTOMER"
               strCustomer = varAttributes(I).TextString
            Case "PO#"
               strPO = varAttributes(I).TextString
            Case "ATTN"
               strAttn = varAttributes(I).TextString
            End Select
        Next
        
        For I = LBound(varNewAttributes) To UBound(varNewAttributes)
           Select Case varNewAttributes(I).TagString
            Case "SERIES"
               varNewAttributes(I).TextString = strSeries & " " & strFlange & " " & strJamb
            Case "CUSTOMER"
               varNewAttributes(I).TextString = strCustomer
            Case "PO#"
               varNewAttributes(I).TextString = strPO
            Case "ATTN"
               varNewAttributes(I).TextString = strAttn
            End Select
        Next
    
       Next
       
       CurSet.Erase
       CurSet.Delete
    it works great, however, it isn't changing some of the titleblocks even though the names match the "BB*" criteria ... attached is a drawing that was "ignored" for lack of a better term by my batch program - if anyone has ideas at why this is happening and how to make this file "included" with the batch changes, i would greatly appreciate it!!
    Attached Files Attached Files
    Last edited by rcrabb; 2007-05-07 at 01:08 PM.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,745
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    You said "the drawing" was ignored. Perhaps its your code to select the "drawing" and has nothing to do with editing blocks?
    C:> ED WORKING....

  5. #5
    Active Member rcrabb's Avatar
    Join Date
    2007-02
    Posts
    99
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    no, i've been using this same batch program for quite awhile, its always worked great, the term "the drawing" was the wrong one for me to use ... "the titleblock" is ignored.

    looking at the code and the attached drawings, any ideas?

  6. #6
    All AUGI, all the time zoomharis's Avatar
    Join Date
    2005-02
    Location
    Abu Dhabi (Native-India)
    Posts
    506
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    Where exactly you are facing the problem? Is the selection set is returned empty or the problem is only with attribute value changing?
    har!s
    CADing && Coding
    AuotCAD 2010 on Windows XP Professional (SP3)

  7. #7
    Active Member rcrabb's Avatar
    Join Date
    2007-02
    Posts
    99
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    Quote Originally Posted by zoomharis
    Where exactly you are facing the problem? Is the selection set is returned empty or the problem is only with attribute value changing?
    zoom to the rescue!! haha

    selection set is returned empty some of the time. in some files, with BB* titleblocks, it recognizes the titleblocks and changes them, in other files (such as the two attached), the selection set BB* is returned empty, even though it has BB* titleblocks

    make sense? :/

  8. #8
    I could stop if I wanted to
    Join Date
    2015-08
    Posts
    263
    Login to Give a bone
    1

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    Quote Originally Posted by rcrabb
    in other files (such as the two attached), the selection set BB* is returned empty, even though it has BB* titleblocks
    make sense? :/
    Hi,

    I think it is because your title blocks are not always in layer "0". Remove the layer filter for the selection set and try.
    Code:
       Set CurSet = ThisDrawing.SelectionSets.Add("CutSelSet")
    
       SelCode(0) = 0: SelCode(1) = 2
       SelValue(0) =  "INSERT"
       SelValue(1) =   "BB*"
       CurSet.Select acSelectionSetAll, , , SelCode, SelValue
    Regards,
    AH

  9. #9
    Active Member rcrabb's Avatar
    Join Date
    2007-02
    Posts
    99
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    WOW - what dumbness on my part! i can't believe i didn't see those titleblocks were on a "FRAME" layer ... many thanks abdul huck!

  10. #10
    I could stop if I wanted to
    Join Date
    2015-08
    Posts
    263
    Login to Give a bone
    0

    Default Re: Updating Blocks with Attributes, use old Attribute values in newly inserted

    Glad to know it helped

    Regards
    AH

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 2007-06-07, 03:58 PM
  2. Attribute Editor does not appear for Blocks inserted from Tool Palette
    By Neo_Richard_Blake in forum AutoCAD General
    Replies: 3
    Last Post: 2007-02-22, 06:18 AM
  3. Replies: 2
    Last Post: 2006-10-23, 05:31 PM
  4. Replies: 4
    Last Post: 2006-02-10, 04:14 PM
  5. Updating attributes in blocks
    By 3D Jack in forum AutoLISP
    Replies: 15
    Last Post: 2005-08-31, 12:14 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
  •