@Kent1Cooper wrote:
....
Does a Text object also already exist, that can be selected along with the rectangle? If it does, with a numerical value, it shouldn't be hard to include incrementing that value as it is copied. And it looks like a routine would need to have the User position the Text as well as and independently of the rectangle.
For example [lightly tested]:
(defun C:COTI ; = Copy Outline and Text Incremented
(/ *error* outl txtsel txtent txtobj str outlmid txtmid)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(prompt (strcat "\nError: " errmsg))
); if
(entdel outl) (entdel txtent)
(prin1)
); defun - *error*
(if
(and
(setq outl (car (entsel "\nSelect outline object to copy: ")))
(setq txtsel (entsel "\nSelect numerical Text to increment with each new outline: "))
(wcmatch (cdr (assoc 0 (entget (setq txtent (car txtsel))))) "*TEXT")
(setq str (vla-get-TextString (setq txtobj (vlax-ename->vla-object txtent))))
(= (itoa (atoi str)) str); content represents integer [also no intermal formatting if Mtext]
); and
(progn ; then
(vla-getboundingbox (vlax-ename->vla-object outl) 'minpt 'maxpt)
(setq outlmid (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2)))
(vla-getboundingbox txtobj 'minpt 'maxpt)
(setq txtmid (mapcar '/ (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt)) '(2 2 2)))
(alert "Place outlines, then incremented text; press ESCape to end.")
(while T
(command "_.copy" outl txtent "" "0,0" "0,0")
(command "_.move" outl "" outlmid pause)
(setq outlmid (getvar 'lastpoint))
(vla-put-TextString txtobj (setq str (itoa (1+ (atoi str)))))
(command "_.move" txtent "" txtmid pause)
(setq txtmid (getvar 'lastpoint))
); while
); progn
(prompt "\nDid not select an outline object and numerical text object.")
); if
(prin1)
)
It could use Undo begin/end wrapping, but that can be added if it does what you want otherwise. It could get other refinements, such as an option to increment the text content by something other than 1, and/or downward, etc.
It continually Copies the original selected objects in place, leaves the copies and Moves the originals, including incrementing the text content before Moving it, so you see it with its changed value as you place it.
The "outline" object can be anything -- it doesn't need to be a rectangle. If it is one, it can be a Polyline or a Block or a Region or a Surface, but it can also be a Circle or an Ellipse or.... Since it is simply Copied, there's no need for (grdraw), dealing with Layers, etc. [Would it be worth checking that the selected objects are on unlocked Layers?]
Kent Cooper, AIA