Laranjeira Posted December 10, 2024 Posted December 10, 2024 I used the "Annotate Suite" in AutoCAD 2011, which has 25 LISP programs for use with text and mtext. It was developed by PowerSolutions, which closed down, so the latest version only works in AutoCAD 2011 and below. I found some LISPs throughout the years that perform the same functions, and I used them, but there is one that I have never found and would like someone to develop. It is the Paragraph Adjustment. It is very useful for adjusting general project notes by increasing or decreasing all the paragraphs of the note to a maximum width allowed by the format of the project sheet available for each project. It does not automatically adjust all 10, 15 notes, but it helps a lot in interactive mode, adjusting paragraph by paragraph by repeating the PA command. Attached is the original explanation from the Suite's user manual. Can anyone help? I would greatly appreciate it. PA.dwg Quote
Steven P Posted December 10, 2024 Posted December 10, 2024 So how are your LISP abilities? From what I see it should be reasonably easy to create something... If you use the LISP command GETPOINT twice and record the results in 2 variables (this is the easiest method) Extract the X coordinates from these 2 points using CAR on each of these calculate the distance in x - this is the width of the rectangle, save as a variable If it was me I'd subtract a little from that just so my text wasn't over running any lines Select the text using ENTGET for single texts and save its handle as a variable Use ENTMOD method (there is a good worked example online) to update the text And that should set mtext width to the paragraph width. If you have dtexts that over run the rectangle area you'll need to convert these to mtext (help is out there and also help to work out dtext width)... and then proceed as above. Might give you a start to work something out Quote
BIGAL Posted December 10, 2024 Posted December 10, 2024 (edited) I can see a few problems, the text is very different mix, for me I would look at mtext. There is txt2mtxt as 1st step, this allows the changing of a paragraph width. Ok may have an idea for this This is the text required for a test. If you look carefully the 1st line does not have a full stop so could convert into mtext, does end of line have a full stop " If so make a new line. You would select the text and use a sort on Y for line order. This would be a straight txt2mtxt. But then run option remove seperate lines. This is the text required for a test. This is the text required for a test. This is the text required for a test. "This is the text required for a test. This is the text required for a test. This is the text required for a test." So may be 2 -3 different functions. Need to think about it. A start dont run ! For the 3 lines do txt2mtxt 1st, will look into width. (setq obj (vlax-ename->vla-object (car (entsel "\nPick mtext object ")))) (setq str (vlax-get obj 'textstring)) (while (wcmatch str "*\\P*") (setq str (vl-string-subst " " "\\P" str)) ) (vlax-put obj 'textstring str) (vlax-put obj 'width 6) Edited December 10, 2024 by BIGAL Quote
BIGAL Posted December 11, 2024 Posted December 11, 2024 Hopefully these make sense as a starting point. ; https://www.cadtutor.net/forum/topic/94735-paragraph-adjust/ ; By AlanH Dec 2024 (defun AH:strippara ( / ent obj str ht ) (setq ent (entsel "\nPick mtext ")) (setq obj (vlax-ename->vla-object (car ent))) (setq str (vlax-get obj 'textstring)) (setq ht (cdr (assoc 40 (entget (car ent))))) (while (wcmatch str "*\\P*") (setq str (vl-string-subst " " "\\P" str)) ) (vlax-put obj 'textstring str) (vlax-put obj 'width (/ (* 0.85 (* ht (strlen str))) 3.)) (princ) ) (defun AH:textlines ( / ) (setq ss (ssget '((0 . "TEXT")))) (setq lst '()) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (1- x))))) (setq str (vlax-get obj 'textstring)) (setq ins (vlax-get obj 'insertionpoint)) (setq y (cadr ins)) (setq lst (cons (list Y str) lst)) ) (setq lst (vl-sort lst '(lambda (x y) (> (car x)(car y))))) (setq str "") (foreach val lst (setq nstr (cadr val)) (setq num (strlen nstr)) (if (= (substr nstr num) ".") (setq str (strcat str " " nstr "\\" "P")) (setq str (strcat str " " nstr)) ) ) (setq pt (getpoint "\nPick point for mtext ")) (setq ht (cdr (assoc 40 (entget (ssname ss 0))))) (command "mtext" Pt (mapcar '+ pt (list 3.5 0.0 0.0)) "-" "") (setq obj (vlax-ename->vla-object (entlast))) (vlax-put obj 'textstring str) (vlax-put obj 'width (/ (* 0.85 (* ht (strlen str))) 3.)) (princ) ) (defun c:T1 ( / )(AH:strippara)) (defun c:T2 ( / )(AH:textlines)) (alert "text-mtext\n\nT1 is used for adding paragrpahs looking for the period .\n\nT2 is used to select plain text and convert to mtext.") 1 Quote
Laranjeira Posted December 25, 2024 Author Posted December 25, 2024 Thanks for the answer, Steven. My experience in creating lisps is almost zero, just very basic things. What I did over 40 years using CAD, since version 2.64b (which I still have today), was to look for lisps with functions that I wanted to use and, by editing and mixing various parts of lisps, create one that would perform the function I needed. In the case of PA, it seems very clear to me how it works. Imagine a text with several paragraphs. You select them with a window where the first point is above and to the left of the first paragraph that you want to adjust, and the second point in the window selects all the paragraphs below that you want to adjust, and by pulling the window to the right side, the right line of the window defines the limit of the width that each paragraph can have. Ready, it adjusts the selected paragraphs, and within the limits to the right of the open window. I understand that PA transforms every selected paragraph chain into Mtext, and based on the window we open it limits the text on the right side by defining a new width for this Mtext, redistributing it downwards or upwards, and then explodes the Mtext. It seems simple at first, but not to me. Notes in a project can have 30, 40 paragraphs, and depending on the project I have to adjust them to different spaces, sometimes 14 cm, sometimes 17,5cm, sometimes I want to gain space in height, therefore external in width, and sometimes the opposite. And for this, it is not very useful to keep transforming each paragraph into Mtext, redistributing it, going to the next one and so on. PA does this more quickly. This also applies to notes and observations distributed throughout the project, where PA helps to redistribute the text in the space where the note or observation is. For me, it is extremely useful and I use it daily in all projects. PARAGRAPH ADJUST.avi Quote
Laranjeira Posted December 25, 2024 Author Posted December 25, 2024 On 12/10/2024 at 8:27 PM, BIGAL said: I can see a few problems, the text is very different mix, for me I would look at mtext. There is txt2mtxt as 1st step, this allows the changing of a paragraph width. Ok may have an idea for this This is the text required for a test. If you look carefully the 1st line does not have a full stop so could convert into mtext, does end of line have a full stop " If so make a new line. You would select the text and use a sort on Y for line order. This would be a straight txt2mtxt. But then run option remove seperate lines. This is the text required for a test. This is the text required for a test. This is the text required for a test. "This is the text required for a test. This is the text required for a test. This is the text required for a test." So may be 2 -3 different functions. Need to think about it. A start dont run ! For the 3 lines do txt2mtxt 1st, will look into width. (setq obj (vlax-ename->vla-object (car (entsel "\nPick mtext object ")))) (setq str (vlax-get obj 'textstring)) (while (wcmatch str "*\\P*") (setq str (vl-string-subst " " "\\P" str)) ) (vlax-put obj 'textstring str) (vlax-put obj 'width 6) Thanks for the answer Bigal. I replied to Steven and I think you are right about transforming it into mtext, defining a new width, and I think you can explode the mtext back into text. Just type PA, open the window and it's done. I attached a video where you can see how Paragraph Adjust works. The open window involves the paragraphs from the first to the last that you want to redistribute in width, and the second point in the window on the right defines the new maximum width of the texts. And that's it, it's done. PARAGRAPH ADJUST.avi Quote
Laranjeira Posted January 20 Author Posted January 20 Can someone help me? It's impossible for me, but I think it shouldn't be too difficult for experts. Quote
BIGAL Posted January 20 Posted January 20 Once you make MTEXT click it look in properties window, for Defined width it may be 0, so click on zero a line should appear on the Mtext just drag to suit width. Once you do this the next go will have all the drag arrows. Yes could do a lisp to set width. So have a go at a lisp, just need insertion point and a new point then get distance between the points, hint using VL code. (vlax-put obj 'width dist) Quote
Laranjeira Posted January 21 Author Posted January 21 Tks Bigal, but I can't create a lisp simply because I don't know how to do it. I don't even know what vlax-put-obj means. Think about having notes with 10, 15, 20 separate paragraphs and I always need to adjust them so that they have a maximum length from the beginning of each paragraph. I think that experts can developing a lisp to do this job. The Paragraph Adjust that I use also allows you to configure the spacing between lines, the spacing between paragraphs, the tolerance of letters for more or less to define whether a word stays or continues to another line of text, the justification of the paragraph, whether right, middle, left, or any other allowed by AutoCAD, if you want it to be mtext or text, and other settings, but its only works in AutoCAD 2011. I'm just asking for the simplest thing, which is to adjust the paragraph ond by one, like in the print. No need settings. Can you do it? Quote
marko_ribar Posted January 21 Posted January 21 (edited) This worked for me, but I haven't touched Styles and other potential parameters like current layer missmatch with original "TEXT" entity, but if you are working with only "MTEXT" entities, it should go smoothly without any problems... (defun c:pa ( / p1 p2 dx dy bp ss mtxt ) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (initget 1) (setq p1 (getpoint "\nFirst point of rectangle : ")) (initget 1) (setq p2 (getcorner p1 "\nSecond point of rectangle : ")) (setq dx (abs (- (car p1) (car p2)))) (setq dy (abs (- (cadr p1) (cadr p2)))) (setq bp (list (min (car p1) (car p2)) (max (cadr p1) (cadr p2)))) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "*TEXT")))) (if (= (cdr (assoc 0 (entget (ssname ss 0)))) "TEXT") (progn (vl-cmdf "_.TXT2MTXT" (ssname ss 0)) (while (< 0 (getvar (quote cmdactive))) (vl-cmdf "") ) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "MTEXT")))) (setq mtxt (ssname ss 0)) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) (progn (setq mtxt (ssname ss 0)) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) ) (princ) ) HTH. M.R. Edited January 22 by marko_ribar Quote
Laranjeira Posted January 21 Author Posted January 21 Thanks for your attention Marko. It only worked when the phrase has only one paragraph. In this case, it adjusts the phrase by creating two or more paragraphs as desired, opening the base rectangle. But when you have a phrase with two or more paragraphs, the lisp does not make any adjustments. Please, I attached an AVI file in response to Bigal and Steven where I show how the PA works. If you can take a look, maybe you can improve the lisp. This is the most useful lisp I have out of the hundreds I have, and the one I use most on a daily basis. PARAGRAPH ADJUST.avi Quote
BIGAL Posted January 21 Posted January 21 Look at this snippet of code it adjusts the width property. NO error checks is it Mtext. (defun c:mtwid ( / obj dist pt1 pt2) (setq obj (vlax-ename->vla-object (car (entsel "\nPick mtext object ")))) (setq pt1 (vlax-get obj 'insertionpoint)) (setq pt2 (getpoint pt1 "\nDrag for width ")) (setq dist (distance pt1 pt2)) (vlax-put obj 'width dist) (princ) ) Quote
marko_ribar Posted January 22 Posted January 22 I've changed slightly my posted code to include command TXT2MTXT - it should remember all parameters between conversion of TEXT to MTEXT... HTH. M.R. Quote
Laranjeira Posted January 22 Author Posted January 22 18 hours ago, marko_ribar said: This worked for me, but I haven't touched Styles and other potential parameters like current layer missmatch with original "TEXT" entity, but if you are working with only "MTEXT" entities, it should go smoothly without any problems... (defun c:pa ( / p1 p2 dx dy bp ss mtxt ) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (initget 1) (setq p1 (getpoint "\nFirst point of rectangle : ")) (initget 1) (setq p2 (getcorner p1 "\nSecond point of rectangle : ")) (setq dx (abs (- (car p1) (car p2)))) (setq dy (abs (- (cadr p1) (cadr p2)))) (setq bp (list (min (car p1) (car p2)) (max (cadr p1) (cadr p2)))) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "*TEXT")))) (if (= (cdr (assoc 0 (entget (ssname ss 0)))) "TEXT") (progn (vl-cmdf "_.TXT2MTXT" (ssname ss 0)) (while (< 0 (getvar (quote cmdactive))) (vl-cmdf "") ) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "MTEXT")))) (setq mtxt (ssname ss 0)) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) (progn (setq mtxt (ssname ss 0)) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) ) (princ) ) HTH. M.R. clear 390 / 5.000 Almost there. When I select 3 paragraphs of the same sentence, it only makes the adjustment for the last one. It only recognizes one paragraph at a time, even if I open the window selecting 3 paragraphs. It only converts this last paragraph into mtext, making the adjustment. I believe that the selection by crossing will create the mtext with all the paragraphs and make the adjustment. Can you try this or another way that converts all the paragraphs selected in the window into mtext and make de adjust? I think it would be perfect. Quote
Laranjeira Posted January 22 Author Posted January 22 14 hours ago, BIGAL said: Look at this snippet of code it adjusts the width property. NO error checks is it Mtext. (defun c:mtwid ( / obj dist pt1 pt2) (setq obj (vlax-ename->vla-object (car (entsel "\nPick mtext object ")))) (setq pt1 (vlax-get obj 'insertionpoint)) (setq pt2 (getpoint pt1 "\nDrag for width ")) (setq dist (distance pt1 pt2)) (vlax-put obj 'width dist) (princ) ) t worked as desired, but I have to first transform the texts into mtext, and then use the mtwid command. But once I do that, it works perfectly. I have had a lisp since 1998, txt2mtxt.lsp from Dotsoft that does this conversion, with several options, so I think I can merge it at the beginning of mtwid and get what I need. I will try, but if I can't, I will ask you for help again. Thank you very much for taking the time to help me. Quote
marko_ribar Posted January 22 Posted January 22 (edited) No, you have to use combination of manual edit and automated via LISP... If you have multiple TEXT entities obtained with exploding paragraphed MTEXT, you have to manually use TXT2MTXT command and select all paragraphed TEXT entities... Then when MTEXT is created you use routine to widen paragraphes if you need it that way, but MTEXT won't adjust itself as you have to DDEDIT and manually move each paragraph with "del" key at the end of each paragraph button and then add "space" between words... If you widen MTEXT to fit just single line, then "pa.lsp" should again work as desired... Edited January 22 by marko_ribar Quote
Laranjeira Posted January 22 Author Posted January 22 51 minutes ago, marko_ribar said: No, you have to use combination of manual edit and automated via LISP... If you have multiple TEXT entities obtained with exploding paragraphed MTEXT, you have to manually use TXT2MTXT command and select all paragraphed TEXT entities... Then when MTEXT is created you use routine to widen paragraphes if you need it that way, but MTEXT won't adjust itself as you have to MTEDIT and manually move each paragraph with backspace <- at the end of each paragraph button and then add space between words... If you widen MTEXT to fit just single line, then "pa.lsp" should again work as desired... Marko, for decades I only work with texts. When I receive projects with Mtext, the first thing I do is explode them all up. In my daily work with installation projects, I make dozens, hundreds of text edits, changing gauges, angles, dimensions, numbering, parts of texts in notes, observations, and doing this with mtext is not productive. For these "text" edits, I only use 2 lisps: ChgText.lsp (CT), which changes an old condition for a new one, like 25mm to 35mm. I just give the commands CT, pick text, 25, 35 and it's done in seconds. (There is a variation CTA that does the same thing with attribute values). And the command CHT.lsp, where I select a text and rewrite it completely. Another useful function for my daily work is Lee Mac's Copyswaptext routine. But I also need a lot the PA routine that have to select several paragraphs of 'texts', transform them into mtext using the method that ignores line breaks, make the witdh adjustment, and explode the mtext, probably using the explode last command, returning them to texts. The PA that you provided does this perfectly, as long as I manually convert the paragraphs to mtext ignoring line breaks. So all that is left is to automate the selection of the several paragraphs by opening the window, using I believe the selection by crossing, and convert them into mtext. In this window opening to select the paragraphs, the width for the mtext is also defined. I would really appreciate this help. No rush, I'm working with the old PA but limited to AutoCAD11. Tks Quote
marko_ribar Posted January 22 Posted January 22 All right @Laranjeira Here, try this revision... It should be more powerful than my previous version as it should automatically combine paragraphed TEXT entities obtained from exploded MTEXT entity and then automatically adjust width size just by picking 2 points that define searching rectangle... (defun c:pa ( / *error* LM:UnFormat cmd p1 p2 dx dy bp ss stri mtxt ) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (defun *error* ( m ) (if cmd (setvar (quote cmdecho) cmd) ) (if m (prompt m) ) (princ) ) ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; stri - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( stri mtx / _replace rx ) (defun _replace ( new old stri ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace stri new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq stri (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq stri (_replace (car pair) (cdr pair) stri)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" stri)) (_replace "\\" "\032" stri) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p stri)) stri ) ) ) ) (setq cmd (getvar (quote cmdecho))) (setvar (quote cmdecho) 0) (initget 1) (setq p1 (getpoint "\nFirst point of rectangle : ")) (initget 1) (setq p2 (getcorner p1 "\nSecond point of rectangle : ")) (setq dx (abs (- (car p1) (car p2)))) (setq dy (abs (- (cadr p1) (cadr p2)))) (setq bp (list (min (car p1) (car p2)) (max (cadr p1) (cadr p2)))) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "*TEXT")))) (if (vl-every (function (lambda ( x ) (= (cdr (assoc 0 (entget x))) "TEXT"))) (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))) (progn (vl-cmdf "_.TXT2MTXT" ss) (while (< 0 (getvar (quote cmdactive))) (vl-cmdf "") ) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "MTEXT")))) (setq mtxt (ssname ss 0)) (setq stri (vla-get-textstring (vlax-ename->vla-object mtxt))) (setq stri (LM:UnFormat stri t)) (vlax-put (vlax-ename->vla-object mtxt) (quote textstring) stri) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) (progn (setq mtxt (ssname ss 0)) (setq stri (vla-get-textstring (vlax-ename->vla-object mtxt))) (setq stri (LM:UnFormat stri t)) (vlax-put (vlax-ename->vla-object mtxt) (quote textstring) stri) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) ) (*error* nil) ) HTH. M.R. Quote
Laranjeira Posted January 22 Author Posted January 22 59 minutes ago, marko_ribar said: All right @Laranjeira Here, try this revision... It should be more powerful than my previous version as it should automatically combine paragraphed TEXT entities obtained from exploded MTEXT entity and then automatically adjust width size just by picking 2 points that define searching rectangle... (defun c:pa ( / *error* LM:UnFormat cmd p1 p2 dx dy bp ss stri mtxt ) (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com)) (defun *error* ( m ) (if cmd (setvar (quote cmdecho) cmd) ) (if m (prompt m) ) (princ) ) ;;-------------------=={ UnFormat String }==------------------;; ;; ;; ;; Returns a string with all MText formatting codes removed. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; stri - String to Process ;; ;; mtx - MText Flag (T if string is for use in MText) ;; ;;------------------------------------------------------------;; ;; Returns: String with formatting codes removed ;; ;;------------------------------------------------------------;; (defun LM:UnFormat ( stri mtx / _replace rx ) (defun _replace ( new old stri ) (vlax-put-property rx 'pattern old) (vlax-invoke rx 'replace stri new) ) (if (setq rx (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq stri (vl-catch-all-apply (function (lambda ( ) (vlax-put-property rx 'global actrue) (vlax-put-property rx 'multiline actrue) (vlax-put-property rx 'ignorecase acfalse) (foreach pair '( ("\032" . "\\\\\\\\") (" " . "\\\\P|\\n|\\t") ("$1" . "\\\\(\\\\[ACcFfHLlOopQTW])|\\\\[ACcFfHLlOopQTW][^\\\\;]*;|\\\\[ACcFfHLlOopQTW]") ("$1$2/$3" . "([^\\\\])\\\\S([^;]*)[/#\\^]([^;]*);") ("$1$2" . "\\\\(\\\\S)|[\\\\](})|}") ("$1" . "[\\\\]({)|{") ) (setq stri (_replace (car pair) (cdr pair) stri)) ) (if mtx (_replace "\\\\" "\032" (_replace "\\$1$2$3" "(\\\\[ACcFfHLlOoPpQSTW])|({)|(})" stri)) (_replace "\\" "\032" stri) ) ) ) ) ) (vlax-release-object rx) (if (null (vl-catch-all-error-p stri)) stri ) ) ) ) (setq cmd (getvar (quote cmdecho))) (setvar (quote cmdecho) 0) (initget 1) (setq p1 (getpoint "\nFirst point of rectangle : ")) (initget 1) (setq p2 (getcorner p1 "\nSecond point of rectangle : ")) (setq dx (abs (- (car p1) (car p2)))) (setq dy (abs (- (cadr p1) (cadr p2)))) (setq bp (list (min (car p1) (car p2)) (max (cadr p1) (cadr p2)))) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "*TEXT")))) (if (vl-every (function (lambda ( x ) (= (cdr (assoc 0 (entget x))) "TEXT"))) (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss)))) (progn (vl-cmdf "_.TXT2MTXT" ss) (while (< 0 (getvar (quote cmdactive))) (vl-cmdf "") ) (setq ss (ssget "_CP" (list bp (list (+ (car bp) dx) (cadr bp)) (list (+ (car bp) dx) (- (cadr bp) dy)) (list (car bp) (- (cadr bp) dy))) (list (cons 0 "MTEXT")))) (setq mtxt (ssname ss 0)) (setq stri (vla-get-textstring (vlax-ename->vla-object mtxt))) (setq stri (LM:UnFormat stri t)) (vlax-put (vlax-ename->vla-object mtxt) (quote textstring) stri) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) (progn (setq mtxt (ssname ss 0)) (setq stri (vla-get-textstring (vlax-ename->vla-object mtxt))) (setq stri (LM:UnFormat stri t)) (vlax-put (vlax-ename->vla-object mtxt) (quote textstring) stri) (vlax-put (vlax-ename->vla-object mtxt) (quote width) dx) ) ) (*error* nil) ) HTH. M.R. Simply perfect. Thank you very much. I just added (command "explode" "L"), to make it text again. What happens is that in most of the notes I make, there is a deliberate alignment to the right of the paragraphs following the first one, and mtext does not include this offset. So after making the adjustment with PA, I immediately use another lisp AA (alignment annotation) to align all the following paragraphs to the right. Pick the text that is in the desired alignment, enter, and then pick all the texts that I want to go to that alignment. That's why I need to explode to make it text again. It was perfect. I really appreciate your attention. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.