Results 1 to 7 of 7

Thread: Inserting Blocks with Block Properties Set

  1. #1
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Inserting Blocks with Block Properties Set

    The title is misleading, as I don't know how to word it. I am modifying about 300,000 drawings my company has, changing the titleblocks (and other stuff) from their older designs to a newer one. Now, I've done this before, but the inserted blocks were simpler. The new blocks I've made have nice descriptions, exploding is disallowed, scale is locked to uniform, and the design is much better.

    So, previously, I would do this:
    Code:
    (command -INSERT "TITLEBLOCK=\\SERVER\\BLOCKS\\TITLEBLOCK.dwg" inspoint scalex scaley angle ....)
    ... to redefine a block called TITLEBLOCK, because the block was in the .dwg file "exploded" (no block, and attribute tags visible), so when they got inserted, they redefined the block.

    NOW, I'd like for the blocks to be inserted as my new versions, which doesn't work the same. I currently have drawings called (e.g.) "BLOCK_TITLEBLOCK.dwg" that, in itself, has a block called TITLEBLOCK. But, if I issue this command:
    Code:
    (command "-insert" "*\\SERVER\\BLOCKS\\BLOCK_TITLEBLOCK.dwg" inspoint scalex angle ....)
    ... AutoCAD says "duplicate definition, ignoring", and my block stays the same as the inserted block.

    I tried renaming the file to TITLEBLOCK.dwg, with a block inside called TITLEBLOCK, and simply redefining the block, but that gives me a "block references itself" issue.

    How can I redefine an existing attributed block with a new attributed block (same name, same tags), while maintaining all of the defined block properties. The "*" to explode convention, and the "BLOCKNAME=FILENAME" convention cannot be used together.

    I found a goofy workaround of searching whether a block exists, then inserting my block that I've renamed to something else (e.g. I've inserted it as "TITLEBLOCK-GOOD"), then using the BLOCKREPLACE command to replace "TITLEBLOCK" with "TITLEBLOCK-GOOD", deleting my inserted block, and renaming "TITLEBLOCK-GOOD" to "TITLEBLOCK", then move it to the proper location.
    Last edited by ettore_c; 2019-11-15 at 05:23 PM.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    -INSERT (Command) http://help.autodesk.com/view/ACD/20...9-7C565CD1B639
    Updating a Block Definition: If you make changes to a block file that is inserted in your drawing and you want to change the existing block definition without creating a new block insertion, enter the following at the Insertion Point prompt (following the Block Name prompt):
    block name=

    If you enter = after the block name, the following prompt is displayed:

    Block "current" already exists. Redefine it?
    Specify Yes or No.
    If you choose to redefine the block, the existing block definition is replaced with the new block definition. The drawing is regenerated, and the new definition is applied to all existing insertions of the block definition. Press Esc when prompted for the insertion point if you do not want to insert a new block into the drawing.

    Using "=" should do the trick. Code below is an example that updates a block picked in the drawing. Automatic if it's in the path otherwise Select File dialog opens.

    Code:
    ;;; BlkUpdate.LSP   Update block by pick.
    ;;; Redo insert from updated drawing file.
    ;;; BY: TOM BEAUFORD
    ;;; BeaufordT@leoncountyfl.gov
    ;;; LEON COUNTY PUBLIC WORKS ENGINEERING SECTION
    ;==================================================================
    (defun C:BlkUpd (/ oldcmd ss elist blkname ffname str1)
      (setq oldcmd (getvar "CMDECHO"))
      (setvar "CMDECHO" 0)
      (setq ss (ssget "+.:E:S" '((0 . "INSERT")))
                elist (entget(ssname SS 0))
      )
      (if (= (cdr (assoc 0 elist)) "INSERT")
        (progn
          (setq blkname (cdr(assoc 2 elist)))
          (setq ffname (findfile (strcat blkname ".dwg")))
          (if ffname
            (progn
              (princ (strcat "\nReplace with=" ffname))
              (setq str1 (getstring " <Yes>"))
            );_ end of progn
          );_ end of if
          (if str1
            (if (= "N" (strcase (substr str1 1 1)))
                (setq str1 nil)
            )
          )
          (if str1
            (progn
              (command "INSERT" (strcat blkname "=" ffname)(command))
              (princ (strcat "\n" blkname " Reinserted."))
            );_ end of progn
            (progn
              (princ (strcat "\nSelect " blkname " file to reinsert."))
              (command "INSERT" (strcat blkname "=~")(command))
            );_ end of progn
          );_ end of if
        );_ end of progn
        (princ "\nObject is not a block!")
      );_ end of if
      (setvar "CMDECHO" oldcmd)
      (princ)
    ) ;_ end of defun

  3. #3
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    Quote Originally Posted by Tom Beauford View Post
    -INSERT (Command) http://help.autodesk.com/view/ACD/20...9-7C565CD1B639
    Updating a Block Definition: If you make changes to a block file that is inserted in your drawing and you want to change the existing block definition without creating a new block insertion, enter the following at the Insertion Point prompt (following the Block Name prompt):
    block name=

    If you enter = after the block name, the following prompt is displayed:

    Block "current" already exists. Redefine it?
    Specify Yes or No.
    If you choose to redefine the block, the existing block definition is replaced with the new block definition. The drawing is regenerated, and the new definition is applied to all existing insertions of the block definition. Press Esc when prompted for the insertion point if you do not want to insert a new block into the drawing.

    Using "=" should do the trick. Code below is an example that updates a block picked in the drawing. Automatic if it's in the path otherwise Select File dialog opens.

    Code:
    ;;; BlkUpdate.LSP   Update block by pick.
    ;;; Redo insert from updated drawing file.
    ;;; BY: TOM BEAUFORD
    ;;; BeaufordT@leoncountyfl.gov
    ;;; LEON COUNTY PUBLIC WORKS ENGINEERING SECTION
    ;==================================================================
    (defun C:BlkUpd (/ oldcmd ss elist blkname ffname str1)
      (setq oldcmd (getvar "CMDECHO"))
      (setvar "CMDECHO" 0)
      (setq ss (ssget "+.:E:S" '((0 . "INSERT")))
                elist (entget(ssname SS 0))
      )
      (if (= (cdr (assoc 0 elist)) "INSERT")
        (progn
          (setq blkname (cdr(assoc 2 elist)))
          (setq ffname (findfile (strcat blkname ".dwg")))
          (if ffname
            (progn
              (princ (strcat "\nReplace with=" ffname))
              (setq str1 (getstring " <Yes>"))
            );_ end of progn
          );_ end of if
          (if str1
            (if (= "N" (strcase (substr str1 1 1)))
                (setq str1 nil)
            )
          )
          (if str1
            (progn
              (command "INSERT" (strcat blkname "=" ffname)(command))
              (princ (strcat "\n" blkname " Reinserted."))
            );_ end of progn
            (progn
              (princ (strcat "\nSelect " blkname " file to reinsert."))
              (command "INSERT" (strcat blkname "=~")(command))
            );_ end of progn
          );_ end of if
        );_ end of progn
        (princ "\nObject is not a block!")
      );_ end of if
      (setvar "CMDECHO" oldcmd)
      (princ)
    ) ;_ end of defun
    So, that doesn't work.

    A drawing has a block called "TITLEBLOCK" in it.
    I have a .DWG file called "TEST.dwg" with a block inside called "TITLEBLOCK" (this is the new block).

    When I do this:
    (COMMAND "-INSERT" "TITLEBLOCK=B:\\Blocks\\TEST.dwg" "0,0" "2" "0")

    ... I get the error "block references itself".

    If I name the drawing TITLEBLOCK.dwg, then use the TITLEBLOCK=B:\\Blocks\\TITLEBLOCK.dwg way, it asks if i want to redefine it. If I say yes, it says "BLOCK REFERENCES ITSELF" because there's a block within TITLEBLOCK.dwg that is, itself, called TITLEBLOCK.

    Again, the goal is to redefine the existing block, but my new block has a lot of attributes that I want kept. Alternate is being able to set those attributes afterwards, but I'd prefer not to.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    Quote Originally Posted by ettore_c View Post
    So, that doesn't work.

    A drawing has a block called "TITLEBLOCK" in it.
    I have a .DWG file called "TEST.dwg" with a block inside called "TITLEBLOCK" (this is the new block).

    When I do this:
    (COMMAND "-INSERT" "TITLEBLOCK=B:\\Blocks\\TEST.dwg" "0,0" "2" "0")
    Why would you redefine a block named TITLEBLOCK to a drawing with a block inside it named TITLEBLOCK creating a circular reference (block referencing itself)?

    Quote Originally Posted by ettore_c View Post
    ... I get the error "block references itself".

    If I name the drawing TITLEBLOCK.dwg, then use the TITLEBLOCK=B:\\Blocks\\TITLEBLOCK.dwg way, it asks if i want to redefine it. If I say yes, it says "BLOCK REFERENCES ITSELF" because there's a block within TITLEBLOCK.dwg that is, itself, called TITLEBLOCK.

    Again, the goal is to redefine the existing block, but my new block has a lot of attributes that I want kept. Alternate is being able to set those attributes afterwards, but I'd prefer not to.
    So you don't want to redefine the block, you want to magically merge the block definitions keeping what you want from both and discarding everything else?

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    Have you tried copy from dwg1 and paste to dwg2 then Attsync, used this to update our company title block, change in address.

  6. #6
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    Quote Originally Posted by Tom Beauford View Post
    Why would you redefine a block named TITLEBLOCK to a drawing with a block inside it named TITLEBLOCK creating a circular reference (block referencing itself)?

    So you don't want to redefine the block, you want to magically merge the block definitions keeping what you want from both and discarding everything else?
    There is an "old" block in a drawing called TITLEBLOCK. I can redefine it with an exploded updated version of it inside a drawing called TITLEBLOCK.dwg (this is what we've previously done). What that will leave me with is an updated TITLEBLOCK block, but it will still be able to be exploded, scaling will not be forced to uniform, and the block description will remain as it was (and other attributes I'm currently forgetting, I'm sure).

    I would like for the new version of the block to be identical to the copy stored in another drawing. The copy in that other drawing is already defined with all the attributes I set for the block.

    I understand the circular reference issue, I just don't know how to avoid it given what I want to do.

    Unless I can find a solution, the way I will end up doing this is to insert all the blocks I wish to redefine on top of the old blocks, but with a different name (so TITLEBLOCK1, FRAME1, REVISION1, etc, etc). Now with essentially two copies of every block in the drawing, I will figure out how to copy all the attributes from the original blocks to the new blocks. I'll now have two blocks on top of each other, with the same information, so I can now delete the old blocks, purge the drawing, then rename the new blocks to the proper names.

    Unless, of course, I can figure out how to simply redefine the existing block using a better-made block from another source location.

    - - - Updated - - -

    Quote Originally Posted by BIG-AL View Post
    Have you tried copy from dwg1 and paste to dwg2 then Attsync, used this to update our company title block, change in address.
    When I paste the block from another drawing, it leaves the block defined as previous. I would love for that to work.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: Inserting Blocks with Block Properties Set

    Quote Originally Posted by ettore_c View Post
    Unless, of course, I can figure out how to simply redefine the existing block using a better-made block from another source location.

    - - - Updated - - -


    When I paste the block from another drawing, it leaves the block defined as previous. I would love for that to work.
    How to redefine blocks in AutoCAD
    https://knowledge.autodesk.com/suppo...n-AutoCAD.html
    Several ways but Design Center is probably the easiest.

Similar Threads

  1. Preset Dynamic Block Properties Before Inserting
    By eberg.mail343416 in forum VBA/COM Interop
    Replies: 0
    Last Post: 2018-04-09, 09:37 PM
  2. Replies: 1
    Last Post: 2016-11-30, 08:36 AM
  3. Inserting dynamic block reference loses the properties
    By a.ghensi689507 in forum Dot Net API
    Replies: 2
    Last Post: 2016-04-13, 08:08 AM
  4. Retain Layer Properties When Inserting Block with Design Center
    By miket.203279 in forum AutoCAD General
    Replies: 8
    Last Post: 2009-08-28, 09:48 AM
  5. Inserting Blocks via the Insert Block Dialog
    By BrenBren in forum AutoCAD General
    Replies: 5
    Last Post: 2007-09-14, 01:20 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
  •