fathihvac Posted August 3, 2011 Posted August 3, 2011 Hello, Can sombody tell me how to use DTEXT in autolisp to insert:) two or more predeterrmined texts as follows in model space of autocad drawing: (command "dtext" text1 text2 text3.....) The result would be: text1 text2 text3 Quote
MSasu Posted August 3, 2011 Posted August 3, 2011 You should reproduce the prompts of that command as arguments when call the COMMAND function - your code will look like: (foreach TextLabel (list Text1st Text2nd Text3rd) (command "_DTEXT" InsertionPoint TextHeight TextAngle TextLabel) ) Regards, Mircea Quote
eldon Posted August 3, 2011 Posted August 3, 2011 The way I do it is like this: (command "TEXT" pt0 "0.1" "0" eastin) (command "TEXT" "" northin) The second command has a null response for the position ("") and writes it underneath the preceding text. Quote
MSasu Posted August 3, 2011 Posted August 3, 2011 (edited) Nice approach @eldon. You can write that also as: (foreach TextLabel (list Text1st Text2nd Text3rd) (command "_TEXT") (if InsertionPoint (setq InsertionPoint (command InsertionPoint TextHeight TextAngle)) (command "")) (command TextLabel) ) Regards, Mircea Edited August 3, 2011 by MSasu Quote
Lt Dan's legs Posted August 3, 2011 Posted August 3, 2011 (edited) (defun text ( text insertionpoint layer height ) (entmakex (list (cons 0 "text") (cons 1 text);text content (cons 7 "Romans");style (cons 8 layer) (cons 10 insertionpoint) (cons 72 1) (cons 73 2) (cons 40 height) (cons 11 insertionpoint) ) ) ) ( (lambda ( insertionpoint1 insertionpoint2 ) (foreach x (list insertionpoint1 insertionpoint2) (text "testing" x "0" 3.) ) ) (list 0. 0. 0.) (list 0. 4. 0.) ) (vl-load-com) ( (lambda ( ms insertionpoint1 insertionpoint2 ) (foreach x (list insertionpoint1 insertionpoint2) (vla-addtext ms "testing" (vlax-3d-point (trans x 0 1)) 3) ) ) (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) (list 0. 0. 0.) (list 0. 4. 0.) ) Edited August 3, 2011 by Lt Dan's legs Quote
fathihvac Posted August 4, 2011 Author Posted August 4, 2011 many Thanks to everybody. Can we put every text (text1,text2,..) in a different layer. Quote
Lt Dan's legs Posted August 4, 2011 Posted August 4, 2011 (defun text ( text insertionpoint layer height ) (entmakex (list (cons 0 "text") (cons 1 text);text content (cons 7 "Romans");style (cons 8 layer) (cons 10 insertionpoint) (cons 72 1) (cons 73 2) (cons 40 height) (cons 11 insertionpoint) ) ) ) ( (lambda ( insertionpoint1 insertionpoint2 ) (foreach x (list insertionpoint1 insertionpoint2) (text "testing" x "0" 3.) ) ) (list 0. 0. 0.) (list 0. 4. 0.) ) ( (lambda ( pt1 pt2 ) (foreach x (list pt1 pt2) (text "testing" (cdr x) (car x) 3.) ) ) (cons "0" (list 0. 0. 0.)) (cons "Defpoints" (list 0. 4. 0.)) ) (vl-load-com) ( (lambda ( ms pt1 pt2 ) (foreach x (list pt1 pt2) (vla-put-layer (vla-addtext ms "testing" (vlax-3d-point (trans (cdr x) 0 1)) 3) (car x) ) ) ) (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)) ) (cons "0" (list 0. 0. 0.)) (cons "Defpoints" (list 0. 4. 0.)) ) If you are planning on using msasu's example (foreach TextLabel (list Text1st Text2nd Text3rd) (command "_TEXT") (if InsertionPoint (setq InsertionPoint (command InsertionPoint TextHeight TextAngle)) (command "")) (command TextLabel) [color=red][b](and (setq elast (entget (entlast))) (entmod (subst (cons 8 x);put new layer here (assoc 8 elast) elast ) ) [/b][/color][color=red][b] ) [/b][/color]) Quote
BlackBox Posted August 4, 2011 Posted August 4, 2011 > many Thanks to everybody.Can we put every text (text1' date='text2,..) in a different layer.[/quote'] > ... Can we repeat the process 256 times' date=' so that there's 256 text entities on top of eachother, and make each iteration a corresponding color to each of the 256 Standard (non-true color) colors respectively? [i'][/i] Quote
Lt Dan's legs Posted August 4, 2011 Posted August 4, 2011 quotes did not show Renderman.. Did I do something wrong or am I missing something? Quote
BlackBox Posted August 4, 2011 Posted August 4, 2011 quotes did not show Renderman.. Did I do something wrong or am I missing something? Edit: Please disregard, I've got what I came for (a laugh). Cheers! Quote
dbroada Posted August 4, 2011 Posted August 4, 2011 ... Can we repeat the process 256 times, so that there's 256 text entities on top of eachother, and make each iteration a corresponding color to each of the 256 Standard (non-true color) colors respectively? One of our clients specs had something similar to that. I am sure whoever wrote it had just read the AutoCAD manual that says "you can have up to 256 layers and colours" so decided that is what they should use. It was (almost) horizontal lines Quote
fathihvac Posted August 4, 2011 Author Posted August 4, 2011 I did't understand well My goal is to insert two texts text1 and text2 at one time but with two different layers layername1 layername2. Thanks:) Quote
BlackBox Posted August 4, 2011 Posted August 4, 2011 One of our clients specs had something similar to that. I am sure whoever wrote it had just read the AutoCAD manual that says "you can have up to 256 layers and colours" so decided that is what they should use. It was (almost) horizontal lines Whoa... See I was only kidding with LT Dan, as he posted code, received a request for change, and then immediately followed up with revisions. I was imply playing a(n unrelated) prank, hence the last line. LoL I thought proposing such a (ridiculous?) request would be indicate my not being serious... how wrong I was. LoL I did't understand well My goal is to insert two texts text1 and text2 at one time but with two different layers layername1 layername2. Thanks:) Sorry for the confusion, I accept the blame for the unrelated tangent, fathihvac. Quote
MSasu Posted August 4, 2011 Posted August 4, 2011 Can we put every text (text1,text2,..) in a different layer. I will write it like: (foreach TextLabel (list (list Text1st Layer1st) (list Text2nd Layer2nd) (list Text3rd Layer3rd)) (command "_TEXT") (if InsertionPoint (setq InsertionPoint (command InsertionPoint TextHeight TextAngle)) (command "")) (command (car TextLabel) "_CHPROP" (entlast) "" "_LA" (cadr TextLabel) "") ) Regards, Mircea Quote
dbroada Posted August 4, 2011 Posted August 4, 2011 I thought proposing such a (ridiculous?) request would be indicate my not being serious... how wrong I was. LoLSome clients will do anything to delay payment! It was only after submission & rejection of the cad files that this standard was passed from our sales guys to us (not in budget obviously). To redaw to their standard would not have been easy except for this new equipment bit which allowed us to re-submit some very yellow drawings (I think I exploded everything as well as blocks had a different sub section of their standard) very quickly. Quote
Lt Dan's legs Posted August 4, 2011 Posted August 4, 2011 For Renderman (defun rendermanrequest ( text insertionpoint layer color height ) (entmakex (list (cons 0 "text") (cons 1 text);text content (cons 7 "Romans");style (cons 8 layer) (cons 62 color) (cons 10 insertionpoint) (cons 72 1) (cons 73 2) (cons 40 height) (cons 11 insertionpoint) ) ) ) ( (lambda ( co ) (while (>= 256 (setq co (1+ co))) (rendermanrequest (strcat "Color" (itoa co)) (getvar 'viewctr) "0" co 4.) ) ) 0 ) This maybe not be as confusing for you..? (defun text ( text insertionpoint layer height ) (entmakex (list (cons 0 "text") (cons 1 text);text content (cons 7 "Romans");style (cons 8 layer) (cons 10 insertionpoint) (cons 72 1) (cons 73 2) (cons 40 height) (cons 11 insertionpoint) ) ) ) (foreach x (list (list "text #1" (list 0. 4. 0.) "0" 3.) (list "text #2" (list 0. 0. 0.) "Defpoints" 3.) ) (apply (function text) x) ) Quote
fathihvac Posted August 4, 2011 Author Posted August 4, 2011 Thanks msasu it worked for me. Thank you everybody you helped me alot. Quote
MSasu Posted August 4, 2011 Posted August 4, 2011 Thanks msasu it worked for me. You're welcomed! Regards, Mircea Quote
fathihvac Posted August 7, 2011 Author Posted August 7, 2011 Hello, Another question is how to modify spacing between text lines? Quote
Lt Dan's legs Posted August 7, 2011 Posted August 7, 2011 Hello,Another question is how to modify spacing between text lines? (defun text ( text insertionpoint layer height ) (entmakex (list (cons 0 "text") (cons 1 text);text content (cons 7 "Romans");style (cons 8 layer) (cons 10 insertionpoint) (cons 72 1) (cons 73 2) (cons 40 height) (cons 11 insertionpoint) ) ) ) (foreach x (list (list "text #1" [color="red"](list 0. 4. 0.)[/color] "0" 3.) (list "text #2" (list 0. 0. 0.) "Defpoints" 3.) ) (apply (function text) x) ) Or lookup POLAR (Polar point angle distance) 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.