我想不出为什么ObjectDBX无法用新块(动态,属性化)替换当前块(非动态,非属性化)。。。在代码中提供了一些彻底的规划和条件过滤。 Verbose example:
(defun _GetBlockTextIf ( blockcollection blockcondition btextcondition / _getitemincollectionif blockdef btextobj ) (defun _GetItemInCollectionIf ( collection condition ) (if (vl-catch-all-error-p (vl-catch-all-apply (function (lambda nil (vlax-for item collection (if (condition item) (progn (setq result item) (exit))) ) ) ) ) ) result ) ) (setq blockcondition (eval blockcondition) btextcondition (eval btextcondition) ) (if (and (setq blockdef (_GetItemInCollectionIf blockcollection blockcondition)) (setq btextobj (_GetItemInCollectionIf blockdef btextcondition)) ) (vla-get-textstring btextobj) ))(defun c:test ( / acdoc acblk ) (vl-load-com) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)) acblk (vla-get-blocks acdoc) ) (_GetBlockTextIf acblk '(lambda ( x ) (wcmatch (strcase (vla-get-name x)) "*-BAR")) '(lambda ( x ) (and (wcmatch (vla-get-objectname x) "AcDb*Text") (wcmatch (vla-get-textstring x) "*=1'-0*"))) ))
... I had a sneaking suspicion that my Hero would show up.
That's just sad -
I have 35,000 drawings for two Hydro Electric Dams
maybe 1/5 of those have one of these predefined blocks in them
if I change the block
I have to update all those drawings (with the proper scale bar)
For this exercise (updating a solidworks drawing to Our AutoCAD standards)
I'd rather just explode the scale block
erase all the pieces
and then reinsert it
or
shove some code in there that sets every scale possibility
to get the piece of text I want ..............
I can't think of a reason why ObjectDBX would be unable to replace the current block (non-dynamic, non-attributed), with a new block (dynamic, attributed)... provided some thorough planning, and conditional filtering in your code, that is.
页:
1
[2]