Peri Posted December 6, 2010 Share Posted December 6, 2010 I find myself once again in the need of help from experts like you. I think the LISP I want is simple, if it can be done. I have a drawing which has some lines drawn in it and a value writen by each line. This text shows the diameter of a pipe (the lines drawn are pipes). The text is a simple text, not an attribute. As you may have guessed, there are hundreds of tubes with diferent diameters. The LISP I need is as follows: I click on the text - it reads the content which is always a number - divide the value by 2 - click on the line - offset this last value to each side and then delete the middle line - end command. With this LISP I'll just go around clicking like a madman untill all my lines show the diameter of the tubes. Thanks in advance, Rodrigo Quote Link to comment Share on other sites More sharing options...
JPlanera Posted December 6, 2010 Share Posted December 6, 2010 This will do what you want, but it wont allow you to pick text. YOu will have to enter the diameter manually. It should get you where you want for now until someone can revise this code... (defun c:DOF (/ a b b1 p1 d pckbox) (setq d 20 p1 nil pee (/ pi 2)e 3 pckbox (getvar "pickbox")line " ") (princ "\nEnter Pipe Diameter <") (setq answer(getreal ">: ")) (setq answer2(/ answer 2)) (princ line) (setvar "pickbox" pckbox) (setq ent(entsel "\nPick the line: ")) (setvar "pickbox" 2) (setq point(cadr ent)) (princ line) (setq side(getpoint "\nPick an offset side: ")) (setq dist(distance side point))(setq ang(angle side point)) (if(or(or(< ang 0.78)(> ang 5.5))(and(> ang 2.35)(< ang 3.92))) (setq ang(- 0 ang))(setq ang(- pi ang)) );end if (setq other(polar point ang dist)) (command "offset" answer2 ent side ent other "") (entdel(car ent)) (setvar "pickbox" pckbox) (prin1) ) Quote Link to comment Share on other sites More sharing options...
Peri Posted December 6, 2010 Author Share Posted December 6, 2010 This will do what you want, but it wont allow you to pick text. YOu will have to enter the diameter manually. It should get you where you want for now until someone can revise this code... (defun c:DOF (/ a b b1 p1 d pckbox) (setq d 20 p1 nil pee (/ pi 2)e 3 pckbox (getvar "pickbox")line " ") (princ "\nEnter Pipe Diameter <") (setq answer(getreal ">: ")) (setq answer2(/ answer 2)) (princ line) (setvar "pickbox" pckbox) (setq ent(entsel "\nPick the line: ")) (setvar "pickbox" 2) (setq point(cadr ent)) (princ line) (setq side(getpoint "\nPick an offset side: ")) (setq dist(distance side point))(setq ang(angle side point)) (if(or(or(< ang 0.78)(> ang 5.5))(and(> ang 2.35)(< ang 3.92))) (setq ang(- 0 ang))(setq ang(- pi ang)) );end if (setq other(polar point ang dist)) (command "offset" answer2 ent side ent other "") (entdel(car ent)) (setvar "pickbox" pckbox) (prin1) ) Thanks for the quick reply! I'll try this now! Quote Link to comment Share on other sites More sharing options...
Cad64 Posted December 6, 2010 Share Posted December 6, 2010 You'll get more responses if you post your question in the lisp section. I've moved this thread there for you. Quote Link to comment Share on other sites More sharing options...
alanjt Posted December 6, 2010 Share Posted December 6, 2010 I love how people speak of a routine being simple to write, but wouldn't imagine learning who to write it themselves. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted December 6, 2010 Share Posted December 6, 2010 I think I'd lean more towards entmake as picking points via the OFFSET command can lead to errors [b][color=BLACK]([/color][/b]defun c:offtxt [b][color=FUCHSIA]([/color][/b]/ tx tv ss en ed p10 p11 p20 p21 p30 p31 fd sd[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not tx[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]/= [b][color=GREEN]([/color][/b]sslength tx[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]<= [b][color=GREEN]([/color][/b]setq tv [b][color=BLUE]([/color][/b]atof [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc 1 [b][color=TEAL]([/color][/b]entget [b][color=OLIVE]([/color][/b]ssname tx 0[b][color=OLIVE])[/color][/b][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] 0.[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect Numeric Text To Read..."[/color][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq tx [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"*TEXT"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]/= [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect Line To Offset..."[/color][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq en [b][color=NAVY]([/color][/b]ssname ss 0[b][color=NAVY])[/color][/b] ed [b][color=NAVY]([/color][/b]entget en[b][color=NAVY])[/color][/b] p10 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 10 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p11 [b][color=NAVY]([/color][/b]cdr [b][color=MAROON]([/color][/b]assoc 11 ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p20 [b][color=NAVY]([/color][/b]polar p10 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p10 p11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* tv 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p30 [b][color=NAVY]([/color][/b]polar p10 [b][color=MAROON]([/color][/b]- [b][color=GREEN]([/color][/b]angle p10 p11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* tv 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p21 [b][color=NAVY]([/color][/b]polar p11 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p10 p11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* tv 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] p31 [b][color=NAVY]([/color][/b]polar p11 [b][color=MAROON]([/color][/b]- [b][color=GREEN]([/color][/b]angle p10 p11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* tv 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] fd [b][color=NAVY]([/color][/b]subst [b][color=MAROON]([/color][/b]cons 10 p20[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]assoc 10 ed[b][color=MAROON])[/color][/b] ed[b][color=NAVY])[/color][/b] fd [b][color=NAVY]([/color][/b]subst [b][color=MAROON]([/color][/b]cons 11 p21[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]assoc 11 ed[b][color=MAROON])[/color][/b] fd[b][color=NAVY])[/color][/b] sd [b][color=NAVY]([/color][/b]subst [b][color=MAROON]([/color][/b]cons 10 p30[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]assoc 10 ed[b][color=MAROON])[/color][/b] ed[b][color=NAVY])[/color][/b] sd [b][color=NAVY]([/color][/b]subst [b][color=MAROON]([/color][/b]cons 11 p31[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]assoc 11 ed[b][color=MAROON])[/color][/b] sd[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake fd[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake sd[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entdel en[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]redraw[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
JPlanera Posted December 6, 2010 Share Posted December 6, 2010 Hmm.. I like it. Thanks for the update! Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted December 6, 2010 Share Posted December 6, 2010 (defun c:simple (/ line ent id ss di p1 p2) (defun line (ang) (entmake (list (cons 0 "line") (cons 8 (cdr (assoc 8 lss))) (cons 10 (polar (setq p1 (cdr (assoc 10 lss)))(+ (angtof ang) (angle p1 (setq p2 (cdr (assoc 11 lss)))))(* 0.5 di))) (cons 11 (polar p2 (+ (angtof ang)(angle p1 p2)) (* 0.5 di))) ) ) ) (while (not (and (setq ent (car (entsel "\nSelect distance to offset (text only): "))) (eq "TEXT" (cdr (assoc 0 (setq ent (entget ent))))) (setq di (distof (cdr (assoc 1 ent)))) ) ) (prompt "\nPlease select a single line text with a numerical value!") ) (prompt "\nSelect lines to offset: ") (setvar 'nomutt 1) (if (setq ss (ssget '((0 . "line")))) (progn (setvar 'nomutt 0) (repeat (setq id (sslength ss)) (setq lss (entget (ssname ss (setq id (1- id))))) (line "90.000000") (line "270.000000") (entdel (cdr (assoc -1 lss))) ) ) (progn (setvar 'nomutt 0) (prompt "\nNo lines selected!") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
stevesfr Posted December 7, 2010 Share Posted December 7, 2010 For those of us who have their drawing set up in units of feet, where in the program can we devide the picked "text" by 12 so the program recognizes the picked text as inches. thx Steve Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 7, 2010 Share Posted December 7, 2010 David Bethels (* tv 0.5) this is offset Lt Dans Legs (* 0.5 di) same thing (/ (* 0.5 di) 12.0)) Quote Link to comment Share on other sites More sharing options...
stevesfr Posted December 7, 2010 Share Posted December 7, 2010 David Bethels (* tv 0.5) this is offset Lt Dans Legs (* 0.5 di) same thing (/ (* 0.5 di) 12.0)) Thx AL, I was trying to figure out how to divide the pick text by twelve. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted December 7, 2010 Share Posted December 7, 2010 (setq di (distof (cdr (assoc 1 ent)))) You got to be careful with ( distof ) If the text is in architectural and UNITS is decimal' date=' the return can be nil [/code'] (setvat "UNITS" 2) (distof "1'-0") [/code] Also what happens to color (62) thinckness (39) linetype (6) UCS ( 210) etc -David 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.