Seems that it adds new block definition, under the provided name:
(vla-ConvertToStaticBlock o "ABC")
But, when I try to convert other block reference under the same / existing block definition name, I get:
_$ (vla-ConvertToStaticBlock o "ABC")Error: Automation Error. Duplicate key_1$
But/And It creates an annonymous block definition anyway:
_$ (vla-get-EffectiveName (vlax-ename->vla-object (car (entsel))))"*U117"_$
Note that the "Name" property row in the quick properties dialog, always references to the block's "effective name / definition name".
So thats why my previously posted code forces the creation of N annonymous block definitions:
(ErrCatcher 'vla-ConvertToStaticBlock (list o (vla-get-EffectiveName o)))
Since this always triggers an error
Of course: the block name argument for the ActiveX converttostaticblock method cannot correspond to an existing block, otherwise you will receive a duplicate key error - this is why the original code included the '_make_key' function. First of all, thanks for all the help so far!
I would like to think together with you guys, but since I can't program, it's though
Let me know if you find a solution please!
Thanks!
- Martin
Try this:
(defun C:test ( / ErrCatcher BlksColl SS i o cnt flg nm ); (ErrCatcher 'vla-item (list (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) "BlockThatDoesNotExist")) -> nil(defun ErrCatcher ( func varLst / rtn ) (if (not (vl-catch-all-error-p (setq rtn (vl-catch-all-apply func varLst)))) rtn))(setq BlksColl (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))(prompt "\nSelect blocks to convert them into static ones:" )(if (setq SS (ssget "_:L" (list (cons 0 "INSERT")))) (repeat (setq i (sslength SS)) (if (eq :vlax-true (vla-get-IsDynamicBlock (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i))))))) (progn (setq cnt 0) (setq flg 'T) (while flg (if (not (ErrCatcher 'vla-item (list BlksColl (setq nm (strcat (vla-get-EffectiveName o) "_" (itoa (setq cnt (1+ cnt)))))))) (progn (vla-ConvertToStaticBlock o nm) (setq flg nil)) ); if ); while ); progn ); if ); repeat); if(princ));| defun |; (or vlax-get-acad-object (vl-load-com)) (princ)
Note that the original dynamic blocks are not purged.
Super! This is what I was looking for!
Thank you so much!
-Martin
页:
1
[2]