Author Topic: Replacing block without changing attribute  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

TJAM51

  • Guest
Replacing block without changing attribute
« on: April 06, 2005, 10:37:42 AM »
I have a block named 1a. This block has an attribute with information typed into the attribute. I need to replace this block 1a with a new block 2a but need to retain the attribute information...only the physical block shape and size are affected......any ideas?


Thanks

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Replacing block without changing attribute
« Reply #1 on: April 06, 2005, 11:14:49 AM »
What happens if you redefine 1a = 2a?  I think the block will update as long as the Attributes are the same.  Can you post the 2 blocks and we can test it?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

hudster

  • Gator
  • Posts: 2848
Replacing block without changing attribute
« Reply #2 on: April 06, 2005, 11:23:25 AM »
if the attributes are the same, can you export them from block a and import to block b?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

ronjonp

  • Needs a day job
  • Posts: 7529
Replacing block without changing attribute
« Reply #3 on: April 06, 2005, 11:36:28 AM »
If all you are doing is changing the way the block looks by redefining it, the attribute values should stay the same. Post the drawing you are working on.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Replacing block without changing attribute
« Reply #4 on: April 06, 2005, 11:36:38 AM »
Here is one I use quite regularly

Code: [Select]

;;;   UB.LSP
;;;   Copyright (C) 1997-2005 by K.E. Blackie
;;;
;;;   kblackie -AT- resourcecad.com
;;;
;;;   Permission to use, copy, modify, and distribute this software
;;;   for any purpose and without fee is hereby granted, provided
;;;   that the above copyright notice appears in all copies and that
;;;   both that copyright notice and this permission notice appear in
;;;   all supporting documentation.
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;;
;;;
;;;   15 March 1997
;;;   8 August 1998
;;;   29 November 2001
;;;   12 January 2005
;;;
;;;----------------------------------------------------------------------------
;;;   DESCRIPTION
;;;----------------------------------------------------------------------------
;;;   C:UB
;;;
;;;   This function replaces a block reference specified by the user
;;;   to another block already inserted in the drawing.
;;;   All attributes are left in place and remain unmodified.
;;;   No error checking is provided. It is presumed the user will
;;;   know what blocks are already inserted and available for use.
;;;
;;;----------------------------------------------------------------------------
;;;----------------------------------------------------------------------------

(DEFUN C:UB( / as e index newname ss ssl)
  (setq ss (ssget '((0 . "insert"))))
  (setq newname (getstring t "\nReplace with block name: "))
  (setq ssl(sslength ss))
  (setq index 0)
  (repeat ssl
   (setq e (entget(ssname ss index)))
   (setq as (assoc 2 e))
   (setq e (subst (cons 2 newname) as e))
   (entmod e)
   (setq index (+ 1 index))
  )
 (PRINC)
)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CottageCGirl

  • Guest
Replacing block without changing attribute
« Reply #5 on: April 06, 2005, 12:09:53 PM »
copy the block- explode the copy, edit the shape-make the revised one back into a block of the same name (be sure to select a base point) -click ok and the origional  will be redefined  [by copying it, it is a double check that it works-you just erase the duplicate when you are done]

this will work for all of the same blocks in a drawing

dubb

  • Swamp Rat
  • Posts: 1105
Replacing block without changing attribute
« Reply #6 on: April 06, 2005, 01:24:16 PM »
cant you also use the "refedit" command?

VerticalMojo

  • Guest
Replacing block without changing attribute
« Reply #7 on: August 11, 2005, 10:56:52 AM »
Keith, is there a way to use your lisp but have it ask for the block name instead of selecting objects that way you can globally do a change?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Replacing block without changing attribute
« Reply #8 on: August 11, 2005, 11:28:46 AM »
Should be able to be done easily enough ... If I get some time, I'll look at it ... kinda busy right now ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Bob Wahr

  • Guest
Replacing block without changing attribute
« Reply #9 on: August 11, 2005, 11:32:48 AM »
-insert 1a=2a

or if you need the name to change as well, use rename to rename 1a to 2a then -insert 2a=

Amsterdammed

  • Guest
Replacing block without changing attribute
« Reply #10 on: August 11, 2005, 02:54:44 PM »
Bob,

that's a cool one.

There are always thinks in Acad i don't know about yet.

Thanks,

Bernd