fcfcadd Posted October 25, 2011 Posted October 25, 2011 (edited) Does anyone have a lisp routine to increase an arc/circle radius/diameter by a specified amount? Or can this lisp routine be modified to be able to specify the amount to increase by rather then the imputing in the actual radius/diameter? (defun C:CHD () (defun c:chd () (quikload "evaluate/chd")) (initget "Radius")(setq DIA (getreal "ENTER THE NEW DIAMETER or (R)adius: (c/r=Exit)")) (cond ((not dia)) ((= DIA "Radius")(setq rad (getreal "\nENTER THE NEW RADIUS :"))) (T (setq rad (/ dia 2.0))) ) (if dia (progn (prompt "\nSELECT ENTITIES TO BE CHANGED (FILTERS CIRCLES/ARCS)") (setq A (ssget (list (cons 0 "CIRCLE,ARC")))) (setq B (if A (sslength A) 0) X 0) (while (< X B)(progn (setq NAME (ssname A X)) (dotsubst 40 RAD name T T) (setq X (1+ X)) )) )) ) (c:chd) Edited November 27, 2012 by SLW210 ADDED CODE TAGS!!!!! Quote
Tharwat Posted October 25, 2011 Posted October 25, 2011 Read about the function entmod and look for the dxf 40 for arcs and circles . e.g . (entmod (subst (cons 40 ........... Quote
DANIEL Posted October 25, 2011 Posted October 25, 2011 might want take a ganger at the code posting guidlines and edit your post before a mod gets here. http://www.cadtutor.net/forum/showthread.php?9184-Code-posting-guidelines Quote
Lee Mac Posted October 25, 2011 Posted October 25, 2011 Quick one: (defun c:radinc ( / e d s ) (if (and (setq s (ssget "_:L" '((0 . "ARC,CIRCLE")))) (setq d (getdist "\nSpecify Addition: ")) ) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (entmod (subst (cons 40 (+ (cdr (assoc 40 e)) d)) (assoc 40 e) e)) ) ) (princ) ) Quote
fcfcadd Posted October 25, 2011 Author Posted October 25, 2011 My bad on the posting of the code. Never posted code here before so I didn't know. I'm not very good at modifying lisp so I leave that to the pro's. I will give this radinc a try and see how it works for me. Quote
David Bethel Posted October 25, 2011 Posted October 25, 2011 Quick one: (defun c:radinc ( / e d s ) (if (and (setq s (ssget "_:L" '((0 . "ARC,CIRCLE")))) (setq d (getdist "\nSpecify Addition: ")) ) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (entmod (subst (cons 40 (+ (cdr (assoc 40 e)) d)) (assoc 40 e) e)) ) ) (princ) ) Lee, just a curiosity, why the (if) statement? I would think that the (and) would be inclusive. -David Quote
fcfcadd Posted October 25, 2011 Author Posted October 25, 2011 The radinc program works great. Thank you Lee for that. Quote
Lee Mac Posted October 25, 2011 Posted October 25, 2011 Lee, just a curiosity, why the (if) statement? I would think that the (and) would be inclusive. -David I feel the (if) is far more readable than solely (and), and also semantically correct. To me, it reads better: "IF (this) AND (this), DO (this)", as opposed to "(this) AND (this) AND (this)". I tend to reserve (and/or/not) for when I require a boolean return. The radinc program works great. Thank you Lee for that. You're welcome Quote
BIGAL Posted October 26, 2011 Posted October 26, 2011 AlanJt wrote a arc program quite some time ago based around the idea of a seed radius then change the rad by a set +- value its dynamic you drag the radius I know I posted my version and AlanJT updated to a smarter version. Now where is it. Quote
SLW210 Posted October 26, 2011 Posted October 26, 2011 My bad on the posting of the code. Never posted code here before so I didn't know. I'm not very good at modifying lisp so I leave that to the pro's. I will give this radinc a try and see how it works for me. What is preventing you from editing your post? Quote
Ahmeds Posted November 23, 2012 Posted November 23, 2012 Quick one: (defun c:radinc ( / e d s ) (if (and (setq s (ssget "_:L" '((0 . "ARC,CIRCLE")))) (setq d (getdist "\nSpecify Addition: ")) ) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (entmod (subst (cons 40 (+ (cdr (assoc 40 e)) d)) (assoc 40 e) e)) ) ) (princ) ) Hi Lee... May I ask what about if I want is the exact radius to be.. which line of this code should I change? Thank you again for so many helpful routines you've posted, more power to you.. Quote
irneb Posted November 23, 2012 Posted November 23, 2012 You could of course just use the Properties Palette for that. If you do want the lisp change: Look at where the old radius is added to the input distance. It's the portion starting with (+ ... count the open and close parentheses so the one just before the + has a matching close. Then you know where the + function ends. Replace that with just the variable name of the input value: in this case d. Quote
irneb Posted November 23, 2012 Posted November 23, 2012 Lee, just a curiosity, why the (if) statement? I would think that the (and) would be inclusive. -DavidAs lee's said ... it's semantics, but also more "logical" and "readable". I tend to reserve (and/or/not) for when I require a boolean return.That's perfect for AutoLisp. If it was some "true" lisp dialect like Common Lisp / Scheme, then it is not so meaningful anymore. Those define and to return the last value if none of the arguments are nil. I think we had a thread about this before somewhere. 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.