+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Junior Member
    Using
    Civil 3D 2006
    Join Date
    Oct 2006
    Posts
    16

    Default 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 ?
    Last edited by elizabeth; 31st Oct 2006 at 03:33 pm.

  2. #2
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    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. #3
    Junior Member
    Using
    Civil 3D 2006
    Join Date
    Oct 2006
    Posts
    16

    Default

    yes cross at the center of the circle

  4. #4
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    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. #5
    Junior Member
    Using
    Civil 3D 2006
    Join Date
    Oct 2006
    Posts
    16

    Default

    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. #6
    Forum Deity
    Using
    not specified
    Join Date
    Jul 2004
    Location
    Anchorage, Alaska
    Posts
    2,074

    Default

    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. #7
    Junior Member
    Using
    Civil 3D 2006
    Join Date
    Oct 2006
    Posts
    16

    Default

    can i send u the code by pm ?

  8. #8
    Junior Member
    Using
    Civil 3D 2006
    Join Date
    Oct 2006
    Posts
    16

    Default

    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)
      (insert_hole_pattern numhole holedia cen rad)
      (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))
      )
    )
    Last edited by fuccaro; 31st Oct 2006 at 05:40 am.

  9. #9
    Super Moderator fuccaro's Avatar
    Using
    AutoCAD 2006
    Join Date
    Nov 2002
    Location
    Romania, Marosvasarhely
    Posts
    3,540

    Default

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

    I adjusted your previous message. It shows better now isn't it?
    Last edited by fuccaro; 31st Oct 2006 at 05:42 am.
    It's nice to be nice, but sometimes is nicer to be evil!.
    Tip: Please do not PM or email me with CAD questions - use the forums, you'll get an answer sooner.

Similar Threads

  1. create an NC code
    By raedbenz in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 5th Apr 2006, 09:09 pm
  2. Simple AutoLISP, draw circles from file
    By malpass in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 27th Jul 2005, 03:26 pm
  3. Pls give me a hint
    By Alexandra in forum AutoCAD General
    Replies: 11
    Last Post: 26th May 2004, 03:45 pm
  4. Pediting (Please: Anyone who can give any advise do so.)
    By Bucky in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 25th Mar 2004, 10:02 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts