AutoLISP Help

Discussion in 'AutoCAD' started by richardhighrange, Mar 20, 2007.

  1. I want to write a simple AutoLISP routine that will list the slope
    between two entities be they points, nodes, polylines, 3dpolylines,
    etc. I have the basic mathematics down, but I am having problems with
    the remainder. Currently the program loads, but gets stuck in
    initializing. I know I need to get the two points, but do not know
    how to do this. Here is the program, can anyone help me finish it?

    (defun ges( pt1 pt2 / dZ d Slope)
    (setq
    dZ (- (caddr pt2) (caddr pt1))
    d (distance (list (car pt1) (cadr pt1) 0.0) (list (car pt2) (cadr
    pt2) 0.0))
    Slope (* 100.0 (/ dZ d))
    )
    )
     
    richardhighrange, Mar 20, 2007
    #1
  2. richardhighrange

    Carl AK Guest

    Try this:

    (defun c:ges( / dZ d Slope)
    (setq Pt1 (getpoint "\nFirst point: "))
    (setq Pt2 (getpoint Pt1 "\nSecond point: "))
    (setq
    dZ (- (caddr pt2) (caddr pt1))
    d (distance (list (car pt1) (cadr pt1) 0.0) (list (car pt2)
    (cadr
    pt2) 0.0))
    Slope (* 100.0 (/ dZ d))
    )
    (princ (strcat "Slope= " (rtos Slope 2 2) "%"))
    (princ)
    )
     
    Carl AK, Mar 20, 2007
    #2
  3. richardhighrange

    Edchera Guest

    Hi,
    please me a little sketch of the line, then I can help you

    Arnold
     
    Edchera, Apr 30, 2007
    #3
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.