TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 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
-
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?
-
if the attributes are the same, can you export them from block a and import to block b?
-
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
-
Here is one I use quite regularly
;;; 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)
)
-
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
-
cant you also use the "refedit" command?
-
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?
-
Should be able to be done easily enough ... If I get some time, I'll look at it ... kinda busy right now ...
-
-insert 1a=2a
or if you need the name to change as well, use rename to rename 1a to 2a then -insert 2a=
-
Bob,
that's a cool one.
There are always thinks in Acad i don't know about yet.
Thanks,
Bernd