Lisp that counts the # of 5" rad Circles found in a drawing

Status
Not open for further replies.

shish

Usenet Archive
Joined
Jan 15, 2002
Messages
9
Reaction score
0
I am trying to make a lisp that cound the about of circles found in a drawing with a certain radius (variable). Can someone help me get started on such a lisp. Thanks.
 
On Mon, 21 Jan 2002 10:19:41 -0500, "shish"
wrote:

I am trying to make a lisp that cound the about of circles found in a drawing with a certain radius (variable). Can someone help me get started on such a lisp. Thanks.

nope ... but if it's not intended to form part of a longer lisp program ... you can simply use the filter and list commands to count them ...

colinfindlay
 
shish schrieb:
I am trying to make a lisp that cound the about of circles found in a drawing with a certain radius (variable). Can someone help me get started on such a lisp. Thanks.

(ssget "X" '((0 . "CIRCLE") (40 . 5))) ;;; (DXF code for radius is 40, isn't it?)

Tom Berger
 
Thanks that almost what I wanted. This will help me get started. Now I just have to figure out how to this with a variable radius, that would be inputted by the user.

"Tom Berger" wrote:

shish schrieb:
>
> I am trying to make a lisp that cound the about of circles found in a
> drawing with a certain radius (variable). Can someone help me get
started
> on such a lisp. Thanks.

(ssget "X" '((0 . "CIRCLE") (40 . 5))) ;;; (DXF code for radius is 40, isn't it?)

Tom Berger
 
Filer command works good but too slow, for what I am doing.

I need a list for a repetitive task that I often do. I need to make a lisp that will allow me to pick a variable radius.
"Dave Jones" wrote:

It's already done for you...just use a FILTER
started
> on such a lisp. Thanks.
>
>
 
shish schrieb:
Thanks that almost what I wanted. This will help me get started. Now I just have to figure out how to this with a variable radius, that would be inputted by the user.

(setq radius 5.0)
(ssget "X" (list
'(0 . "CIRCLE")
(cons 40 radius)
))

You can even filter for radiusses greater than A and smaller than B with special boolean filter-dxf-codes. Your online help will tell you more ...

Tom Berger
 
(setq rad (getdist "\Radius to find: ")
ss (ssget "X" (list '(0 . "CIRCLE")(cons 40 rad))) )
___

"shish" wrote:

Thanks that almost what I wanted. This will help me get started. Now I just have to figure out how to this with a variable radius, that
would
be inputted by the user.
 
(defun C:RADCT (/ rad ss count)
(setq rad (getdist "\nRadius to count: ")
ss (ssget "X" (list '(0 . "CIRCLE")(cons 40 rad))) count (sslength ss) ) (alert (strcat (itoa count) " " (rtos rad) " radius circles found.")) (princ) )
___

"shish" wrote:

Filer command works good but too slow, for what I am doing.

I need a list for a repetitive task that I often do. I need to make a lisp that will allow me to pick a variable radius.
"Dave Jones" wrote:

> It's already done for you...just use a FILTER
> --
> Dave
> "shish" wrote:
>
> > I am trying to make a lisp that cound the about of circles found in a ...
 
Would it be a lot harder to make this lisp select these circles in a selected area of a drawing.

"Tom Berger" wrote:

shish schrieb:
>
> Thanks that almost what I wanted. This will help me get started.
> Now I just have to figure out how to this with a variable radius, that
would
> be inputted by the user.

(setq radius 5.0)
(ssget "X" (list
'(0 . "CIRCLE")
(cons 40 radius)
))

You can even filter for radiusses greater than A and smaller than B with special boolean filter-dxf-codes. Your online help will tell you more ...

...
 
shish schrieb:

Would it be a lot harder to make this lisp select these circles in a selected area of a drawing.

Simply remove "X" from the code. Then you get the famous "select objects: " prompt which allows you to select via window, crossing, previous etc ...

Tom Berger
 
"Tom Berger" wrote:

shish schrieb:

> Would it be a lot harder to make this lisp select these circles in a
> selected area of a drawing.

Simply remove "X" from the code. Then you get the famous "select objects: " prompt which allows you to select via window, crossing, previous etc ...

Tom Berger
 
Why does this lisp work great with (ssget "X" )
but if I try to use crossing (ssget "C") it gives me an error?

(defun C:ttff (/ )
(while (not (setq frst (entsel "\nPick a First circle: ")))) (setq radc (cdr (assoc 40 (entget (entlast))))) (setq ss (ssget "C" (list '(0 . "CIRCLE")(cons 40 radc))) count (sslength ss) )(setq diac (* 2 radc)) (alert (strcat (itoa count) " Circles found @ " (rtos diac) "Dia")) (princ)
)

"Paul Turvill" wrote:

(setq rad (getdist "\Radius to find: ")
ss (ssget "X" (list '(0 . "CIRCLE")(cons 40 rad))) )
___

"shish" wrote:

> Thanks that almost what I wanted. This will help me get started.
> Now I just have to figure out how to this with a variable radius, that would
> be inputted by the user.
 
shish schrieb:
Why does this lisp work great with (ssget "X" )
but if I try to use crossing (ssget "C") it gives me an error?

SSGET is missing the coordinates of your crossing window.

Try: (ssget "c" pt1 pt2 '((0 . "CIRCLE")))

Tom Berger
 
"shish" wrote:

Why does this lisp work great with (ssget "X" )
but if I try to use crossing (ssget "C") it gives me an error?

(defun C:ttff (/ )
(while (not (setq frst (entsel "\nPick a First circle: ")))) (setq radc (cdr (assoc 40 (entget (entlast))))) (setq ss (ssget "C" (list '(0 . "CIRCLE")(cons 40 radc))) count (sslength ss) )(setq diac (* 2 radc)) (alert (strcat (itoa count) " Circles found @ " (rtos diac)
"Dia"))
(princ)
)

"Paul Turvill" wrote:

> (setq rad (getdist "\Radius to find: ")
> ss (ssget "X" (list '(0 . "CIRCLE")(cons 40 rad)))
> )
> ___
>
> "shish" wrote:
...

If you specify the Crossing "C", you have to specify the corner points of the crossing window. If you want the user to pick them, then just leave it out.

You also need to use the circle you picked in your code, not the last one drawn. You should also localize variables, and check your input.

Here's some updated code:

(defun C:ttff ( / frst radc ss diac)
(while (not (setq frst (entsel "\nPick a First circle: ")))) (if frst (setq radc (cdr (assoc 40 (car frst)))) ; USE THE RAD OF THE SELECTED CIRCLE (setq ss (ssget (list '(0 . "CIRCLE")(cons 40 radc))) count (sslength ss) ) (setq diac (* 2.0 radc)) (alert (strcat (itoa count) " Circles found at " (rtos diac) " Dia")) ) ) (princ)
)

There are a few other errors, for example, it will crash if someone picks a line or block. I'll leave those as an exercise for the student...

- Aaron

-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
 
Status
Not open for further replies.

Latest threads

Back
Top