Jump to content

Recommended Posts

Posted (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 by SLW210
ADDED CODE TAGS!!!!!
Posted

Read about the function entmod and look for the dxf 40 for arcs and circles .

 

e.g .

 

(entmod (subst (cons 40 ...........

Posted

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)
)

Posted

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.

Posted
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

Posted

The radinc program works great. Thank you Lee for that.

Posted
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 :)

Posted

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.

Posted
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?

  • 1 year later...
Posted
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..

Posted

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.

Posted
Lee, just a curiosity, why the (if) statement? I would think that the (and) would be inclusive. -David
As 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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...