# Thread: can any one give a code to create centerlines for circles(autolisp)

1. ## can any one give a code to create centerlines for circles(autolisp)

Registered forum members do not see this ad.

can any one give a code to create centerlines for circles for autolisp please ?

2. Can you clarify please -
For writing lisp code you need to know exactly what you want, not just a vague idea...

Do you want to make a cross at the center of the circle?

3. yes cross at the center of the circle

4. Since you're learning this in a class you probably want to figure out as much as possible on your own, right?

Did your routine draw this circle? If so you already know the cemter point and the radius. I'll assume this, if not you'll need to first "extract" this information from a circle the user selects.(A separate topic on 'entget').

You could mark the center with 2 short lines. Say the length of each is 1/4 of the radius. using math/algebra, calculate the endpoint coordinates of each line. These coordinates will be used in the "line" command.

Example: Centerpoint is at 100,200, radius is 20. So horizontal line will be 5 units long. Starting x value for line is 100- 5/2=98.5. Start point is 97.5,200; end point is 102.5,200. Create a coordinate "point" with (setq ptStart (list 97.5 200.0)) for the start point. Maybe you can handle from there...if not let us know.

5. i have 15 holes in my drawing, and i wanna create a user prompt, that draws center lines in all holes. the radius of the circle is 15

6. I could keep trying to extract more useful information from you but ...
let's try a different language - lisp. Could you post your code for a partucular task you need help with? We still don't know if circle locations are unknown that the code must find, or if circles were drawn by the routine.

What is the user prompted for - if marks are drawn for ALL circles and ALL are the same size then user input not needed?

7. can i send u the code by pm ?

8. this is the code
Code:
```
(defun flange (/ cen inner outer rad numhole holedia wallthick)
(graphscr)
(setq cen (getpoint "pick centre of flange"))
(terpri)
(setq inner (getdist "pick inner flange radius" cen))
(terpri)
(command "circle" cen inner)
(setq outer (getdist "pick outer flange radius" cen))
(terpri)
(command "circle" cen outer)
(setq wallthick (- outer inner))
(setq rad (+ inner (/ wallthick 2)))
(setq numhole (getint " enter number of bolt holes "))
(terpri)
(setq holedia (* wallthick 0.5))
(terpri)
(princ)
)
(defun insert_hole_pattern (number diam origin rad / count ang_spacing incre_angle)
(setq ang_spacing (/ 360 number))
(setq incre_angle (/ (* ang_spacing pi) 180))
(setq count '1)
(repeat number
(setq centre (polar origin (* count incre_angle) rad))
(command "circle" centre (/ diam 2))
(setq count (1+ count))
)
)```

9. Registered forum members do not see this ad.

Elizabeth
When you post code just use the CODE tags in the editor.
Also I would try an other approach: myself I changed my button macro for the DIMCENTER command to repeat itself. Now I start the command and I click the circles one by one. When I finish I press Esc -it is a bit faster as in the regular way.
Also it is possible to write a lisp to use the DIMCENTER command on all the selected circles or even on all the circles in the drawing.
Well, just my oppinion...