autocrap Posted July 27, 2010 Share Posted July 27, 2010 (edited) my colleague made this lsip routine to measure and label lines but it does not work, please help. (defun C:LF() (setq en(car (entsel "\n Select Line: "))) (setq enlist(entget en) pt1 (cdr(assoc 10 enlist)) pt2 (cdr(assoc 11 enlist)) ang (angle pt1 pt2) dis (distance pt1 pt2) ) (command "Dtext" (polar (polar pt1 ang (/ dis 2.0)) (+ ang (/ pi 2.0))(* (getvar"ltscale") 0.0625)) (* (getvar"ltscale") 0.09375) (angtos ang) (strcat (rtos (/ dis 12.0) 2 2) "' " (angtos ang)) ) ) Edited July 30, 2010 by autocrap Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted July 27, 2010 Share Posted July 27, 2010 (defun c:lf (/ p1 p2 di ang ins txt) (setq p1 (getpoint "\nspecify first point: ")) (setq p2 (getpoint p1 "\nspecify second point: ")) (setq di (distance p1 p2)) (setq ang (angle p1 p2)) (setq ins (getpoint "\nspecify text location: ")) (setq txt (strcat (rtos di 2 2) "' " (angtos ang))) (command "text" ins 2.5 0 txt) (princ) ) i just modified the one i use. You'll need to modify futher but i think this is easier to understand what's going on. Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 27, 2010 Author Share Posted July 27, 2010 thank you worked perfectly Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 27, 2010 Author Share Posted July 27, 2010 is it possible to get it to write in architectural rather than decimal Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 27, 2010 Share Posted July 27, 2010 Food for thought... (defun c:Test (/ ss) (if (setq ss (ssget '((0 . "LINE")))) ((lambda (i / e l p1 p2 a) (while (setq e (ssname ss (setq i (1+ i)))) (entmake (list '(0 . "TEXT") (cons 10 (mapcar (function (lambda (a b) (/ (+ a b) 2.))) (setq p1 (cdr (assoc 10 (setq l (entget e))))) (setq p2 (cdr (assoc 11 l))) ) ) (cons 40 (getvar 'textsize)) (cons 1 (strcat (rtos (/ (distance p1 p2) 12.) 4 2) "' " (angtos (setq a (angle p1 p2))) ) ) (cons 50 a) ) ) ) ) -1 ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 27, 2010 Share Posted July 27, 2010 Nice coding Alan, this is the only change I would make - hope you don't mind: (defun c:Test (/ ss) ;; AJ Thompson, angle modified by LeeMac (if (setq ss (ssget '((0 . "LINE")))) ((lambda (i / e l p p1 p2 a) (while (setq e (ssname ss (setq i (1+ i)))) (entmake (list '(0 . "TEXT") (cons 10 (setq p ; LM (mapcar (function (lambda (a b) (/ (+ a b) 2.))) (setq p1 (cdr (assoc 10 (setq l (entget e))))) (setq p2 (cdr (assoc 11 l))) ) ) ) (cons 40 (getvar 'textsize)) (cons 1 (strcat (rtos (/ (distance p1 p2) 12.) 4 2) "' " (angtos (setq a (angle p1 p2))) ) ) (cons 50 (LM:MakeReadable a)) ; LM (cons 72 1) ; LM (cons 73 0) ; LM (cons 11 p) ; LM ) ) ) ) -1 ) ) (princ) ) (defun LM:MakeReadable ( a ) ;; © Lee Mac 2010 (cond ( (and (> a (/ pi 2)) (<= a pi)) (- a pi) ) ( (and (> a pi) (<= a (/ (* 3 pi) 2))) (+ a pi) ) ( a ) ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 27, 2010 Share Posted July 27, 2010 Oops. I completely forgot about proper justification and making it readable. Nice work. Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 30, 2010 Author Share Posted July 30, 2010 I have been using "Lt Dan's Leg's" lisp routine, and it works great except for it writes in decimal units, and I need it to write in architectural units. I have already done Format > units and changed them to architectural, but it still writes in decimal. What should I do now? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 30, 2010 Share Posted July 30, 2010 What should I do now? Use mine or Alan's. Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted July 30, 2010 Share Posted July 30, 2010 (defun c:lf (/ p1 p2 di ang ins txt) (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify second point: ")) (setq di (distance p1 p2)) (setq ang (angle p1 p2)) (setq ins (getpoint "\nSpecify text location: ")) (setq txt (strcat (rtos di 4 2) "' " (angtos ang))) ;or (setq txt (strcat (rtos di 4 2) (angtos ang))) (entmake (list '(0 . "text") (cons 1 TXT) (cons 10 ins) (cons 11 ins) (cons 40 2.5) (cons 50 ang) (cons 72 1);replace 1 with 0 for text justification left ) ) (princ) ) I'm finally getting into entmake/mod! Thanks lee and alan ____ sorry for editing so much.. Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 30, 2010 Author Share Posted July 30, 2010 thanks. I hate to ask you guys for more since you have done so much for me already, but is it possible to get your program to write as 10'-6" rather than 10 1/2'. I am a an autolisp newbie and not quite sure how to do it myself Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 30, 2010 Author Share Posted July 30, 2010 oops nevermind I got it Quote Link to comment Share on other sites More sharing options...
autocrap Posted July 30, 2010 Author Share Posted July 30, 2010 thanks for the help everyone Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 30, 2010 Share Posted July 30, 2010 thanks for the help everyone You're quite welcome. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 30, 2010 Share Posted July 30, 2010 thanks for the help everyoneEnjoy... Quote Link to comment Share on other sites More sharing options...
autocrap Posted August 6, 2010 Author Share Posted August 6, 2010 this is Lt Dan's Legs program that I modified. I am having trouble with the second half when i try to input the pipe size when i use the program. (defun c:KB (/ p1 p2 di ins txt) (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify second point: ")) (setq di (distance p1 p2)) (setq ang (angle p1 p2)) (setq ins (getpoint "\nSpecify text location: ")) (setq txt(strcat(rtos di))) (entmake (list '(0 . "text") (cons 1 TXT) (cons 10 ins) (cons 50 ang) (cons 40 2.5) (cons 73 3) (cons 11 ins) ) ) (princ) ;;; Only changes I have made to this point is it doesn't write the angle on the drawing, and the distance is written lower on the drawing. (setq ppt(getkword "\nSpecify pipe size" )) (setq ttx(strcat (rtos ppt))) (entmake (list '(0 . "text") (cons 1 ttx) (cons 10 ins) (cons 50 ang) (cons 40 2.5) (cons 73 1) (cons 11 ins) ) ) (princ) ) please help Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 6, 2010 Share Posted August 6, 2010 use getdist or getreal Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 6, 2010 Share Posted August 6, 2010 this is Lt Dan's Legs program that I modified. I am having trouble with the second half when i try to input the pipe size when i use the program. (defun c:KB (/ p1 p2 di ins txt) (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify second point: ")) (setq di (distance p1 p2)) (setq ang (angle p1 p2)) (setq ins (getpoint "\nSpecify text location: ")) (setq txt(rtos di))[color="red"];<--- strcat deleted[/color] (entmake (list '(0 . "text") (cons 1 TXT) [color="red"](cons 10 ins)[/color]<--- Texts would come above each others[color="red"][/color] (cons 50 ang) (cons 40 2.5) (cons 73 3) [color="red"](cons 11 ins)[/color]<--- Texts would come above each others[color="red"][/color] ) ) (princ) ;;; Only changes I have made to this point is it doesn't write the angle on the drawing, and the distance is written lower on the drawing. (setq ppt([color="red"]getdist[/color] "\nSpecify pipe size" ))[color="red"];<-- This one is modified according to Alanjt idea .[/color] (setq ttx (rtos ppt))[color="red"];<--- strcat deleted[/color] (entmake (list '(0 . "text") (cons 1 ttx) [color="red"] (cons 10 ins)[/color]<--- Texts would come above each others[color="red"][/color] (cons 50 ang) (cons 40 2.5) (cons 73 1) [color="red"](cons 11 ins)[/color];[color="red"]<--- Texts would come above each others[/color] ) ) (princ) ) please help Enjoy it Tharwat Quote Link to comment Share on other sites More sharing options...
autocrap Posted August 6, 2010 Author Share Posted August 6, 2010 thanks, very helpfull. I'm happy it was a simple solution Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 6, 2010 Share Posted August 6, 2010 thanks, very helpfull. I'm happy it was a simple solution I am happy for you that you got worked . Best regards, Tharwat Quote Link to comment Share on other sites More sharing options...
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.