- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So the company I work for is trying to update a block so the attributes are properly tagged for exporting purposes. We have 1000's of drawings and on a given day I can shift through 25-100 that need the new block. After a few days of scowering the web in my spare time I have written some semi functional code, but it has a few bugs I can't work out because I don't properly understand how lisp handles data types.
Currently it is not adding the old attributes, when debugging the list prints right, I just can't get it to insert into the new block right.
Any ideas?
Code:
(defun c:BU (/ )
(DEFUN AddSupportPath (dir / tmp Cpath);function for adding support path
(VL-LOAD-COM)
(SETQ Cpath (GETENV "ACAD") tmp (STRCAT ";" dir ";"))
(IF (NOT (VL-STRING-SEARCH dir cpath)) (SETENV "ACAD" (STRCAT Cpath ";" dir)))
(PRINC)
)
(AddSupportPath "X:\\Precast\\z-Misc\\00_PUBLISH");add new block support path
(setq osnapold (getvar "osmode"))
(setq ss (ssget "_X" '((0 . "INSERT") (2 . "BOM 2013"))));select old block
(setq origin (cdr (assoc 10 (entget (ssname ss 0)))));identify old block origin
(setq scale (cdr (assoc 41 (entget (ssname ss 0)))));identify old block scale
(setq sel (entsel "\nSelect a Block: "));select old block for attribute list
(setq attlst
(mapcar '(lambda (x) (vla-get-TextString x))
(vlax-invoke (vlax-ename->vla-object (car sel)) 'GetAttributes);make list of old attributes
)
)
;(princ attlst);debugg line to print items to verify correct
(command "ucs" "w");switch to world coord
(command "_-insert" "BOM2016" origin scale "" "" items);insert new block with old attributes
(setvar "osmode" osnapold)
(command "ucs" "p");switch coord back
(command) )
I would also like to delete this line and just have it use the "ss" variable when extracting old attributes, but it throws a data type error.
(setq sel (entsel "\nSelect a Block: "));select old block for attribute list
Thanks everyone
Solved! Go to Solution.