Lisp routine fix for 2005

Discussion in 'AutoCAD' started by sdmadden, Feb 14, 2005.

  1. sdmadden

    sdmadden Guest

    This routine was working on 2002. It listed the 3d slope for 2 points and put them in a block arrow on the screen showing the flow direction and slope %. It will still list the slope, but cant get the block to show the slope %. I have some other routines that I am having the same problem with, any help is greatly appreciated.


    (setq start (getpoint "\nStart: "))
    (setq endpt (getpoint start "\nEnd: "))
    (setq dx (- (nth 0 start) (nth 0 endpt)))
    (setq dy (- (nth 1 start) (nth 1 endpt)))
    (setq dz (- (nth 2 start) (nth 2 endpt)))
    (setq mid (polar
    (list (nth 0 start) (nth 1 start) 0.0)
    (setq ang (angle start endpt))
    (* (distance (list dx 0.0) (list 0.0 dy)) 0.5)
    )
    )
    (princ "\n")
    ;s * / d d/8s
    (setq slope (* 100.0 (/ dz (distance (list dx 0.0) (list 0.0 dy)))))
    (princ (rtos slope))
    (princ "% ")
    (princ (rtos (/ 1.0 (/ dz (distance (list dx 0.0) (list 0.0 dy)))) 2 1))
    (princ ":1\n")
    (setq scale (/ (* (getvar "DIMSCALE") (getvar "DIMTXT")) 2.54))
    (setq attreq (getvar "ATTREQ"))
    (setvar "ATTREQ" 0)
    (setq aunits (getvar "AUNITS"))
    (setq auprec (getvar "AUPREC"))
    (setvar "AUNITS" 3)
    (setvar "AUPREC" 8)
    (if (< slope 0.0)
    (command "INSERT" (STRCAT ELECT_PATH "SLOPEM") "NON" mid scale scale ang)
    (command "INSERT" (STRCAT ELECT_PATH "SLOPEP") "NON" mid scale scale ang)
    )
    (setvar "AUNITS" aunits)
    (setvar "AUPREC" auprec)
    (setvar "ATTREQ" attreq)
    (setq vals (list "#" (strcat (rtos (abs slope) 2 2) "%")))
    (setq ed (entget (entlast)))
    (setq n 0)
    (while (/= te "SEQEND")
    (setq ed (entget (entnext (cdr (assoc -1 ed)))))
    (setq te (cdr (assoc 0 ed)))
    (if (and (/= te "SEQEND") (= 0 (boole 1 2 (cdr (assoc 70 ed))))) (progn
    (setq n (+ n 1))
    (setq ed (subst (cons 1 (nth n vals)) (assoc 1 ed) ed))
    (entmod ed)
    ))
    )
    (entupd (cdr (assoc -1 ed)))
    (EL-EXIT)
    (princ)
    )


    Thanks,
    Steven
     
    sdmadden, Feb 14, 2005
    #1
  2. sdmadden

    R.K. McSwain Guest

    and slope %. It will still list the slope, but cant get the block to
    show the slope %. I have some other

    Since nobody here has your blocks (SLOPEM, SLOPEP), your path
    (ELECT_PATH) or the function named (EL_EXIT) - it may be difficult to debug.

    Have you tried loading the code in the visual lisp editor (VLIDE) and
    stepping through the code one line at a time and see where the error
    occurs? If you get an error and don't know what it means, post it.

    Generally speaking, not a whole lot changed between 2002 and 2005 in
    lisp. We have hundreds of routines which needed no modifications. Are
    you sure you are inserting the right block, did a path change, are you
    missing an externally defined function, etc. etc...
     
    R.K. McSwain, Feb 15, 2005
    #2
  3. sdmadden

    sdmadden Guest

    Sorry, I have a lot of routines running off my .mnl file that defines the ELECT_PATH as well as the (EL_EXIT), but I was planning on taking the (EL_EXIT) out just to test it....do you need me to post the long functions and the blocks on here? I can do that if needed. I double checked the ELECT_PATH and that is correct, where my custom menu is stored.

    thanks.
     
    sdmadden, Feb 15, 2005
    #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.