See the top rated post in this thread. Click here

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

Thread: Replace an old block with a new one with the same name

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2001-08
    Posts
    10
    Login to Give a bone
    0

    Default Replace an old block with a new one with the same name

    I have a block named DSBDSHTM that is used for creating sheet metal cut lists. I recently needed to add a new attribute (Part#) to this block. The new block is the same name as the original. I am trying to find a way that I can go into a drawing that has the old block definition in it and globally update all the existing blocks with the new one. I need those to remain on their same layers & in their same position in the drawing. To date I have been unable to find any utility or Lisp that can do this automatically. Does anyone know of such a utility or Lisp code that will work? Thanks in advance for any help.

    I am using AutoCAD 2020 with mainly Autolisp but VisualLisp code would be ok as well.

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,502
    Login to Give a bone
    1

    Default Re: Replace an old block with a new one with the same name

    Quote Originally Posted by d.gaither View Post
    I have a block named DSBDSHTM that is used for creating sheet metal cut lists. I recently needed to add a new attribute (Part#) to this block. The new block is the same name as the original. I am trying to find a way that I can go into a drawing that has the old block definition in it and globally update all the existing blocks with the new one. I need those to remain on their same layers & in their same position in the drawing. To date I have been unable to find any utility or Lisp that can do this automatically. Does anyone know of such a utility or Lisp code that will work? Thanks in advance for any help.

    I am using AutoCAD 2020 with mainly Autolisp but VisualLisp code would be ok as well.
    You mention it's the same block with same attributes and everything...

    Maybe you can try this (on a saved copy just in case):
    If you were to make the block definition a separate file (Wblock out the block name to a drawing file)
    and insert the block and re-define the same block, it should update and keep all the values.
    You may need to run the attsync command to see the new attributes.

    And if you need to do that to many files, you can use a script to do that

  3. #3
    Member
    Join Date
    2016-10
    Posts
    7
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Code:
    (command "_.insert" "dsbdshtm=" nil)
    This line gives me the following error:
    Code:
    "dsbdshtm.dwg": Can't find file in search path
    *Invalid*
    I'm not sure what that line is supposed to be doing, it looks like it's not doing anything.

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

    Default Re: Replace an old block with a new one with the same name

    He stated that it was the name of a specific block. You would have to modify the code for your use. The main thing he was showing is the use of the attsync command.
    C:> ED WORKING....

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

    Default Re: Replace an old block with a new one with the same name

    You don't need any code if you use the CLASSICINSERT command. Just browse to the new block and you will be prompted to redefine the old block.

    I see Ted posted seconds before I did.
    C:> ED WORKING....

  6. #6
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,502
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Quote Originally Posted by Ed Jobe View Post
    I see Ted posted seconds before I did.
    BOOM

  7. #7
    Member
    Join Date
    2001-08
    Posts
    10
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Quote Originally Posted by Ed Jobe View Post
    You don't need any code if you use the CLASSICINSERT command. Just browse to the new block and you will be prompted to redefine the old block.

    I see Ted posted seconds before I did.
    Thanks Ed. When I try that, the block that comes in has the new attribute when I edit it but the old existing on still shows the block without the new attribute. However, if I open the old block in block editor, I see the new attribute. The problem is, when I run another program it does not see the new attribute on the old block & crashes. It is like the old block definition is updated but it needs refreshed somehow.

    Forgot to mention, I have numerous other programs that also insert this block automatically & they will by default insert the original that is defined in the drawing already & not get the new one. Trying to find a way when I know I am dealing with a drawing that has the old block to get them all refreshed at once.

  8. #8
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,502
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Quote Originally Posted by d.gaither View Post
    Thanks Ed. When I try that, the block that comes in has the new attribute when I edit it but the old existing on still shows the block without the new attribute. However, if I open the old block in block editor, I see the new attribute. The problem is, when I run another program it does not see the new attribute on the old block & crashes. It is like the old block definition is updated but it needs refreshed somehow.
    Did you try Attsync as I mentioned? That "should" refresh the blocks in the drawing.

    Forgot to mention, I have numerous other programs that also insert this block automatically & they will by default insert the original that is defined in the drawing already & not get the new one. Trying to find a way when I know I am dealing with a drawing that has the old block to get them all refreshed at once.
    That is a bigger question, the template or files those programs are referencing should get updated. And if you've updated the internal block, It would insert that one correct?
    More about you or your companies process for inserting blocks.

    As I mentioned before, you can run a script to update blocks in current drawings, we use scriptpro

  9. #9
    Member
    Join Date
    2001-08
    Posts
    10
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Quote Originally Posted by tedg View Post
    Did you try Attsync as I mentioned? That "should" refresh the blocks in the drawing.


    That is a bigger question, the template or files those programs are referencing should get updated. And if you've updated the internal block, It would insert that one correct?
    More about you or your companies process for inserting blocks.

    As I mentioned before, you can run a script to update blocks in current drawings, we use scriptpro
    Thanks for the help Ted (Sorry I said Ed before). The Attsync does the trick with the old block not refreshing.As for the ancillary programs that insert this block, I am updating them to handle the updated block with the added attribute. I was just looking for a way to automate the whole insert the new block -->Yes Redefine-->Attsync thing. Am I wrong in thinking that if I insert the block by name from code, it will get the existing definition instead of the updated version on the drive? Or, is there a way to achieve this with code?

  10. #10
    Member
    Join Date
    2001-08
    Posts
    10
    Login to Give a bone
    0

    Default Re: Replace an old block with a new one with the same name

    Thanks everyone! With the information provided, I was able to create a lisp that accomplishes what I needed!

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 2018-03-18, 06:20 PM
  2. Select multiple Reference Name and set one new file path at same time
    By Wish List System in forum AutoCAD Wish List
    Replies: 9
    Last Post: 2017-10-07, 10:24 PM
  3. Replace existing block definition with new definition of the same name
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2016-10-31, 07:37 PM
  4. Identify blocks with same name and replace them with another block
    By msmith.109036 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2013-11-12, 04:48 PM
  5. Replace old xref files with a set of new xref files
    By simon_coupland in forum AutoLISP
    Replies: 15
    Last Post: 2013-05-30, 05:12 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
  •