Finding circle of known radius

  • Thread starter Thread starter Frankie Golaub
  • Start date Start date
F

Frankie Golaub

Hi,
I want to create a toggle for scaling a drawing based on the radius of a
circle at a known insertion point. If the radius = 10000.000 then I scale
the drawing to 10001.177 and vice versa.
However, I seem to be having a problem determining the radius of the circle.
My test code is as follows:

(DEFUN GRSCALE ()
(command "layer" "on" "geo" "")
(SETQ SEL (SSGET "X" '((0 . "CIRCLE")(8 . "GEO")(10 329061.399 4772506.537
0.000)))))
(SETQ NA (SSLENGTH SEL))
(SETQ INDEX 0)
(REPEAT NA
(SETQ B1 (ENTGET (SSNAME SEL INDEX)))
(SETQ INDEX (+ INDEX 1))
(SETQ C (ASSOC 40 B1))
(SETQ D (RTOS (CDR C) 2 3))
(IF (= "10001.177" D)
(PROMPT "THIS DRAWING IS SET TO GRIDSCALE" )
)
(IF (= "10000.000" D)
(PROMPT "THIS DRAWING IS SET TO GROUNDSCALE")
)
)
)

My drawing units are set to decimal and are to 3 decimal places. The actual
radii are not exactly 10000.000 and 100001.177 which is why I used RTOS to
round up the figures.
But when I check the entity list the numbers are only one decimal place and
are expressed as engineering units
ie. (10 329061.0 4.77251e+006 0.0) and (40 . 10000.0)
So even though the circle exists I get a nil return.
I think that the problem lies in the different units but i'm not sure how to
get past it.

Thanks In Advance.

Frankie Golaub
 
Frankie,
Instead of using the (rtos), which also uses the value of DIMZIN, why not
use (equal) which allows the use of a "fuzz" factor. For instance:
(equal 1.1750 1.1770 0.003) returns T since the first & second numbers are
equal within the tolerance provied in the third number.

HTH,
Jeff
 
Thanks Jeff,

That seems to work.
I checked out DIMZIN and in this drawing it is set to (9).
Also, I noticed that if I get the entity list of a smaller circle say
1000.153 radius the assoc. code 40 was given as (40 . 1000.15) which tells
me that it only ever displays 6 digits, which explains why my circle had an
entity list of (40 . 10001.2) when the actual radius is
10001.1175456.....etc.

Cheers,

Frankie Golaub.
 
To add to this, Autocad stores and uses ALL reals to 16 significant digits,
whether you can see them or not. So the accuracy of the list is NOT the
problem. However this is exactly why you should use (equal) with a fuzz
factor because as accurate as we try to be, using 16 significant places
introduces small, but noticable, error which will accumulate. Pretty soon
you can have two circles with center points that SHOULD be identical but
they may be off by 0.000000000002. Using (equal cp1 cp2 0.001) will say they
are equal, but using (= cp1 cp2) will say they are not equal......

FYI, a DIMZIN value of 9 means that both bits 1 & 8 are set, bit 8
suppresses trailing zeros.

HTH,
Jeff
 
Back
Top