TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on April 11, 2015, 09:07:16 AM

Title: Redefining a block in multiple files via OBJECTDBX Wrapper
Post by: MSTG007 on April 11, 2015, 09:07:16 AM
Lee ad awhile ago showed me an awesome way to do some layer management stuff via this.

http://www.theswamp.org/index.php?topic=47376.msg524151#msg524151

I was wondering using his same setup how to change it to redefine 1 block name in mulitple dwgs.

Thanks!
Title: Re: Redefining a block in multiple files via OBJECTDBX Wrapper
Post by: ttray33y on June 14, 2015, 11:26:33 PM
in my own understanding. ObjectDBX wrapper cannot do that.

Code: [Select]
http://lee-mac.com/odbxbase.html
Title: Re: Redefining a block in multiple files via OBJECTDBX Wrapper
Post by: Lee Mac on June 15, 2015, 04:10:10 AM
You could try the following (untested!):
Code - Auto/Visual Lisp: [Select]
  1. (defun c:batchredef ( / blk dwg )
  2.     (while
  3.         (not
  4.             (or
  5.                 (= "" (setq blk (getstring t "\nSpecify block name to redefine: ")))
  6.                 (setq dwg (findfile (strcat blk ".dwg")))
  7.             )
  8.         )
  9.         (princ (strcat "\nFile \"" blk ".dwg\" not found."))
  10.     )
  11.     (if dwg
  12.         (LM:odbx
  13.             (function
  14.                 (lambda ( doc )
  15.                     (if
  16.                         (not
  17.                             (vl-catch-all-error-p
  18.                                 (vl-catch-all-apply 'vla-item  (list (vla-get-blocks doc) blk))
  19.                             )
  20.                         )
  21.                         (vla-delete
  22.                             (vla-insertblock
  23.                                 (vla-get-modelspace doc)
  24.                                 (vlax-3D-point 0 0) dwg 1.0 1.0 1.0 0.0
  25.                             )
  26.                         )
  27.                     )
  28.                 )
  29.             )
  30.             nil t
  31.         )
  32.     )
  33.     (princ)
  34. )

EDIT: On testing the above, this method does not appear to be successful.