Message 1 of 26
Pick two Points to get Downslope in percents, prompted in CommandLine

Not applicable
01-27-2015
09:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I wrote a lisp which calculates the downslope in percents and returns this downslope's value to CommandLine.
Here it is:
; DSE = DownSlopE ; DOWNSLOPE (defun c:DOWNSLOPE (/ ptL1 ptL2 Len_X Len_Y Len Ang DownslopePercents) (setvar "cmdecho" 0) (setq ptL1 (getpoint "\nSpecify First Point to calculate Downslope: ")) (setq ptL2 (getpoint "\nSpecify Second Point to calculate Downslope: ")) (setq XptL1 (car ptL1)) (setq YptL1 (cadr ptL1)) (setq XptL2 (car ptL2)) (setq YptL2 (cadr ptL2)) (setq Len_X (- XptL2 XptL1)) (setq Len_Y (- YptL2 YptL1)) ; What if XptL1 = XptL2 --> Len_X=0? ; (setq Len ; (sqrt ; (+ (* Len_X Len_X) (* Len_Y Len_Y)) ; ); sqrt ; ); Len ; (setq Ang (atan Len_Y Len_X)) ;Len_Y/Len_X = DownslopePercents/100 (setq DownslopePercents (* (/ Len_Y Len_X) 100)) (setq DownslopePercents2string (rtos DownslopePercents 2 3)); Mode=2=Engineering, Precision=3 (princ "\nDownslope = ") DownslopePercents2string (princ "%.") ; (princ "\nAngle = ") ; Length ; (princ " <Here should be current angle units. Should I type 'getvar AUNITS?'>.") ; (princ "\nLength = ") ; Length ; (princ ".") );defun
Some parts of this lisp I ignore with ';', because they will be investigated in other cases - on ground of this lisp I want to write lisps which return to CommandLine Distance and Angle between two picked Points. And I can't do them using 'getdist' and 'getangle', because the user would type his own value for Distance and Angle.
So returning to the main topic: This lisp doesn't work properly.
In the CommandLine it returns:
Command: DOWNSLOPE
Specify First Point to calculate Downslope:
Specify Second Point to calculate Downslope:
Downslope = %."%."
Could you please tell me why it doesn't work in way which I suspected?