Okay, well, here's something that half works.
- (defun st ( / ) (setq es (entsel "\nSelect MTEXT:") en (car es) cp (cadr es) vo (vlax-ename->vla-object en) vc (vla-copy (vlax-ename->vla-object en)) vcc (vla-put-visible vc :vlax-false) ex (vl-cmdf "explode" en) ss (ssget "_P") s (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) ot (ssname (ssget cp '((0 . "TEXT"))) 0) os (vla-get-textstring (vlax-ename->vla-object ot)) textCol "8" ) (if ss (progn (vlax-for o s (progn (setq tstr (vla-get-textstring o)) (if (= tstr os) (progn (vl-cmdf "draworder" (vlax-vla-object->ename o) "" "_front") (LM:strikethrough (vlax-vla-object->ename o) '((0.0 0.1))) (vl-cmdf "erase" (vlax-vla-object->ename o) "") ) (vl-cmdf "erase" (vlax-vla-object->ename o) "") ) ) ) (vla-delete s) ) ) (setq text (vl-string-subst (strcat "\\C" textCol ";" os "\\C256;") os (vla-get-textstring vc))) (vla-put-textstring vc text) (vla-put-visible vc :vlax-true) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewPort) ss )
This does almost what we want it to do, but I'm having trouble with draw order. Running it the first time on an MTEXT block works as expected, but running it again on a second line, the MTEXT block ends up on top of the previously drawn poly lines.
To try and solve it, I put the draworder of the TEXT to _front before using the strikethrough command on it. I figured this would put the polyline on the front layer. I don't want to change the draw order of the MTEXT.
It seems like when I use VLA-COPY, it is copying it to the front. Then my TEXT object is being brought to front after that, so that is showing in front of the MTEXT, but any previous lines are hidden as the new MTEXT object is in front of the previous polylines. Is there some caveat when using vla-copy and draw orders? |