View Full Version : can any one give a code to create centerlines for circles(autolisp)
31st Oct 2006, 01:08 am
can any one give a code to create centerlines for circles for autolisp please ?
31st Oct 2006, 01:12 am
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?
31st Oct 2006, 01:32 am
yes cross at the center of the circle
31st Oct 2006, 01:52 am
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.
31st Oct 2006, 02:02 am
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
31st Oct 2006, 02:32 am
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?
31st Oct 2006, 03:17 am
can i send u the code by pm ?
31st Oct 2006, 03:18 am
this is the code
(defun flange (/ cen inner outer rad numhole holedia wallthick)
(setq cen (getpoint "pick centre of flange"))
(setq inner (getdist "pick inner flange radius" cen))
(command "circle" cen inner)
(setq outer (getdist "pick outer flange radius" cen))
(command "circle" cen outer)
(setq wallthick (- outer inner))
(setq rad (+ inner (/ wallthick 2)))
(setq numhole (getint " enter number of bolt holes "))
(setq holedia (* wallthick 0.5))
(insert_hole_pattern numhole holedia cen rad)
(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)
(setq centre (polar origin (* count incre_angle) rad))
(command "circle" centre (/ diam 2))
(setq count (1+ count))
31st Oct 2006, 05:34 am
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...
I adjusted your previous message. It shows better now isn't it?
Powered by vBulletin™ Version 4.1.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.