Author Topic: Export to excel the angle,distance and ID from pivot point to surrounding points  (Read 1541 times)

0 Members and 1 Guest are viewing this topic.

tsdlc888

  • Mosquito
  • Posts: 12
Good day. Could you please help for a lisp to get from drawing the a)angle b)distance and c)point ID number,of several points(sideshots) from a pivot point(station). The sequence is click first the pivot point then click next the autonumbered surrounding points. I have several station pivots. Later i will convert the angle to azimuth by excel formula.
Thank you TheSwampers.

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
This is a bit rough but should do what you want.

Code: [Select]
;The dtr function converts degrees to radians
;The rtd function converts radians to degrees
(defun dtr (a)
(* pi (/ a 180.0))
)
;
(defun rtd (a)
(setq ang (/ (* a 180.0) pi))
(setq ddd (fix ang))
(setq mm (* (- ang ddd) 60.0))
(setq ss (fix (* (- mm (fix mm)) 60.0)))
(setq mm (fix mm))
(if (> 10. mm)
(setq mm (strcat "0" (rtos mm 2 0)))
(setq mm (rtos mm 2 0))
)
(if (> 10. ss)
(setq ss (strcat "0" (rtos ss 2 0)))
(setq ss (rtos ss 2 0))
)
(setq ang (strcat (rtos ddd 2 0) "."  mm ss))
)

(defun c:rads ( / pt1 pt2)
(SETVAR "ANGDIR" 0)
(SETVAR "LUPREC" 3)
(SETVAR "AUNITS" 1)
(setq fname (open "C:\\temp\\radiationsx.txt" "W"))
(setq pt1 (getpoint "Pick station point"))
(setq num 1)
(write-line "Pt , X , Y" fname)
(write-line (strcat (rtos num 2 0) "," (rtos (car pt1) 2 2) "," (rtos (cadr pt1) 2 2 )) fname)
(write-line "Pt , Ang , Dist" fname)
(while (setq pt2 (getpoint pt1 "Pick radiation pt <Cr> to exit"))
(setq num (+ num 1))
(command "Text" pt2 2.5 90 num ) ; expects a text style with height set to zero
(setq ang (angle pt1 pt2))
(setq dist (distance pt1 pt2))
(rtd ang)
(write-line (strcat (rtos num 2 0) "," ang "," (rtos dist 2 2 )) fname)
)
(close fname)
)
A man who never made a mistake never made anything

tsdlc888

  • Mosquito
  • Posts: 12
This is a bit rough but should do what you want.

Code: [Select]
;The dtr function converts degrees to radians
;The rtd function converts radians to degrees
(defun dtr (a)
(* pi (/ a 180.0))
)
;
(defun rtd (a)
(setq ang (/ (* a 180.0) pi))
(setq ddd (fix ang))
(setq mm (* (- ang ddd) 60.0))
(setq ss (fix (* (- mm (fix mm)) 60.0)))
(setq mm (fix mm))
(if (> 10. mm)
(setq mm (strcat "0" (rtos mm 2 0)))
(setq mm (rtos mm 2 0))
)
(if (> 10. ss)
(setq ss (strcat "0" (rtos ss 2 0)))
(setq ss (rtos ss 2 0))
)
(setq ang (strcat (rtos ddd 2 0) "."  mm ss))
)

(defun c:rads ( / pt1 pt2)
(SETVAR "ANGDIR" 0)
(SETVAR "LUPREC" 3)
(SETVAR "AUNITS" 1)
(setq fname (open "C:\\temp\\radiationsx.txt" "W"))
(setq pt1 (getpoint "Pick station point"))
(setq num 1)
(write-line "Pt , X , Y" fname)
(write-line (strcat (rtos num 2 0) "," (rtos (car pt1) 2 2) "," (rtos (cadr pt1) 2 2 )) fname)
(write-line "Pt , Ang , Dist" fname)
(while (setq pt2 (getpoint pt1 "Pick radiation pt <Cr> to exit"))
(setq num (+ num 1))
(command "Text" pt2 2.5 90 num ) ; expects a text style with height set to zero
(setq ang (angle pt1 pt2))
(setq dist (distance pt1 pt2))
(rtd ang)
(write-line (strcat (rtos num 2 0) "," ang "," (rtos dist 2 2 )) fname)
)
(close fname)
)
Hi BIGAL.
 It does for the first set and proceeding with the second set it overwrites the first set in the radiationsx.txt file. Can it please be done so that type N(next) for next station and sideshots and the result is appended to the txt file and so on? BTW the ID numbers rotation is 90d. Thanks