@Anonymous wrote:
.... pick the existing dimension text, then place my new dimension and after i have made my final click the actual dimesion will be replace with the text i picked from the old exploded text. ....
For that assign-the-text-content part alone, in barest-bones terms, and involving User selection:
(defun C:TEST (/ txt dim)
(setq
txt (vlax-ename->vla-object (car (entsel "\nText: ")))
dim (vlax-ename->vla-object (car (entsel "\nDimension: ")))
)
(vla-put-TextOverride dim (vla-get-TextString txt))
)
It can have the User selection of the Dimension replaced by (entlast) after drawing the Dimension, easily enough, but otherwise, first I have questions:
You talk about selecting the pieces left over from what was a Dimension, to Erase them. Is the idea that the routine would find the Text object from among those pieces for you? A routine could figure that out if there's one Text object for it to find, but will run into trouble in your lower example in the sample drawing, which involves two Text objects. How should such a situation be handled?
In Message 1, you describe the process in terms of an Aligned Dimension, but have a Linear one in the code. From the sample drawing, the latter seems like the appropriate type, but please confirm that.
[As an aside, I would not use the OSMODE value in Message 1's code. That includes the NEArest mode, which will almost always "win out" over the rest of them, so the others will be pointless. And you could easily get it Dimensioned to incorrect places.]
EDIT:
For one with only one piece of Text, try this:
(defun C:DimReplace (/ parts txtss)
(command
"_.LAYER" "_make" "DIM" "_color" "6" "" ""
"dimstyle" "r" "AA DIM I"
); command
(prompt "\nTo delete exploded-Dimension pieces for replacement with Dimension,")
(setq
parts (ssget "_:L" '((0 . "LINE,TEXT,SOLID")))
txtss (ssget "_P" '((0 . "TEXT")))
); setq
(setvar 'osmode 247)
(command-s "_.dimlinear")
(vla-put-TextOverride
(vlax-ename->vla-object (entlast))
(vla-get-TextString (vlax-ename->vla-object (ssname txtss 0)))
); ...put...Override
(command "_.erase" parts "")
(princ)
)
It assumes the Dimension Style exists, and is of appropriate characteristics [e.g. Text size] to replace the exploded pieces.
If the selection before making the Dimension includes more than one piece of Text, it will use one of them as the source for the override, but you will have no control over which one.
Kent Cooper, AIA