erbalaji Posted February 22, 2019 Posted February 22, 2019 Hi Writers! here i am again with new question. I am looking for a lisp to Offset line by a selection set values. i really wanted to get an intersection point after offsetting so that i can draw circle at each intersection. but i have values till outer of circle, i know the radius of circle. Process may be like this. Select Values Get Circle radius from user add with selected values select Line offset in positive direction by added values repeat once to offset another line. please help me to find a lisp. Thank you.. Quote
BIGAL Posted February 24, 2019 Posted February 24, 2019 (edited) This is a pretty easy task and a good task for learning lisp etc. Just look at some of the code examples here and you will find all the answers. It is better to see people having a go rather then just go to Cadtutor and doing the lazy some one there will write the code for you. Here is the method with the lisp commands highlited. Select text Entsel use assoc 1 to get text convert to a number atof txt Get radius getreal or getdist Comand offset pick line pick side getpoint. Save the new line's entityname entlast repeat offset for second line Use inters to find intersection point Command Erase the two offset lines using the entity name and entlast Command circle using the intersection point and rad To do positive side of picked line requires a bit more code where you check which end of a line you picked and can then work out left and right. Lastly search for offset here so many lisp examples. Edited February 24, 2019 by BIGAL Quote
erbalaji Posted February 26, 2019 Author Posted February 26, 2019 (edited) thank you! i came up with this coding please check. i want to re run this program by getting a key word from user. (yes/No) please explain how to do without terminating. i need to add intersections after that. (defun c:TEST (/) (vl-load-com) (setq temperr *error*) ;store *error* (setq *error* trap1) ;re-assign *error* (setq oldecho (getvar "cmdecho")) ;store variables (setq oldlayer (getvar "clayer")) (setq oldsnap (getvar "osmode")) (setvar "cmdecho" 0) ;reset variables (setvar "osmode" 32) (command "undo" "m") (command "layer" "make" "INT" "color" "160" "" "") (princ "\nSelect Bottom/Side/Vertical Line: ") (setq o (ssget)) (setq s (getpoint "\nPick Offset side")) (setq ra (getreal "\nEnter Duct Radius: ")) (setq gr (ssget '((0 . "TEXT")))) (setq x1 (sslength gr)) (cond ((= 1 x1) (setq b1 (cdr (assoc 1 (entget (ssname gr 0)))) c1 (+ ra (atof b1)) ) ) ((= 2 x1) (setq b1 (cdr (assoc 1 (entget (ssname gr 0)))) c1 (+ ra (atof b1)) b2 (cdr (assoc 1 (entget (ssname gr 1)))) c2 (+ ra (atof b2)) ) ) ((= 3 x1) (setq b1 (cdr (assoc 1 (entget (ssname gr 0)))) c1 (+ ra (atof b1)) b2 (cdr (assoc 1 (entget (ssname gr 1)))) c2 (+ ra (atof b2)) b3 (cdr (assoc 1 (entget (ssname gr 2)))) c3 (+ ra (atof b3)) ) ) ((= 4 x1) (setq b1 (cdr (assoc 1 (entget (ssname gr 0)))) c1 (+ ra (atof b1)) b2 (cdr (assoc 1 (entget (ssname gr 1)))) c2 (+ ra (atof b2)) b3 (cdr (assoc 1 (entget (ssname gr 2)))) c3 (+ ra (atof b3)) b4 (cdr (assoc 1 (entget (ssname gr 3)))) c4 (+ ra (atof b4)) ) ) ) (setq x1 (sslength gr)) (cond ((= 1 x1) (progn (command "OFFSET" c1 o s "")) ) ((= 2 x1) (progn (command "OFFSET" c1 o s "") (command "OFFSET" c2 o s "")) ) ((= 3 x1) (progn (command "OFFSET" c1 o s "") (command "OFFSET" c2 o s "") (command "OFFSET" c3 o s "")) ) ((= 4 x1) (progn (command "OFFSET" c1 o s "") (command "OFFSET" c2 o s "") (command "OFFSET" c3 o s "") (command "OFFSET" c4 o s "")) ) ) (setvar "clayer" oldlayer) ;reset variables (setvar "osmode" oldsnap) (setvar "cmdecho" oldecho) (setq *error* temperr) (princ) ) Edited February 26, 2019 by erbalaji coding revised Quote
BIGAL Posted February 26, 2019 Posted February 26, 2019 (edited) Glad you got something together happy to help, nice use of the cond to work out how many text picked. , I added a While just press enter to exit, did not test as need your dwg, also change 1st pick line to Entsel a it is only 1 object. Need a before & after picture, dwg would be best. Are you wanting to do others side as well (command "layer" "make" "INT" "color" "160" "" "") (while (setq o (entsel "Select Bottom/Side/Vertical Line: ")) (setq s (getpoint "\nPick Offset side")) .......... ........ ) ) ; end while (setvar "clayer" oldlayer) Edited February 26, 2019 by BIGAL Quote
erbalaji Posted February 27, 2019 Author Posted February 27, 2019 thank you for your input. it would be more convenient if the user chooses to use offset or not! if yes then repeat if no then need to go for finding intersections. please give me a hint to combine programs. Quote
BIGAL Posted February 28, 2019 Posted February 28, 2019 (edited) Please post some examples. Dwg is best we are guessing what you want. Edited February 28, 2019 by BIGAL Quote
erbalaji Posted February 28, 2019 Author Posted February 28, 2019 (defun TSE (/) (sub function) ) (defun c:TSS (/ ans ans1) (vl-load-com) (setq temperr *error*) ;store *error* (setq *error* trap1) ;re-assign *error* (setq oldecho (getvar "cmdecho")) ;store variables (setq oldlayer (getvar "clayer")) (setq oldsnap (getvar "osmode")) (setvar "cmdecho" 0) ;reset variables (setvar "osmode" 32) (command "undo" "m") (command "layer" "make" "INT" "color" "160" "" "") (command "OFFSET" l c "" "") (command (TSE)) ;blind run of sub function (initget 1 "YES NO") (setq ans (getkword "\nWant to Offset [Yes/No]: ")) ;first yes/no (cond ((= "YES" ans) (command (TSE)) ) ((= "NO" ans) (command (COL-IT)) ) ) (command "OFFSET" l c "" "") (initget 1 "YES NO") (setq ans1 (getkword "\nWant to Offset [Yes/No]: ")) ;second yes/no here if the user chooses yes above sub function (COL-IT) will not run hence this entire program fails. (cond ((= "YES" ans1) (command (TSE)) ) ((= "NO" ans1) (command (COL-IT)) ) ) (setvar "clayer" oldlayer) ;reset variables (setvar "osmode" oldsnap) (setvar "cmdecho" oldecho) (setq *error* temperr) (princ) ) 2 hours ago, BIGAL said: Please post some examples. Dwg is best we are guessing what you want. Please see the code below attached i want to use repeat the program until the user wants to. i did something nasty. please check. below here entire lisp attached. TSS.LSP 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.