Does anyone out there have a routine that centers selected text to the center of a circle.
Just make your text justified to middle, then move it from the insertion point to the center point. If you want to make it faster, only turn on those two options of the running osnaps. Tim
Here is a quick one. ;; Center Text to Circle ;; CT.lsp (defun C:CT ( / ent cent ss txt ) (prompt "\nPick Circle:") (setq ss (ssget)) (if ss (progn (setq ent (entget (ssname ss 0))); get Circle entity (setq cent (cdr (assoc 10 ent))); get Center point (prompt "\nPick a Single Line of Text") (setq ss nil) (setq ss (ssget)) (if ss (progn (setq ent (entget (ssname ss 0))); get the Text Entity (setq txt (cdr (assoc 1 ent))); get the Value of the Text (if txt (progn (command "_erase" ss ""); remove old text (command "_text" "m" cent "" "" txt); insert new text ); progn ); if ); progn ); if ); progn ); if (princ) ); function
I tend toward the simple approach, middle justify the text and snap to center of circle. If this happens frequently, I'd make the circle and text an attributed block. Place the block and edit the attribute.
Sorry Bob, I guess I don't know how to use this routine. I tried to select the circle and the text, and then the text string again and the text disappeared.
Try it. Move text polygon... Justify text to Middle Center and move to centroid of polygon. (circle, rectangle). []s, Rogério ;;;MIDDLECENTER JUSTIFY AND MOVE TEXT TO CENTROID - BEGIN (defun C:MTP (/ ENT ELST PTS SS1 OLDOSM INS TXT EI p1 p2 p3 p4) (setvar "cmdecho" 0) (command "STYLE" "STANDARD" "verdana" "0" "1" "0" "N" "N");;optional (setq OLDOSM (getvar "osmode")) (SETQ TXT (ENTSEL "\n Pick only text to move to center to Polygon:"));LOCALIZAÇÃO DE INSERÇÃO DE TEXTO SELECIONADO ;(SETQ INS (OSNAP (CADR TXT) "INSERT"));PONTO DE INSERÇÃO (setq ET (cdr(assoc 0(entget(car TXT)))));;TYPE: TEXT (SETQ EL (cdr(assoc 8(entget(car TXT)))));;LAYER (SETQ EI (cdr(assoc 10(entget(car TXT)))));;PONTO DE INSERÇÃO (SETQ EH (cdr(assoc 40(entget(car TXT)))));;ALTURA (SETQ EA (cdr(assoc 50(entget(car TXT)))));;ÂNGULO DO TEXTO? (SETQ TS (cdr(assoc 1(entget(car TXT)))));;TEXT STRING (setvar "clayer" EL) (COMMAND "ERASE" "SI" TXT) (COMMAND "TEXT" "MC" EI EH EA TS) (COMMAND "MOVE" (ENTLAST) "" (CDR (ASSOC 10 (ENTGET (ENTLAST)))) EI ) (COMMAND "CHANGE" "last" "" "P" "C" "1" "" ) (setvar "osmode" 0) ;================================================ (princ "\n Get Centroid...") (if (setq Curent (car (entsel "\n Select a closed Polyline (Polygon): "))) (progn (setq OldCmd (getvar "CMDECHO")) (setvar "CMDECHO" 0) (command "_.COPY" CurEnt "" '(0 0 0) '(0 0 0) "_.REGION" (entlast) "" ) (setq RegObj (vlax-ename->vla-object (entlast))) (vla-GetBoundingBox RegObj 'MinPnt 'MaxPnt) (setq MinPnt (vlax-safearray->list MinPnt) OriCen (vlax-safearray->list (vlax-variant-value (vla-get-Centroid RegObj) ) ) CurCen (mapcar '- OriCen MinPnt) ) (vla-Erase RegObj) (mapcar 'princ (list "\n Relative centroid: " CurCen)) (mapcar 'princ (list "\n Absolute centroid: " OriCen)) (setvar "CMDECHO" OldCmd) ) ) (COMMAND "CHANGE" "last" "" "P" "C" "bylayer" "" ) (command "change" (ENTLAST) "" "" OriCen "" "" "" "") (setvar "osmode" OLDOSM) (princ "\n Done!") (princ) ) ;;;MIDDLECENTER JUSTIFY AND MOVE TEXT TO CENTROID - BEGIN
To set text height and don´t modify your text style: (command "STYLE" "STANDARD" "" "0" "1" "0" "N" "N")
Felipe, I wrote something about centering a letter/s in a circle. Like change letter balloons. This file was in CADalyst. Look in autodesk.autocad.customer-files. centerit.lsp Hope it works the way you want. It changes the justification to center, and then moves it to the center of the circle. One click. W. Kirk Crawford Rochester Hills, Michigan
Tom, Your way is, I believe, The Proper Way. But where I work, just get it done. W. Kirk Crawford Rochester Hills, Michigan
Kirk, he didn't explain the application, but I was thinking of something like a column grid bubble. Just takes a sec to define an attributed block, then forever after it's faster to place than drawing individual circles and placing text inside. If it's anything like that, I'd prefer to have the thing as a single entity anyway, rather than two.