Mental block: Getangle relative to another angle

Discussion in 'AutoCAD' started by Matt W, Nov 12, 2004.

  1. Matt W

    Matt W Guest

    So here's the deal.
    I've got a line that I select.
    I get the endpoints and determine the angle of the line.
    I then want to use "GETANGLE" from the midpoint of those two points (I can
    get the midpoint, no problem) and then return the angle relative to the
    selected line.

    I'm having a severe mental block.
    Must be because I'm getting paranoid about the "white out conditions" I see
    outside my window.


    Thanks in advance!
     
    Matt W, Nov 12, 2004
    #1
  2. Matt W

    BillZ Guest

    Try this:

    Code:
    ;John Uhden latest version of this formula
    ;
    ;
    ;
    
    (defun @delta (a1 a2)
    (cond ((> a1 (+ a2 pi))
    (+ a2 pi pi (- a1))
    )
    ((> a2 (+ a1 pi))
    (- a2 a1 pi pi)
    )
    (1 (- a2 a1))
    )
    )
    
    Bill
     
    BillZ, Nov 12, 2004
    #2
  3. Matt W

    Matt W Guest

    Not quite sure what I'm supposed to do with this.
    I'm passing two points to it??
    Anyhoo.... here's what I've got so far...

    Code:
    ;John Uhden latest version of this formula
    (defun @delta (a1 a2)
    (cond
    ((> a1 (+ a2 pi))  (+ a2 pi pi (- a1)))
    ((> a2 (+ a1 pi))  (- a2 a1 pi pi))
    (1 (- a2 a1))
    )
    )
    
    (defun DXF (code lst) (cdr (assoc code lst)))
    
    (defun RTD (A) (/ (* A 180.0) PI))
    
    (defun C:PICK_LINE ( / objEnt ptS ptE ductWidth ductHeight objAng objDist
    ptMid objAng2 ptAng)
    (setq objEnt (entsel))
    (setq objEnt (entget (car objEnt)))
    (setq ptS (DXF 10 objEnt))
    (setq ptE (DXF 11 objEnt))
    (setq objAng (angle ptS ptE))
    (setq objDist (distance ptS ptE))
    (setvar "snapang" objAng)
    (setq ptMid (polar ptS objAng (/ objDist 2)))
    (command "angbase" objAng)
    (setvar "snapang" objAng)
    (setq ptAng (rtd (getangle ptMid "\n Pick a point.... ")))
    
    ;;; it throws a wobbly right here... "bad argument type for compare:
    (1039.48 1271.01 0.0) 355.797"
    (setq objAng2 (@delta ptMid ptAng))
    (princ)
    )
    
     
    Matt W, Nov 12, 2004
    #3
  4. Matt W

    ECCAD Guest

    Change:
    (setq ptAng (rtd (getangle ptMid "\n Pick a point.... ")))
    ----------
    To:
    (setq Pnt (getpoint "\n Pick a point.... "))
    (setq ptAng (rtd (angle ptMid Pnt)))

    Bob
     
    ECCAD, Nov 12, 2004
    #4
  5. Matt W

    BillZ Guest

    I'm passing two points to it??<<<

    Two angles...

    (@delta (angle p1 p2)(angle p3 p4))

    Would be one way.

    Returns the deflection angle from angle one.

    Bill
     
    BillZ, Nov 15, 2004
    #5
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.