Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Calling all Gurus: Here is an easy one

  1. #1
    Member jack.frahm's Avatar
    Join Date
    2001-10
    Location
    Santa Clara County, USA
    Posts
    42
    Login to Give a bone
    0

    Talking Calling all Gurus: Here is an easy one

    Command: L
    LINE Specify first point: _from Base point: <Offset>: .06

    Specify next point or [Undo]: _from Base point: <Offset>: .06


    How would I make the above series of commands one easy LISP routine? I would like to create a LISP routine that would allow the drawing of a line that starts offset at .xx from user input.

    Thanks in advance,
    Jack

  2. #2
    Active Member
    Join Date
    2003-11
    Location
    YUL
    Posts
    75
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    ... offset 0.06, OK, but at what angle from the base point?

    Quote Originally Posted by jack.frahm
    Command: L
    LINE Specify first point: _from Base point: <Offset>: .06

    Specify next point or [Undo]: _from Base point: <Offset>: .06


    How would I make the above series of commands one easy LISP routine? I would like to create a LISP routine that would allow the drawing of a line that starts offset at .xx from user input.

    Thanks in advance,
    Jack

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Quote Originally Posted by jack.frahm
    Command: L
    LINE Specify first point: _from Base point: <Offset>: .06

    Specify next point or [Undo]: _from Base point: <Offset>: .06


    How would I make the above series of commands one easy LISP routine? I would like to create a LISP routine that would allow the drawing of a line that starts offset at .xx from user input.

    Thanks in advance,
    Jack
    Something like this?
    Code:
     (defun c:myline	(/ p1)
       (command "._line"
     	   (polar (setq p1 (getpoint "\nSpecify first point: "))
     		  (* 0.5 pi)
     		  0.06
     	   )
     	   (polar (getpoint p1 "\nSpecify next point: ")
     		  (* 0.5 pi)
     		  0.06
     	   )
     	   ""
       )
       (princ)
     )
    You will have to modify the angle to suit your needs. Currently it's 90°

  4. #4
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Here are some more options:
    Code:
     (defun c:myline        (/ p1)
       (if (and (setq p1 (getpoint "\nSpecify first point: "))
                (setq p2 (getpoint p1 "\nSpecify next point: ")))
         (command "._line"
               (polar p1 (* 0.5 pi) 0.06)
               (polar p2 (* 0.5 pi) 0.06)
               ""
         )
       )
       (princ)
     )
    
    (defun c:myline (/ p1)
       (if (and (setq p1 (getpoint "\nSpecify first point: "))
                (setq p2 (getpoint p1 "\nSpecify next point: ")))
         (command "._line" p1 p2 ""
                  "_.move" "L" "" p1 (polar p1 (* 0.5 pi) 0.06) ""
                 )
       )
       (princ)
    )

  5. #5
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Hi Jack, have fun
    Code:
    (defun c:parl ( / Pkt1 ) ;; *Offset*
    
      (defun parl_err (msg / ask )
        (princ "\nUser [Esc]. " )
        (if (not *Offset* ) (setq *Offset* 0 ) ( ) )
        (setq *error* OldErr )
        (setq ask (getreal (strcat "New Offset <" (rtos *Offset* 2 2 )"> or Enter ? : " )) )
        (if ask (setq *Offset* ask ) (setq *Offset* *Offset* ) )
        (drawl)
      )
    
      (defun drawl ( / OldErr Pkt2 )
        (setq OldErr *error* *error* parl_err )
        (initget 65 )
        (if (not *Offset* ) (while (not (setq *Offset* (getdist "Digitize the distance or enter a real : " )))) ( ) )
        (princ (strcat "\nPresent Offset is " (rtos *Offset* 2 2 ) ", use [Esc] to change.\n" ) )
        (if (not Pkt1 ) (while (not (setq Pkt1 (getpoint "Start point: ")))) )
        (while (not (setq Pkt2 (getpoint "End point: "))) )
        (command "._line" 
          (polar Pkt1 (+ (angle Pkt1 Pkt2 ) (/ PI 2 )) *Offset* )
          (polar Pkt2 (+ (angle Pkt1 Pkt2 ) (/ PI 2 )) *Offset* )
          ""
        )
        (setq *error* OldErr )
      )
    
      (drawl)
      (princ)
    )
    paulmcz, the line is parallel to the 2 points
    rkmcswain, what happens when You draw a vertical line ?
    ab2draft, what happens when You draw a vertical line ?
    ab2draft, what happens again when You draw a vertical line ?

    : ) Happy Computing !

    kennet

  6. #6
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    kennet,
    sorry I did not test the code, just offering options for limited error checking.

    How about one that repeats until enter is pressed and you may change the offset as in your code, sort of like your code .

    Code:
    (defun c:myline (/ p1 p2 ang)
      ;; remembers changed offset
      ;; press ENTER to quit
      ;;  press O to change offset
      ;;  to offset to the opposit direction pick points in reverse order
      ;;  or enter a negative offset
      (setq off|set (cond (off|set) (0.06)); default
            p1 t
      ) 
      (while
        (and
          (not
            (while (and p1 (/= (type p1) 'list))
              (initget "Offset")
              (setq p1 (getpoint
                         (strcat "\nPick first point or [Offset] to change: "
                                 (rtos off|set))))
              (if (= p1 "Offset")
                (while (not (setq off|set (getdist "\nEnter new offset distance: ")))))
            )
          )
          (and p1
               (setq p2 (getpoint p1 "\nSpecify next point: "))
               (setq ang (- (angle p1 p2) (* 0.5 pi))
                     p1  (polar p1 ang off|set)
                     p2  (polar p2 ang off|set)
               )
               (not (command "._line" p1 p2 ""))
               (setq p1 T)
          )
        )
      )
      (princ)
    )

  7. #7
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Quote Originally Posted by kennet.sjoberg
    rkmcswain, what happens when You draw a vertical line ?
    kennet
    Same thing it does when you draw a line at any other angle. Both line endpoints are 0.06 units away, at 90°, from the two picked points, just what the code tells it to do, unless I'm missing something.

  8. #8
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Quote Originally Posted by rkmcswain
    Same thing it does when you draw a line at any other angle . . unless I'm missing something.
    Yes rkmcswain, my routine always draw the line offset and parallel,
    Your routine draws the line parallel 0 dislocated when vertical.

    : ) Happy Computing !

    kennet

  9. #9
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    Quote Originally Posted by kennet.sjoberg
    Yes rkmcswain, my routine always draw the line offset and parallel,
    Your routine draws the line parallel 0 dislocated when vertical.
    kennet
    That's great, but the original post never specified an angle from which the offset points should be offset.

    Quote Originally Posted by jack.frahm
    ...allow the drawing of a line that starts offset at .xx from user input
    My last comment on the first post indicated to the OP that the angle might have to be modified by the OP, possibly at run time.

  10. #10
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Calling all Gurus: Here is an easy one

    mmm..rkmcswain, In Your opinion You are totally right,
    Quote Originally Posted by rkmcswain
    That's great, but the original post never specified an angle from which the offset points should be offset.
    But for me is an offset distance always perpendicular to a line or curve,
    or in AutoCAD terms "Offsetting creates a new object whose shape parallels the shape of a selected object."
    and in our case an fictitious line through two points.

    : ) Happy Computing !

    kennet

Page 1 of 2 12 LastLast

Similar Threads

  1. 2011: Calling All Label Gurus
    By driggins in forum AutoCAD Civil 3D - General
    Replies: 5
    Last Post: 2014-10-29, 02:59 PM
  2. Any MEP family gurus?
    By sgermano in forum Revit MEP - General
    Replies: 3
    Last Post: 2010-08-23, 05:58 PM
  3. Roofing Gurus Please Help
    By yakob1966 in forum Revit Architecture - General
    Replies: 7
    Last Post: 2008-04-19, 04:21 AM
  4. Sheetmetal gurus, please Help!
    By awarren in forum Inventor - General
    Replies: 0
    Last Post: 2006-06-22, 04:00 PM
  5. A job for a roof gurus
    By Wagurto in forum Revit Architecture - General
    Replies: 4
    Last Post: 2004-07-01, 12:56 PM

Posting Permissions

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