LISP

LISP

marwah.izmeqna
Participant Participant
4,680 Views
29 Replies
Message 1 of 30

LISP

marwah.izmeqna
Participant
Participant

Hi 

I have a problem in loading LISP to my AutoCAD version 2019, it doesn't work!

I have uploaded the LISP files to the support files successfully, but when I write a command to run the LISP it gives (PRESS F1 FOR HELP)

Can you help me please?

I can provide you with the lisp files, in order to try it in your AutoCAD version.

0 Likes
Accepted solutions (1)
4,681 Views
29 Replies
Replies (29)
Message 21 of 30

hosneyalaa
Advisor
Advisor

مافهمت عليك ....

عندك ليسب تاني  اسمه  water  فيه نفس المشكلة 

ارفقه كامل متل الاول ملف مضغوط في كل المطلوب حتى احاول فيه

حتى اشوف  بجوز نفس المشكلة  انه يضيع ملف الخيارات المؤقتة 

مافي غلبة اختنا وقت فضاتي بحاول فيه 

 

Message 22 of 30

hosneyalaa
Advisor
Advisor

شوف هيك كويس

 

 

;;;;=============error================
(defun myerr2 (msg2)
  (defun *error* (s)
    (if	old_error2
      (setq *error* old_error2)
    )
    (princ)
  )
  (if msg2
    (princ msg2)
  )
  (exit)
)
;;;;;;;=========support path=============
;;;(setq ac_exe (findfile "acad.exe"))
;;;(setq ac_path (substr ac_exe 1 (- (strlen ac_exe) 8)))
;;;(setq supp_path (strcat ac_path "support\\"))
;;;;=============setup================
;;;(defun c:wasetup ()
;;;  (setq fstpf2 (findfile "wtrstp.txt"))
;;;  (if (= fstpf2 nil)
;;;    (progn
;;;      (setq hsc	"1000"
;;;	    vsc	"100"
;;;	    sst	"0.00"
;;;	    dtm	"0"
;;;      )
;;;    )
;;;    (progn
;;;      (setq ostpr2 (open fstpf2 "r"))
;;;      (setq hsc (read-line ostpr2))
;;;      (setq vsc (read-line ostpr2))
;;;      (setq sst (read-line ostpr2))
;;;      (setq dtm (read-line ostpr2))
;;;      (close ostpr2)
;;;    )
;;;  )
;;;;;;;==========load setup dialog==================
;;;  (setq wtr_dcl (load_dialog "water_prof.dcl"))
;;;  (if (/= wtr_dcl -1)
;;;    (new_dialog "wtr_prf" wtr_dcl)
;;;    (progn
;;;      (alert "\nDialog File < water_prof.dcl > not found.")
;;;      (myerr2 "Function Terminated.")
;;;    )
;;;  )
;;;  (set_tile "hsc" hsc)
;;;  (set_tile "vsc" vsc)
;;;  (set_tile "sst" sst)
;;;  (set_tile "dtm" dtm)
;;;  (action_tile "hsc" "(setq hsc1 $value)")
;;;  (action_tile "vsc" "(setq vsc1 $value)")
;;;  (action_tile "sst" "(setq sst1 $value)")
;;;  (action_tile "dtm" "(setq dtm1 $value)")
;;;  (setq hsc1 (get_tile "hsc"))
;;;  (setq vsc1 (get_tile "vsc"))
;;;  (setq sst1 (get_tile "sst"))
;;;  (setq dtm1 (get_tile "dtm"))
;;;  (start_dialog)
;;;  (setq ostpw2 (open (strcat supp_path "wtrstp.txt") "w"))
;;;  (write-line hsc1 ostpw2)
;;;  (write-line vsc1 ostpw2)
;;;  (write-line sst1 ostpw2)
;;;  (write-line dtm1 ostpw2)
;;;  (close ostpw2)
;;;)
;;;;swsetup

;;;start::
(defun c:water (/ filename filereader filereader2 filereader3 filereader4 filereader5 filereader6
		     datum startstation xscale yscale fitname
		     oneline nextline exit_loop_flage last_station
		     station groundlevel incrdes invertlevel pipefitting pipedia pipetype
		     station_n groundlevel_n incrdes_n invertlevel_n pipefitting_n pipedia_n pipetype_n
		     )

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (setq fstpf2 (findfile "wtrstp.txt"))
  (if (= fstpf2 nil)
    (progn
      (setq hsc	"1000"
	    vsc	"100"
	    sst	"0.00"
	    dtm	"0"
      )
    )
    (progn
      (setq ostpr2 (open fstpf2 "r"))
      (setq hsc (read-line ostpr2))
      (setq vsc (read-line ostpr2))
      (setq sst (read-line ostpr2))
      (setq dtm (read-line ostpr2))
      (close ostpr2)
    )
  )
;;;;==========load setup dialog==================
  (setq wtr_dcl (load_dialog "water_prof.dcl"))
  (if (/= wtr_dcl -1)
    (new_dialog "wtr_prf" wtr_dcl)
    (progn
      (alert "\nDialog File < water_prof.dcl > not found.")
      (myerr2 "Function Terminated.")
    )
  )
  (set_tile "hsc" hsc)
  (set_tile "vsc" vsc)
  (set_tile "sst" sst)
  (set_tile "dtm" dtm)
  (action_tile "hsc" "(setq hsc1 $value)")
  (action_tile "vsc" "(setq vsc1 $value)")
  (action_tile "sst" "(setq sst1 $value)")
  (action_tile "dtm" "(setq dtm1 $value)")
  (setq hsc1 (get_tile "hsc"))
  (setq vsc1 (get_tile "vsc"))
  (setq sst1 (get_tile "sst"))
  (setq dtm1 (get_tile "dtm"))
  (start_dialog)
;;;  (setq ostpw2 (open (strcat supp_path "wtrstp.txt") "w"))
;;;  (write-line hsc1 ostpw2)
;;;  (write-line vsc1 ostpw2)
;;;  (write-line sst1 ostpw2)
;;;  (write-line dtm1 ostpw2)
;;;  (close ostpw2)

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setvar "cmdecho" 0)
;;;  (setq stpchk2 (findfile "wtrstp.txt"))
  (if hsc1
    
    (progn
;;;      (setq opchkf2 (open stpchk2 "r"))
  	(setq xscale (atof hsc1))
  	(setq yscale (atof vsc1))
  	(setq startstation (atof sst1))
  	(setq datum (atof dtm1))
;;;      (close opchkf2)

  
 ; (setq station_n nil)
  ;(setq groundlevel_n nil)
  ;(setq last_station nil)
  ;(setq groundlevel nil)
  ;(setq station nil)
  ;(setq nextline "")
  ;(setq oneline "")
  ;(setq invertlevel nil)
  ;(setq invertlevel_n nil)
  
  ; Get user input.
  ; Set the X Scale and the Y Scale.
  (setq filename (getfiled "Select data file"
                (strcat (getvar "dwgprefix")
;;;                (substr (getvar "DWGNAME") 1 (- (strlen (getvar "dwgname")) 1))
			)
                "prn"     ;file type
                4))
       
  ;(setq xscale (getreal "\nEnter Xscale: "))
  ;(setq yscale (getreal "\nEnter Yscale: "))
  ;(setq datum (getreal "\nEnter Datum: "))
  ;(setq startstation (getreal "\nEnter Start Station: "))
  ;(setq filename (getstring "\nEnter Data File name: "))
  (setq filereader (open filename "r"))
  ; Insert the legend from the file in the support files.
  (command "insert" "LEGEND_WATER_PROF" (list 0.0 0.0) "1" "1" "0")
  ; Write near legend the Datum and the X Scale and the Y Scale.
  (command "layer" "new" "vline" "color" "8" "vline" "")
  (command "layer" "new" "texts" "color" "white" "texts" "")
  (command "layer" "new" "upper_line" "color" "blue" "upper_line" "")
  (command "layer" "new" "lower_line" "color" "magenta" "lower_line" "")
  
  (command "layer" "set" "texts" "")
  (command "text" "s" "ST1" "j" "br" '(0 0.1) "0.3" "0" (strcat (rtos datum 2 2) " m"))
  (command "text" "s" "ST1" "j" "bl" '(-3.9 2.15) "0.3" "0" (rtos xscale 2 0))
  (command "text" "s" "ST1" "j" "bl" '(-6.3 5.1) "0.3" "0" (rtos yscale 2 0))

  ; Create layer to hold all the red lines.
  (command "layer" "new" "red_lines" "color" "red" "red_lines" "")
  (command "layer" "set" "red_lines" "")
    )
  )
  ; Create the Stations line. Working on the red lines.
  ; -------------------------------------------
  ; First loop starting from the Start Station.
  ; -------------------------------------------
  (while (/= (setq oneline (read-line filereader)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (if (= station startstation)
	(progn
	  (setq pipedia (atof (substr oneline 38 5)))
          (setq pipetype (substr oneline 43 5))
	)
      )
      (setq last_station station)

      ; Read next line.
      (if (/= (setq nextline (read-line filereader)) nil)
         (progn
           (setq station_n (atof (substr nextline 1 8)))
           (setq groundlevel_n (atof (substr nextline 9 8)))
	   (setq last_station station_n)
	 )
      );end if

      ; Write the stations and thier lines.
      (if (= startstation station)
	(progn
	  ; Drawing the Stations.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -6.5) "0.15" "90" (rtos station 2 2))
	  (command "text" "mc" (list (+ (/ station_n (/ xscale 100)) 0.2) -6.5) "0.15" "90" (rtos station_n 2 2))
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
	  (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
	  ; Drawing vertical lines.
	  (command "layer" "set" "vline" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station (/ xscale 100)) 0) "")
	  (command "line" (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) 0) "")
	  ; Drawing the Ground Level.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -2.5) "0.15" "90" (rtos groundlevel 2 2))
	  (command "text" "mc" (list (+ (/ station_n (/ xscale 100)) 0.2) -2.5) "0.15" "90" (rtos groundlevel_n 2 2))
	)
	(progn
	  ; Drawing the Stations.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (/ station (/ xscale 100)) -6.5) "0.15" "90" (rtos station 2 2))
	  (command "text" "mc" (list (/ station_n (/ xscale 100)) -6.5) "0.15" "90" (rtos station_n 2 2))
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
	  (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
	  ; Drawing vertical lines.
	  (command "layer" "set" "vline" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station (/ xscale 100)) 0) "")
	  (command "line" (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) 0) "")
	  ; Drawing the Ground Level.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (/ station (/ xscale 100)) -2.5) "0.15" "90" (rtos groundlevel 2 2))
	  (command "text" "mc" (list (/ station_n (/ xscale 100)) -2.5) "0.15" "90" (rtos groundlevel_n 2 2))
	)
      );end if
    );end progn of while
  );end while
  ; Draw the Pipe Diameter and the Pipe Type.
  (command "layer" "set" "texts" "")
  (command "text" "mc" (list (/ (/ last_station (/ xscale 100)) 2) -0.5) "0.35" "0" (strcat (rtos pipedia 2 0) " mm " pipetype))
  ; Draw the last top last line.
  (command "layer" "set" "red_lines" "")
  (command "line" (list (/ last_station (/ xscale 100)) -11) (list (/ last_station (/ xscale 100)) -10) "")
  (command "line" (list 0 -11) (list (/ last_station (/ xscale 100)) -11) "")
  (command "line" (list 0 -10) (list (/ last_station (/ xscale 100)) -10) "")
  ; Draw the last line.
  (command "layer" "set" "red_lines" "")
  (command "line" (list (/ last_station (/ xscale 100)) 0) (list (/ last_station (/ xscale 100)) -9) "")
  (close filereader)
  ; ------------------------------------------------------
  ; Second loop, starting from the Start Station plus one.
  ; ------------------------------------------------------
  (setq filereader2 (open filename "r"))
  (while (/= (setq oneline (read-line filereader2)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (if (/= startstation station)
	(progn
          (setq groundlevel (atof (substr oneline 9 8)))

          ; Read next line.
          (if (/= (setq nextline (read-line filereader2)) nil)
            (progn
              (setq station_n (atof (substr nextline 1 8)))
              (setq groundlevel_n (atof (substr nextline 9 8)))
	    )
          );end if
          ; Drawing the rest of the Stations lines.
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
          (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
        );end progn of inner if
      );end inner if
    );end progn of while
  );end while
  (close filereader2)
  ; ---------------------------------------------------------------
  ; Third loop, for the Invert Level and the Depth to Invert Level.
  ; ---------------------------------------------------------------
  (setq filereader3 (open filename "r"))
  (while (/= (setq oneline (read-line filereader3)) nil)
    (progn
      (setq exit_loop_flage "N")
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (setq invertlevel (atof (substr oneline 25 8)))
      (if (/= invertlevel 0.00)
        (progn
	  (while (and (= exit_loop_flage "N") (/= (setq nextline (read-line filereader3)) nil))
	    (progn
	      (setq station_n (atof (substr nextline 1 8)))
	      (setq groundlevel_n (atof (substr nextline 9 8)))
	      (setq invertlevel_n (atof (substr nextline 25 8)))
              (if (/= invertlevel_n 0.00)
		(progn
		  (setq exit_loop_flage "Y")
;;;		  (princ (rtos station 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos groundlevel 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos station_n 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos groundlevel_n 2 2))
;;;	          (princ "\n")
		  ; Drawing lower line.
		  (command "layer" "set" "lower_line" "")
                  (command "line" (list (/ station (/ xscale 100)) (/ (- invertlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- invertlevel_n datum) (/ yscale 100))) "")
;                  (command "line" (list (/ station (/ xscale 100)) (/ (- (+ invertlevel (/ pipedia 1000)) datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- (+ invertlevel_n (/ pipedia 1000)) datum) (/ yscale 100))) "")
		  ; Drawing the Partial Distance line and text.
	          (command "layer" "set" "red_lines" "")
	          (command "line" (list (/ station_n (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -2) "")
		  (command "layer" "set" "texts" "")
		  (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -1.5) "0.3" "0" (rtos (- station_n station) 2 2))
		  ; Drawing the Gradient line and text.
	          (command "layer" "set" "red_lines" "")
	          (command "line" (list (/ station_n (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -8) "")
		  (command "layer" "set" "texts" "")
		  (if (/= station station_n)
		    (progn
		      (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -7.5) "0.3" "0" (rtos (/ (- invertlevel_n invertlevel) (- station_n station)) 1 2))
		    )
		  )
		  (if (= startstation station)
	            (progn
;;;	              (princ (rtos invertlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos groundlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel_n 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos groundlevel_n 2 2))
;;;	              (princ "\n")
	              ; Writing the Invert Level texts.
	              (command "layer" "set" "texts" "")
	              (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -3.5) "0.15" "90" (rtos invertlevel 2 2))
                      (command "text" "mc" (list (/ station_n (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel_n 2 2))
	              ; Drawing Depth to Invert Level.
                      (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -4.5) "0.15" "90" (rtos (- groundlevel invertlevel) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel_n invertlevel_n) 2 2))
	              ; Drawing Depth to Bottom of Excavation.
	              (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -5.5) "0.15" "90" (rtos (+ (- groundlevel invertlevel) 0.15) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel_n invertlevel_n) 0.15) 2 2))
	            );end progn
	            (progn
;;;	              (princ (rtos station 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel 2 2))
;;;		      (princ "\n")
;;;		      (princ (rtos groundlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos station_n 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel_n 2 2))
;;;	              (princ "\n")
;;;		      (princ (rtos groundlevel_n 2 2))
;;;	              (princ "\n")
	              ; Writing the Invert Level texts.
	              (command "layer" "set" "texts" "")
	              (command "text" "mc" (list (/ station (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel 2 2))
                      (command "text" "mc" (list (/ station_n (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel_n 2 2))
	              ; Drawing Depth to Invert Level.
                      (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (/ station (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel invertlevel) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel_n invertlevel_n) 2 2))
	              ; Drawing Depth to Bottom of Excavation.
	              (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (/ station (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel invertlevel) 0.15) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel_n invertlevel_n) 0.15) 2 2))
	            );end progn
	          );end if
		);end progn
	      );end if
	    );end progn
	  );end while
	);end progn
      );end if
    );end progn
  );end while
  (close filereader3)
  ; -----------------------------------------------------------------------------------------
  ; Fourth loop, the rest of the Invert Level and the Depth to Invert Level (Just the lines).
  ; -----------------------------------------------------------------------------------------
  (setq filereader4 (open filename "r"))
  (while (/= (setq oneline (read-line filereader4)) nil)
    (progn
      (setq exit_loop_flage "N")
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (setq invertlevel (atof (substr oneline 25 8)))
      (if (/= station startstation)
        (progn
          (if (/= invertlevel 0.00)
            (progn
	      (while (and (= exit_loop_flage "N") (/= (setq nextline (read-line filereader4)) nil))
	        (progn
	          (setq station_n (atof (substr nextline 1 8)))
		  (setq groundlevel_n (atof (substr oneline 9 8)))
	          (setq invertlevel_n (atof (substr nextline 25 8)))
                  (if (/= invertlevel_n 0.00)
		    (progn
		      (setq exit_loop_flage "Y")
		      ; Drawing lower line.
		      (command "layer" "set" "lower_line" "")
                      (command "line" (list (/ station (/ xscale 100)) (/ (- invertlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- invertlevel_n datum) (/ yscale 100))) "")
		      ; Drawing the Partial Distance line and text.
		      (command "layer" "set" "red_lines" "")
	              (command "line" (list (/ station_n (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -2) "")
		      (command "layer" "set" "texts" "")
		      (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -1.5) "0.3" "0" (rtos (- station_n station) 2 2))
		      ; Drawing the Gradient line and text.
	              (command "layer" "set" "red_lines" "")
	              (command "line" (list (/ station_n (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -8) "")
		      (command "layer" "set" "texts" "")
		      (if (/= station station_n)
		        (progn
		          (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -7.5) "0.3" "0" (rtos (/ (- invertlevel_n invertlevel) (- station_n station)) 1 2))
		        )
		      )
		    );end progn
	          );end if
	        );end progn
	      );end while
	    );end progn
          );end if
	);end progn
      );end if
    );end progn of while
  );end while
  (close filereader4)
  ; ------------------------------
  ; Fifth loop, for Pipe Fittings.
  ; ------------------------------
  (setq filereader5 (open filename "r"))
  (while (/= (setq oneline (read-line filereader5)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (setq pipefitting (atof (substr oneline 33 5)))
      (if (/= pipefitting 0.00)
        (progn
          (cond ((eq pipefitting  1) (setq fitname "s-arv"))
            ((eq pipefitting  2) (setq fitname "d-arv"))
            ((eq pipefitting  3) (setq fitname "flow_mtr"))
            ((eq pipefitting  4) (setq fitname "futr_con"))
            ((eq pipefitting  5) (setq fitname "line_vlv"))
            ((eq pipefitting  6) (setq fitname "wash_out"))
            ((eq pipefitting  7) (setq fitname "adapter"))
            ((eq pipefitting  😎 (setq fitname "elb45"))
            ((eq pipefitting  9) (setq fitname "end"))
            ((eq pipefitting 10) (setq fitname "fta-s"))
            ((eq pipefitting 11) (setq fitname "fta-d"))
            ((eq pipefitting 12) (setq fitname "reducer"))
            ((eq pipefitting 13) (setq fitname "tee-ask"))
            ((eq pipefitting 14) (setq fitname "elb22"))
            ((eq pipefitting 15) (setq fitname "elb11"))
            ((eq pipefitting 16) (setq fitname "t-ask45"))
            ((eq pipefitting 17) (setq fitname "crossing"))
            ((eq pipefitting 18) (setq fitname "end-flsh"))
            ((eq pipefitting 19) (setq fitname "vlv-fm"))
            ((eq pipefitting 20) (setq fitname "r-cross"))
            ((eq pipefitting 21) (setq fitname "w-cross"))
            ((eq pipefitting 22) (setq fitname "meter"))
            ((eq pipefitting 23) (setq fitname "flax-fr"))
            ((eq pipefitting 24) (setq fitname "sudle"))
            ((eq pipefitting 25) (setq fitname "box-culv"))
            ((eq pipefitting 26) (setq fitname "elb90"))
            ((eq pipefitting 27) (setq fitname "prv"))
            ((eq pipefitting 28) (setq fitname "tec"))
            ((eq pipefitting 29) (setq fitname "u-cross"))
            ((eq pipefitting 30) (setq fitname "weld"))
            ((eq pipefitting 50) (setq fitname "av"))
	  )
          (command "insert" fitname (list (/ station (/ 	xscale 100)) -8.5) "1" "1" "0")
	)
      )
    );end progn of while
  );end while
  (close filereader5)
;;;  ; ------------------------------------------------------------------------------
;;;  ; Sixth loop, for the rest of Pipe Fittings. **Right now this loop is not used**
;;;  ; ------------------------------------------------------------------------------
;;;  (setq filereader6 (open filename "r"))
;;;  (while (/= (setq oneline (read-line filereader6)) nil)
;;;    (progn
;;;      (setq exit_loop_flage "N")
;;;      (setq station (atof (substr oneline 1 8)))
;;;      (setq groundlevel (atof (substr oneline 9 8)))
;;;      (setq pipefitting (atof (substr oneline 33 5)))
;;;      (if (/= pipefitting 0.00)
;;;        (progn
;;;	  (while (and (/= (setq nextline (read-line filereader5)) nil) (= exit_loop_flage "N"))
;;;	    (progn
;;;	      (setq station_n (atof (substr nextline 1 8)))
;;;	      (setq groundlevel_n (atof (substr oneline 9 8)))
;;;	      (setq pipefitting_n (atof (substr nextline 33 5)))
;;;              (if (/= pipefitting_n 0.00)
;;;		(progn
;;;		  (setq exit_loop_flage "Y")
;;;		  
;;;		)
;;;	      )
;;;	    )
;;;	  )
;;;	)
;;;      )
;;;    );end progn of while
;;;  );end while
;;;  (close filereader6)
  (command "zoom" "e")
);end water
(prompt
  (strcat "\nTo setup water profile settings Run < WASetup >..."
	  "\n& < water > To run main program..."
  )
)
0 Likes
Message 23 of 30

marwah.izmeqna
Participant
Participant

شكراً لجهودك ..للأسف ما اشتغل 

بعطيني Press F1 for Help

جربته عندك و اشتغل؟؟

0 Likes
Message 24 of 30

hosneyalaa
Advisor
Advisor
Accepted solution

العفو من الملف الاصلي كان ناقص قوس بالاخير 

 

اشتغل عندي بس ملفات الي عندي SEWER 

لازم جرب  ملف الخاص به  WATER

اذا ما اشتغل معك

 

;;;;=============error================
(defun myerr2 (msg2)
  (defun *error* (s)
    (if	old_error2
      (setq *error* old_error2)
    )
    (princ)
  )
  (if msg2
    (princ msg2)
  )
  (exit)
)
;;;;;;;=========support path=============
;;;(setq ac_exe (findfile "acad.exe"))
;;;(setq ac_path (substr ac_exe 1 (- (strlen ac_exe) 8)))
;;;(setq supp_path (strcat ac_path "support\\"))
;;;;=============setup================
;;;(defun c:wasetup ()
;;;  (setq fstpf2 (findfile "wtrstp.txt"))
;;;  (if (= fstpf2 nil)
;;;    (progn
;;;      (setq hsc	"1000"
;;;	    vsc	"100"
;;;	    sst	"0.00"
;;;	    dtm	"0"
;;;      )
;;;    )
;;;    (progn
;;;      (setq ostpr2 (open fstpf2 "r"))
;;;      (setq hsc (read-line ostpr2))
;;;      (setq vsc (read-line ostpr2))
;;;      (setq sst (read-line ostpr2))
;;;      (setq dtm (read-line ostpr2))
;;;      (close ostpr2)
;;;    )
;;;  )
;;;;;;;==========load setup dialog==================
;;;  (setq wtr_dcl (load_dialog "water_prof.dcl"))
;;;  (if (/= wtr_dcl -1)
;;;    (new_dialog "wtr_prf" wtr_dcl)
;;;    (progn
;;;      (alert "\nDialog File < water_prof.dcl > not found.")
;;;      (myerr2 "Function Terminated.")
;;;    )
;;;  )
;;;  (set_tile "hsc" hsc)
;;;  (set_tile "vsc" vsc)
;;;  (set_tile "sst" sst)
;;;  (set_tile "dtm" dtm)
;;;  (action_tile "hsc" "(setq hsc1 $value)")
;;;  (action_tile "vsc" "(setq vsc1 $value)")
;;;  (action_tile "sst" "(setq sst1 $value)")
;;;  (action_tile "dtm" "(setq dtm1 $value)")
;;;  (setq hsc1 (get_tile "hsc"))
;;;  (setq vsc1 (get_tile "vsc"))
;;;  (setq sst1 (get_tile "sst"))
;;;  (setq dtm1 (get_tile "dtm"))
;;;  (start_dialog)
;;;  (setq ostpw2 (open (strcat supp_path "wtrstp.txt") "w"))
;;;  (write-line hsc1 ostpw2)
;;;  (write-line vsc1 ostpw2)
;;;  (write-line sst1 ostpw2)
;;;  (write-line dtm1 ostpw2)
;;;  (close ostpw2)
;;;)
;;;;swsetup

;;;start::
(defun c:water (/ filename filereader filereader2 filereader3 filereader4 filereader5 filereader6
		     datum startstation xscale yscale fitname
		     oneline nextline exit_loop_flage last_station
		     station groundlevel incrdes invertlevel pipefitting pipedia pipetype
		     station_n groundlevel_n incrdes_n invertlevel_n pipefitting_n pipedia_n pipetype_n
		     )

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  (setq fstpf2 (findfile "wtrstp.txt"))
  (if (= fstpf2 nil)
    (progn
      (setq hsc	"1000"
	    vsc	"100"
	    sst	"0.00"
	    dtm	"0"
      )
    )
    (progn
      (setq ostpr2 (open fstpf2 "r"))
      (setq hsc (read-line ostpr2))
      (setq vsc (read-line ostpr2))
      (setq sst (read-line ostpr2))
      (setq dtm (read-line ostpr2))
      (close ostpr2)
    )
  )
;;;;==========load setup dialog==================
  (setq wtr_dcl (load_dialog "water_prof.dcl"))
  (if (/= wtr_dcl -1)
    (new_dialog "wtr_prf" wtr_dcl)
    (progn
      (alert "\nDialog File < water_prof.dcl > not found.")
      (myerr2 "Function Terminated.")
    )
  )
  (set_tile "hsc" hsc)
  (set_tile "vsc" vsc)
  (set_tile "sst" sst)
  (set_tile "dtm" dtm)
  (action_tile "hsc" "(setq hsc1 $value)")
  (action_tile "vsc" "(setq vsc1 $value)")
  (action_tile "sst" "(setq sst1 $value)")
  (action_tile "dtm" "(setq dtm1 $value)")
  (setq hsc1 (get_tile "hsc"))
  (setq vsc1 (get_tile "vsc"))
  (setq sst1 (get_tile "sst"))
  (setq dtm1 (get_tile "dtm"))
  (start_dialog)
;;;  (setq ostpw2 (open (strcat supp_path "wtrstp.txt") "w"))
;;;  (write-line hsc1 ostpw2)
;;;  (write-line vsc1 ostpw2)
;;;  (write-line sst1 ostpw2)
;;;  (write-line dtm1 ostpw2)
;;;  (close ostpw2)

  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setvar "cmdecho" 0)
;;;  (setq stpchk2 (findfile "wtrstp.txt"))
  (if hsc1
    
    (progn
;;;      (setq opchkf2 (open stpchk2 "r"))
  	(setq xscale (atof hsc1))
  	(setq yscale (atof vsc1))
  	(setq startstation (atof sst1))
  	(setq datum (atof dtm1))
;;;      (close opchkf2)

  
 ; (setq station_n nil)
  ;(setq groundlevel_n nil)
  ;(setq last_station nil)
  ;(setq groundlevel nil)
  ;(setq station nil)
  ;(setq nextline "")
  ;(setq oneline "")
  ;(setq invertlevel nil)
  ;(setq invertlevel_n nil)
  
  ; Get user input.
  ; Set the X Scale and the Y Scale.
  (setq filename (getfiled "Select data file"
                (strcat (getvar "dwgprefix")
;;;                (substr (getvar "DWGNAME") 1 (- (strlen (getvar "dwgname")) 1))
			)
                "prn"     ;file type
                4))
       
  ;(setq xscale (getreal "\nEnter Xscale: "))
  ;(setq yscale (getreal "\nEnter Yscale: "))
  ;(setq datum (getreal "\nEnter Datum: "))
  ;(setq startstation (getreal "\nEnter Start Station: "))
  ;(setq filename (getstring "\nEnter Data File name: "))
  (setq filereader (open filename "r"))
  ; Insert the legend from the file in the support files.
  (command "insert" "LEGEND_WATER_PROF" (list 0.0 0.0) "1" "1" "0")
  ; Write near legend the Datum and the X Scale and the Y Scale.
  (command "layer" "new" "vline" "color" "8" "vline" "")
  (command "layer" "new" "texts" "color" "white" "texts" "")
  (command "layer" "new" "upper_line" "color" "blue" "upper_line" "")
  (command "layer" "new" "lower_line" "color" "magenta" "lower_line" "")
  
  (command "layer" "set" "texts" "")
  (command "text" "s" "ST1" "j" "br" '(0 0.1) "0.3" "0" (strcat (rtos datum 2 2) " m"))
  (command "text" "s" "ST1" "j" "bl" '(-3.9 2.15) "0.3" "0" (rtos xscale 2 0))
  (command "text" "s" "ST1" "j" "bl" '(-6.3 5.1) "0.3" "0" (rtos yscale 2 0))

  ; Create layer to hold all the red lines.
  (command "layer" "new" "red_lines" "color" "red" "red_lines" "")
  (command "layer" "set" "red_lines" "")
    )
  )
  ; Create the Stations line. Working on the red lines.
  ; -------------------------------------------
  ; First loop starting from the Start Station.
  ; -------------------------------------------
  (while (/= (setq oneline (read-line filereader)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (if (= station startstation)
	(progn
	  (setq pipedia (atof (substr oneline 38 5)))
          (setq pipetype (substr oneline 43 5))
	)
      )
      (setq last_station station)

      ; Read next line.
      (if (/= (setq nextline (read-line filereader)) nil)
         (progn
           (setq station_n (atof (substr nextline 1 8)))
           (setq groundlevel_n (atof (substr nextline 9 8)))
	   (setq last_station station_n)
	 )
      );end if

      ; Write the stations and thier lines.
      (if (= startstation station)
	(progn
	  ; Drawing the Stations.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -6.5) "0.15" "90" (rtos station 2 2))
	  (command "text" "mc" (list (+ (/ station_n (/ xscale 100)) 0.2) -6.5) "0.15" "90" (rtos station_n 2 2))
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
	  (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
	  ; Drawing vertical lines.
	  (command "layer" "set" "vline" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station (/ xscale 100)) 0) "")
	  (command "line" (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) 0) "")
	  ; Drawing the Ground Level.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -2.5) "0.15" "90" (rtos groundlevel 2 2))
	  (command "text" "mc" (list (+ (/ station_n (/ xscale 100)) 0.2) -2.5) "0.15" "90" (rtos groundlevel_n 2 2))
	)
	(progn
	  ; Drawing the Stations.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (/ station (/ xscale 100)) -6.5) "0.15" "90" (rtos station 2 2))
	  (command "text" "mc" (list (/ station_n (/ xscale 100)) -6.5) "0.15" "90" (rtos station_n 2 2))
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
	  (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
	  ; Drawing vertical lines.
	  (command "layer" "set" "vline" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station (/ xscale 100)) 0) "")
	  (command "line" (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) 0) "")
	  ; Drawing the Ground Level.
	  (command "layer" "set" "texts" "")
	  (command "text" "mc" (list (/ station (/ xscale 100)) -2.5) "0.15" "90" (rtos groundlevel 2 2))
	  (command "text" "mc" (list (/ station_n (/ xscale 100)) -2.5) "0.15" "90" (rtos groundlevel_n 2 2))
	)
      );end if
    );end progn of while
  );end while
  ; Draw the Pipe Diameter and the Pipe Type.
  (command "layer" "set" "texts" "")
  (command "text" "mc" (list (/ (/ last_station (/ xscale 100)) 2) -0.5) "0.35" "0" (strcat (rtos pipedia 2 0) " mm " pipetype))
  ; Draw the last top last line.
  (command "layer" "set" "red_lines" "")
  (command "line" (list (/ last_station (/ xscale 100)) -11) (list (/ last_station (/ xscale 100)) -10) "")
  (command "line" (list 0 -11) (list (/ last_station (/ xscale 100)) -11) "")
  (command "line" (list 0 -10) (list (/ last_station (/ xscale 100)) -10) "")
  ; Draw the last line.
  (command "layer" "set" "red_lines" "")
  (command "line" (list (/ last_station (/ xscale 100)) 0) (list (/ last_station (/ xscale 100)) -9) "")
  (close filereader)
  ; ------------------------------------------------------
  ; Second loop, starting from the Start Station plus one.
  ; ------------------------------------------------------
  (setq filereader2 (open filename "r"))
  (while (/= (setq oneline (read-line filereader2)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (if (/= startstation station)
	(progn
          (setq groundlevel (atof (substr oneline 9 8)))

          ; Read next line.
          (if (/= (setq nextline (read-line filereader2)) nil)
            (progn
              (setq station_n (atof (substr nextline 1 8)))
              (setq groundlevel_n (atof (substr nextline 9 8)))
	    )
          );end if
          ; Drawing the rest of the Stations lines.
	  ; Drawing red lines.
	  (command "layer" "set" "red_lines" "")
          (command "line" (list (/ station (/ xscale 100)) 0) (list (/ station_n (/ xscale 100)) 0) "")
	  (command "line" (list (/ station (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -1) "")
	  (command "line" (list (/ station (/ xscale 100)) -2) (list (/ station_n (/ xscale 100)) -2) "")
	  (command "line" (list (/ station (/ xscale 100)) -3) (list (/ station_n (/ xscale 100)) -3) "")
	  (command "line" (list (/ station (/ xscale 100)) -4) (list (/ station_n (/ xscale 100)) -4) "")
	  (command "line" (list (/ station (/ xscale 100)) -5) (list (/ station_n (/ xscale 100)) -5) "")
	  (command "line" (list (/ station (/ xscale 100)) -6) (list (/ station_n (/ xscale 100)) -6) "")
	  (command "line" (list (/ station (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -7) "")
	  (command "line" (list (/ station (/ xscale 100)) -8) (list (/ station_n (/ xscale 100)) -8) "")
	  (command "line" (list (/ station (/ xscale 100)) -9) (list (/ station_n (/ xscale 100)) -9) "")
	  ; Drawing upper line.
	  (command "layer" "set" "upper_line" "")
	  (command "line" (list (/ station (/ xscale 100)) (/ (- groundlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- groundlevel_n datum) (/ yscale 100))) "")
        );end progn of inner if
      );end inner if
    );end progn of while
  );end while
  (close filereader2)
  ; ---------------------------------------------------------------
  ; Third loop, for the Invert Level and the Depth to Invert Level.
  ; ---------------------------------------------------------------
  (setq filereader3 (open filename "r"))
  (while (/= (setq oneline (read-line filereader3)) nil)
    (progn
      (setq exit_loop_flage "N")
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (setq invertlevel (atof (substr oneline 25 8)))
      (if (/= invertlevel 0.00)
        (progn
	  (while (and (= exit_loop_flage "N") (/= (setq nextline (read-line filereader3)) nil))
	    (progn
	      (setq station_n (atof (substr nextline 1 8)))
	      (setq groundlevel_n (atof (substr nextline 9 8)))
	      (setq invertlevel_n (atof (substr nextline 25 8)))
              (if (/= invertlevel_n 0.00)
		(progn
		  (setq exit_loop_flage "Y")
;;;		  (princ (rtos station 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos groundlevel 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos station_n 2 2))
;;;	          (princ "\n")
;;;	          (princ (rtos groundlevel_n 2 2))
;;;	          (princ "\n")
		  ; Drawing lower line.
		  (command "layer" "set" "lower_line" "")
                  (command "line" (list (/ station (/ xscale 100)) (/ (- invertlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- invertlevel_n datum) (/ yscale 100))) "")
;                  (command "line" (list (/ station (/ xscale 100)) (/ (- (+ invertlevel (/ pipedia 1000)) datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- (+ invertlevel_n (/ pipedia 1000)) datum) (/ yscale 100))) "")
		  ; Drawing the Partial Distance line and text.
	          (command "layer" "set" "red_lines" "")
	          (command "line" (list (/ station_n (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -2) "")
		  (command "layer" "set" "texts" "")
		  (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -1.5) "0.3" "0" (rtos (- station_n station) 2 2))
		  ; Drawing the Gradient line and text.
	          (command "layer" "set" "red_lines" "")
	          (command "line" (list (/ station_n (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -8) "")
		  (command "layer" "set" "texts" "")
		  (if (/= station station_n)
		    (progn
		      (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -7.5) "0.3" "0" (rtos (/ (- invertlevel_n invertlevel) (- station_n station)) 1 2))
		    )
		  )
		  (if (= startstation station)
	            (progn
;;;	              (princ (rtos invertlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos groundlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel_n 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos groundlevel_n 2 2))
;;;	              (princ "\n")
	              ; Writing the Invert Level texts.
	              (command "layer" "set" "texts" "")
	              (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -3.5) "0.15" "90" (rtos invertlevel 2 2))
                      (command "text" "mc" (list (/ station_n (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel_n 2 2))
	              ; Drawing Depth to Invert Level.
                      (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -4.5) "0.15" "90" (rtos (- groundlevel invertlevel) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel_n invertlevel_n) 2 2))
	              ; Drawing Depth to Bottom of Excavation.
	              (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (+ (/ station (/ xscale 100)) 0.2) -5.5) "0.15" "90" (rtos (+ (- groundlevel invertlevel) 0.15) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel_n invertlevel_n) 0.15) 2 2))
	            );end progn
	            (progn
;;;	              (princ (rtos station 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel 2 2))
;;;		      (princ "\n")
;;;		      (princ (rtos groundlevel 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos station_n 2 2))
;;;	              (princ "\n")
;;;	              (princ (rtos invertlevel_n 2 2))
;;;	              (princ "\n")
;;;		      (princ (rtos groundlevel_n 2 2))
;;;	              (princ "\n")
	              ; Writing the Invert Level texts.
	              (command "layer" "set" "texts" "")
	              (command "text" "mc" (list (/ station (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel 2 2))
                      (command "text" "mc" (list (/ station_n (/ xscale 100)) -3.5) "0.15" "90" (rtos invertlevel_n 2 2))
	              ; Drawing Depth to Invert Level.
                      (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (/ station (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel invertlevel) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -4.5) "0.15" "90" (rtos (- groundlevel_n invertlevel_n) 2 2))
	              ; Drawing Depth to Bottom of Excavation.
	              (command "layer" "set" "texts" "")
                      (command "text" "mc" (list (/ station (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel invertlevel) 0.15) 2 2))
	              (command "text" "mc" (list (/ station_n (/ xscale 100)) -5.5) "0.15" "90" (rtos (+ (- groundlevel_n invertlevel_n) 0.15) 2 2))
	            );end progn
	          );end if
		);end progn
	      );end if
	    );end progn
	  );end while
	);end progn
      );end if
    );end progn
  );end while
  (close filereader3)
  ; -----------------------------------------------------------------------------------------
  ; Fourth loop, the rest of the Invert Level and the Depth to Invert Level (Just the lines).
  ; -----------------------------------------------------------------------------------------
  (setq filereader4 (open filename "r"))
  (while (/= (setq oneline (read-line filereader4)) nil)
    (progn
      (setq exit_loop_flage "N")
      (setq station (atof (substr oneline 1 8)))
      (setq groundlevel (atof (substr oneline 9 8)))
      (setq invertlevel (atof (substr oneline 25 8)))
      (if (/= station startstation)
        (progn
          (if (/= invertlevel 0.00)
            (progn
	      (while (and (= exit_loop_flage "N") (/= (setq nextline (read-line filereader4)) nil))
	        (progn
	          (setq station_n (atof (substr nextline 1 8)))
		  (setq groundlevel_n (atof (substr oneline 9 8)))
	          (setq invertlevel_n (atof (substr nextline 25 8)))
                  (if (/= invertlevel_n 0.00)
		    (progn
		      (setq exit_loop_flage "Y")
		      ; Drawing lower line.
		      (command "layer" "set" "lower_line" "")
                      (command "line" (list (/ station (/ xscale 100)) (/ (- invertlevel datum) (/ yscale 100))) (list (/ station_n (/ xscale 100)) (/ (- invertlevel_n datum) (/ yscale 100))) "")
		      ; Drawing the Partial Distance line and text.
		      (command "layer" "set" "red_lines" "")
	              (command "line" (list (/ station_n (/ xscale 100)) -1) (list (/ station_n (/ xscale 100)) -2) "")
		      (command "layer" "set" "texts" "")
		      (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -1.5) "0.3" "0" (rtos (- station_n station) 2 2))
		      ; Drawing the Gradient line and text.
	              (command "layer" "set" "red_lines" "")
	              (command "line" (list (/ station_n (/ xscale 100)) -7) (list (/ station_n (/ xscale 100)) -8) "")
		      (command "layer" "set" "texts" "")
		      (if (/= station station_n)
		        (progn
		          (command "text" "mc" (list (/ (+ (/ (- station_n station) 2) (- station startstation)) (/ xscale 100)) -7.5) "0.3" "0" (rtos (/ (- invertlevel_n invertlevel) (- station_n station)) 1 2))
		        )
		      )
		    );end progn
	          );end if
	        );end progn
	      );end while
	    );end progn
          );end if
	);end progn
      );end if
    );end progn of while
  );end while
  (close filereader4)
  ; ------------------------------
  ; Fifth loop, for Pipe Fittings.
  ; ------------------------------
  (setq filereader5 (open filename "r"))
  (while (/= (setq oneline (read-line filereader5)) nil)
    (progn
      (setq station (atof (substr oneline 1 8)))
      (setq pipefitting (atof (substr oneline 33 5)))
      (if (/= pipefitting 0.00)
        (progn
          (cond ((eq pipefitting  1) (setq fitname "s-arv"))
            ((eq pipefitting  2) (setq fitname "d-arv"))
            ((eq pipefitting  3) (setq fitname "flow_mtr"))
            ((eq pipefitting  4) (setq fitname "futr_con"))
            ((eq pipefitting  5) (setq fitname "line_vlv"))
            ((eq pipefitting  6) (setq fitname "wash_out"))
            ((eq pipefitting  7) (setq fitname "adapter"))
            ((eq pipefitting   (setq fitname "elb45"))
            ((eq pipefitting  9) (setq fitname "end"))
            ((eq pipefitting 10) (setq fitname "fta-s"))
            ((eq pipefitting 11) (setq fitname "fta-d"))
            ((eq pipefitting 12) (setq fitname "reducer"))
            ((eq pipefitting 13) (setq fitname "tee-ask"))
            ((eq pipefitting 14) (setq fitname "elb22"))
            ((eq pipefitting 15) (setq fitname "elb11"))
            ((eq pipefitting 16) (setq fitname "t-ask45"))
            ((eq pipefitting 17) (setq fitname "crossing"))
            ((eq pipefitting 18) (setq fitname "end-flsh"))
            ((eq pipefitting 19) (setq fitname "vlv-fm"))
            ((eq pipefitting 20) (setq fitname "r-cross"))
            ((eq pipefitting 21) (setq fitname "w-cross"))
            ((eq pipefitting 22) (setq fitname "meter"))
            ((eq pipefitting 23) (setq fitname "flax-fr"))
            ((eq pipefitting 24) (setq fitname "sudle"))
            ((eq pipefitting 25) (setq fitname "box-culv"))
            ((eq pipefitting 26) (setq fitname "elb90"))
            ((eq pipefitting 27) (setq fitname "prv"))
            ((eq pipefitting 28) (setq fitname "tec"))
            ((eq pipefitting 29) (setq fitname "u-cross"))
            ((eq pipefitting 30) (setq fitname "weld"))
            ((eq pipefitting 50) (setq fitname "av"))
	  )
          (command "insert" fitname (list (/ station (/ 	xscale 100)) -8.5) "1" "1" "0")
	)
      )
    );end progn of while
  );end while
  (close filereader5)
;;;  ; ------------------------------------------------------------------------------
;;;  ; Sixth loop, for the rest of Pipe Fittings. **Right now this loop is not used**
;;;  ; ------------------------------------------------------------------------------
;;;  (setq filereader6 (open filename "r"))
;;;  (while (/= (setq oneline (read-line filereader6)) nil)
;;;    (progn
;;;      (setq exit_loop_flage "N")
;;;      (setq station (atof (substr oneline 1 8)))
;;;      (setq groundlevel (atof (substr oneline 9 8)))
;;;      (setq pipefitting (atof (substr oneline 33 5)))
;;;      (if (/= pipefitting 0.00)
;;;        (progn
;;;	  (while (and (/= (setq nextline (read-line filereader5)) nil) (= exit_loop_flage "N"))
;;;	    (progn
;;;	      (setq station_n (atof (substr nextline 1 8)))
;;;	      (setq groundlevel_n (atof (substr oneline 9 8)))
;;;	      (setq pipefitting_n (atof (substr nextline 33 5)))
;;;              (if (/= pipefitting_n 0.00)
;;;		(progn
;;;		  (setq exit_loop_flage "Y")
;;;		  
;;;		)
;;;	      )
;;;	    )
;;;	  )
;;;	)
;;;      )
;;;    );end progn of while
;;;  );end while
;;;  (close filereader6)
  (command "zoom" "e")
);end water
  )
(prompt
  (strcat "\nTo setup water profile settings Run < WASetup >..."
	  "\n& < water > To run main program..."
  )
)

 

 

Message 25 of 30

hosneyalaa
Advisor
Advisor

ecording_28-09-2020_11-38-59_216181_.gif

0 Likes
Message 26 of 30

marwah.izmeqna
Participant
Participant

تمام...اشتغل

شكراً كتير لجهدك و وقتك

 

😊

 

Message 27 of 30

marwah.izmeqna
Participant
Participant

@hosneyalaa 

عندي مشكلة جديدة ، ممكن تساعدني بحلها؟

Sewer LISP لا يظهر رقم كان يظهره في السابق

 هل التعديل الي عملته اله علاقة

0 Likes
Message 28 of 30

hosneyalaa
Advisor
Advisor

 

"prn"  ممكن من الداتا الموجودة بالملف

 

انا جربت على الامثلة الي مرفقة  شوفيه

ice_screenshot_٢٠٢٠١٠٠٥-٢٢٢٢٢٧.png 

0 Likes
Message 29 of 30

hosneyalaa
Advisor
Advisor

ice_screenshot_٢٠٢٠١٠٠٥-٢٢٤٧٢٩.png

0 Likes
Message 30 of 30

Anonymous
Not applicable
Please send me excel& lisp file to draw profile for sewer and stormwater pipe line autocad on email : salijazal@gmail.com
0 Likes