drawing a line with poar coordinates help!

Discussion in 'AutoCAD' started by Casey Roberts, Aug 20, 2004.

  1. I am writing a routine that will draw a line from a user selected point to
    another user selected point, except a set distance smaller on each end.

    For example,

    If user selects first point at 0,0,0 and then the second point at 0,5000,0,
    the routine would draw a line from 0,300,0 to 0,4700,0.

    Can someone give me a nudge in the right direction?

    Thanks,


    Casey
     
    Casey Roberts, Aug 20, 2004
    #1
  2. Casey Roberts

    larry Guest

    This should work because I am not sure what wrong with your lisp, if it do
    not let me know.


    (defun c:line-draw (/ acadDocument mspace point1 point2 myLine)

    (vl-load-com)

    (setq acadDocument (vla-get-activedocument (vlax-get-acad-object)))

    (setq mspace (vla-get-modelspace acadDocument))

    (setq point1 (getpoint "Specify First Point: "))

    (setq point2 (getpoint "Specify next point: " point1))

    (setq myLine (vla-addline mspace (vlax-3d-point point1)(vlax-3d-point
    point2))))
     
    larry, Aug 20, 2004
    #2
  3. Casey Roberts

    Jim Claypool Guest

    (setq pt1 '(0 0 0))
    (setq pt2 '(0 5000 0))
    (setq ang (angle pt1 pt2))
    (setq pt1 (polar pt1 ang 300))
    (setq pt2 (polar pt2 ang -300))
    (command ".line" pt1 pt2 "")
     
    Jim Claypool, Aug 20, 2004
    #3
  4. Casey Roberts

    larry Guest

    sorry i did not see (with poar)
    you will need to send me the lisp
     
    larry, Aug 20, 2004
    #4
  5. Casey Roberts

    Paul Turvill Guest

    After the user supplies the points, you can calculate the angle of the
    desired line, then define the line's endpoints with the (polar ...)
    function:

    (setq p1 (getpoint "\nFirst point: ")
    p2 (getpoint "\nSecond point: ")
    StartPoint (polar p1 (angle p1 p2) 300)
    EndPoint (polar p2 (angle p2 p1) 300)
    )

    .... now construct your line from StartPoint to EndPoint.
    ___
     
    Paul Turvill, Aug 20, 2004
    #5
  6. Thanks Jim, I guess I should have just looked in the help file before just
    posting in the news group but I have another question that is an extension
    of this one. My current routine is as follows:

    (defun c:bline ()
    (setq p1 (getpoint "First Point"))
    (setq p2 (getpoint "Second Point"))
    (setq oldosm (getvar "OSMODE"))
    (setvar "OSMODE" 0)
    (setq ang (angle p1 p2))
    (setq point1 (polar p1 ang 300))
    (setq point2 (polar p1 ang (- (distance p1 p2) 300)))
    (command "line" point1 point2 "")
    (SETVAR "OSMODE" OLDOSM)
    )

    My question is, how do I modify this so that I can use it like the regular
    line command in the sense that I don't have to re-initiate the command after
    each line segment. In other words, I want to pick the first point, then the
    second, (draw line segment) then pick a third (draw line segment) then a 4th
    and so on untill I right click or hit enter to end the command.

    TIA

    Casey
     
    Casey Roberts, Aug 20, 2004
    #6
  7. Casey Roberts

    Paul Turvill Guest

    Continue with something like:

    (while (setq p3 (getpoint "\nNext point (ENTER when done): "))
    (setq p1 p2
    p2 p3
    StartPoint (polar p1 (angle p1 p2) 300)
    StartPoint (polar p2 (angle p2 p1) 300)
    );;setq
    (command "_.line" Startpoint Endpoint "")
    );;while
    ___
     
    Paul Turvill, Aug 20, 2004
    #7
  8. Casey Roberts

    Jim Claypool Guest

    (defun c:bline ()
    (setq p1 (getpoint "First Point"))
    (while ;;Added this line
    (setq p2 (getpoint "Second Point"))
    (setq oldosm (getvar "OSMODE"))
    (setvar "OSMODE" 0)
    (setq ang (angle p1 p2))
    (setq point1 (polar p1 ang 300))
    (setq point2 (polar p1 ang (- (distance p1 p2) 300)))
    (command "line" point1 point2 "")
    (setq p1 p2) ;;Added this line
    (SETVAR "OSMODE" OLDOSM)
    );end while ;;Added this line
    )
     
    Jim Claypool, Aug 20, 2004
    #8
  9. Slick.... thanks Paul.


     
    Casey Roberts, Aug 20, 2004
    #9
  10. Casey Roberts

    Paul Turvill Guest

    You're welcome.
    ___
     
    Paul Turvill, Aug 20, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.