Set drawing orientation/direction with 2 picks

Discussion in 'AutoCAD' started by tercelpiper, Nov 25, 2004.

  1. tercelpiper

    tercelpiper Guest

    Does anyone have code for setting the orientation for drawing an object or writing text with 2 picks? First pick for location or start pt and second pick for the direction or orientation.

    Thanks in advance

    Paul
     
    tercelpiper, Nov 25, 2004
    #1
  2. ucs (enter)
    z (enter)
    pick first point
    pick second point

    ?

    This changes the ucs to the angle you pick with the two points.

    Casey
    writing text with 2 picks? First pick for location or start pt and second
    pick for the direction or orientation.
     
    Casey Roberts, Nov 25, 2004
    #2
  3. tercelpiper

    tercelpiper Guest

    Thanks Casey, but I guess I didn't define the situation clearly enough. I meant to say that I would have code draw an object, but before the code to draw the object executes the user would pick 2 points to define the 'direction' the object would 'point' in. The 2 picks would determine the angle say an arrow would point.
     
    tercelpiper, Nov 26, 2004
    #3
  4. tercelpiper

    ECCAD Guest

    Untested, but should work.
    ;; Degrees to Radians, Radians to Degrees
    (defun dtr (d) (* pi (/ d 180.0)))
    (defun rtd (r) (* 180.0 (/ r pi)))

    ;; Function to get insertion angle.
    ;; call (getangle)
    ;; returns 'ang' angle in degrees e.g. 45.0
    (defun getangle (/ orth osm pt1 pt2)
    (setq orth (getvar "orthomode"))
    (setq osm (getvar "osmode"))
    (setvar "orthomode" 0)
    (setvar "osmode" 0)
    (setq pt1 (getpoint "\nPick first direction point"))
    (setq pt2 (getpoint pt1 "\nPick Angle:"))
    (setq ang (rtd (angle pt1 pt2)))
    (setvar "orthomode" orth)
    (setvar "osmode" osm)
    (princ)
    ); end function
     
    ECCAD, Nov 26, 2004
    #4
  5. (setq ang1 (angle (getpoint) (getpoint))

    (command "ucs" "z" (rtd ang1))

    - note this uses a function "rtd" that converts radians to degrees.


    meant to say that I would have code draw an object, but before the code to
    draw the object executes the user would pick 2 points to define the
    'direction' the object would 'point' in. The 2 picks would determine the
    angle say an arrow would point.
     
    Casey Roberts, Nov 30, 2004
    #5
  6. tercelpiper

    CAB2k Guest

    To expand on what Casey said:

    (if (and ; both picks must happen
    (setq p1 (getpoinr "\nPick start point."))
    (setq ang1 (getangle p1 "\nPick the angle."))
    )
    (progn
    ;; set the drawing angle
    (command "ucs" "z" (* 180.0 (/ ang1 pi)))
    ;;=========================================
    ;; Draw you object or text
    ;;========================================
    (command "ucs" "p") ; restore the drawing
    )
    )
     
    CAB2k, Nov 30, 2004
    #6
  7. tercelpiper

    OLD-CADaver Guest

    Why all the fiddling with (ANGLE and (GETANGLE ?

    The code below should rotate the UCS to the two selected points, shouldn't it?

    (COMMAND ".UCS" "Z" (SETQ PT1 (GETPOINT)) (GETPOINT PT1))
     
    OLD-CADaver, Nov 30, 2004
    #7
  8. tercelpiper

    CAB2k Guest

    Why all the fiddling with (ANGLE and (GETANGLE ?

    Let me guess, so you can do some error checking? :)

    If you want to go with your suggestion, Why all the fiddling with
    (SETQ PT1 (GETPOINT)) (GETPOINT PT1))

    Just use:

    (COMMAND ".UCS" "Z" pause pause)
     
    CAB2k, Nov 30, 2004
    #8
  9. tercelpiper

    OLD-CADaver Guest

    <<Let me guess, so you can do some error checking? :)
    Gee, how much error checking is needed for 2 picks? ;-)


    << (COMMAND ".UCS" "Z" pause pause) >>

    Hold over from R9, "pause pause" wouldn't "rubber band" from the first point.
     
    OLD-CADaver, Nov 30, 2004
    #9
  10. tercelpiper

    CAB2k Guest

    Gee, how much error checking is needed for 2 picks? ;-)
    Just being pickie, ..... Sorry :)
     
    CAB2k, Nov 30, 2004
    #10
  11. tercelpiper

    OLD-CADaver Guest

    ahhh, if you can't take a little pickin', you'll never be a nose.
     
    OLD-CADaver, Dec 1, 2004
    #11
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.