You are on page 1of 2

chain_n.lsp Page:4/4 chain_n.

lsp Page:1/4
c:\documents and settings\vernon\my documents\ Last modification: 29/02/2012 16:30:34 c:\documents and settings\vernon\my documents\ Last modification: 29/02/2012 16:30:34

217: "text" txtend "3" "90" tmptxt 1: (defun C:chain()


218: ) 2:
219: (setq loop 0) 3: (defun input()
220: (repeat sect 4:
221: (setq txtmid (list (- xid 1) (+ txtdn (* loop incr))) 5: (setq dwght (defa "\nWidth of Drawing <" 297)
222: loop (1+ loop)) 6: scale (defa "\nScale of Drawing <" 1500)
223: (command "text" txtmid "3" "90" tmptxt) 7: fact (/ 1000.0 scale)
224: ) 8: name nil
225: 9: )
226: (if (and (< (abs (atof mtrtxt)) 100.000) (>= (abs (atof mtrtxt)) 10.0)) 10: (while (= name nil)
227: (setq mtrtxt (strcat "0" (rtos (abs (atof mtrtxt)) 2 2))) 11: (setq name (getfiled "Select a Data File" "" "txt" 2))
228: ) 12: )
229: (if (< (abs (atof mtrtxt)) 10.0) 13:
230: (setq mtrtxt (strcat "00" (rtos (abs (atof mtrtxt)) 2 2))) 14: (getlg)
231: ) 15:
232: 16: (if semicol
233: (command "line" chline1 chline2 "") 17: (progn
234: (setq tram (ssadd (entlast) tram)) 18: (princ "\n\nConvert Absolute Chainages to Relative ? ")
235: (command "text" "j" "r" mtrpt "2.3" "90" mtrtxt) 19: (initget 1 "Yes No")
236: (setq tram (ssadd (entlast) tram)) 20: (setq cnvt (getkword "(Yes/No) : "))
237: (if (and (/= kmtxt nil) (/= cnvt "Yes")) 21: (if (= cnvt "Yes")
238: (progn 22: (progn
239: (command "text" "j" "c" kmpt "2.3" "90" kmtxt) 23: (princ "\n\nShow Absolute or Relative Chainages? ")
240: (setq tram (ssadd (entlast) tram)) 24: (initget 1 "Absolute Relative")
241: ) 25: (setq abschn (getkword "(Absolute/Relative) : "))
242: ) 26: )
243: (command "text" "j" "r" gearpt "2.3" "90" geartxt) 27: )
244: (setq tram (ssadd (entlast) tram)) 28: )
245: 29: )
246: (setq data (read-line infile)) 30:
247: ) 31: (setq y1 (- dwght 75) y2 15 ref (- dwght 5)
248: (close infile) 32: obbl (list 0 0) obbr (list dwglg 0)
249: (command "_.chprop" tram "" "LA" "0" "" 33: obtl (list 0 dwght) obtr (list dwglg dwght)
250: "-layer" "s" "0" "" 34: ibbl (list 25 5) ibbr (list (- dwglg 5) 5)
251: "-layer" "lo" "chain" "") 35: ibtl (list 25 ref) ibtr (list (- dwglg 5) (- dwght 5))
252: 36: hor1_1 (list 25 (- dwght 23)) hor1_2 (list (- dwglg 5 163) (- dwght 23))
253: ) 37: hor2_1 (list 25 (- dwght 35)) hor2_2 (list (- dwglg 5 163) (- dwght 35))
254: 38: tr_ch (list 30 (- dwght 14)) tr_km (list 30 (- dwght 29))
255: ;; MAIN 39: )
256: 40: )
257: (setvar "cmdecho" 0) 41:
258: (input) 42: (defun draw_bd()
259: (draw_bd) 43: (setvar "limmax" (list (+ dwglg 5) (+ dwght 5)))
260: (proc_file) 44: (command "rectangle" obbl obtr "rectangle" ibbl ibtr
261: (princ) 45: "line" hor1_1 hor1_2 "" "line" hor2_1 hor2_2 ""
262: 46: "insert" "*SPTB" ibbr "" "")
263: ) ; END 47: (setvar "textstyle" "arial")
264: 48: (command "text" "j" "bc" tr_ch "3" "90" "CH."
49: "text" "j" "bc" tr_km "3" "90" "Km."
50: "zoom" "e")
51:
52: (if (> dwght 297)
53: (progn
54: (setq
55: strw1 (list (- dwglg 15) 270)
56: strw2 (list (- dwglg 175) 270)
57: strdif (- dwght 297)
58: strobj (ssget "c" strw1 strw2)
59: cnt 0
60: )
61: (if (/= strobj nil)
62: (while (< cnt (sslength strobj))
63: (setq elst (entget (ssname strobj cnt))
64: pt1 (cdr (setq sub (assoc 11 elst)))
65: newpt (list (car pt1) (+ (cadr pt1) strdif))
66: )
67: (entmod (subst (cons 11 newpt) sub elst))
68: (setq cnt (1+ cnt))
69: )
70: )
71: )
72: )
PSPad editor 4.5.3 (2298) www.pspad.com 01/03/2012 11:11:32 Vernon PSPad editor 4.5.3 (2298) www.pspad.com 01/03/2012 11:11:32 Vernon
chain_n.lsp Page:2/4 chain_n.lsp Page:3/4
c:\documents and settings\vernon\my documents\ Last modification: 29/02/2012 16:30:34 c:\documents and settings\vernon\my documents\ Last modification: 29/02/2012 16:30:34

73: ) 145: )
74: 146: )
75: (defun getlg() 147:
76: 148: )
77: (setq 149:
78: infile (open name "r") 150: (defun defa (wdprmpt val)
79: data (read-line infile) 151:
80: ) 152: (setq oldval val)
81: (extract data) 153: (setq wdprmpt
82: (setq clid ch_val 154: (strcat wdprmpt (rtos oldval 2 0) ">: ")
83: minim ch_val 155: )
84: maxim ch_val 156: (setq new_val (getreal wdprmpt))
85: ) 157: (if (not (or (= new_val "") (null new_val)))
86: 158: (setq oldval new_val)
87: (while (/= data nil) 159: )
88: 160: oldval
89: (extract data) 161: )
90: (cond 162:
91: ((< ch_val minim) 163: (defun proc_file()
92: (setq minim ch_val)) 164:
93: ((> ch_val maxim) 165: (setvar "dimzin" 0)
94: (setq maxim ch_val)) 166: (setvar "luprec" 2)
95: ) 167: (setq
96: (setq data (read-line infile)) 168: infile (open name "r")
97: ) 169: data (read-line infile)
98: (close infile) 170: )
99: (setq ch_len (* fact (- maxim minim)) 171:
100: dwglg (+ ch_len 200 50) 172: (command "-layer" "m" "chain" "c" "cyan" "" "")
101: clpt (+ (* (- clid minim) fact) 50) 173: (setq tram nil tram (ssadd))
102: ) 174:
103: ) 175: (while (/= data nil)
104: 176: (extract data)
105: (defun strpos (string srchar / len tststr tstchr cnt chk) 177: (setq
106: 178: ch_diff (- ch_val clid)
107: (setq len (strlen string) 179: offset (* ch_diff fact)
108: cnt 1 180: xid (+ offset clpt)
109: pos nil 181: txtup (- dwght 90) txtdn 20
110: ) 182: chline1 (list xid ref)
111: (while (<= cnt len) 183: chline2 (list xid (- ref 50))
112: (setq chk (substr string cnt 1)) 184: mtrpt (list (1- xid) (- ref 1.5))
113: (if (= chk srchar) 185: kmpt (list (1- xid) (- ref 24))
114: (setq pos cnt cnt len) 186: gearpt (list (1- xid) (- ref 33.5))
115: ) 187: tmpline1 (list xid y1) tmpline2 (list xid y2)
116: (setq cnt (1+ cnt)) 188: tmplg (- txtup txtdn)
117: ) 189: sect (1+ (fix (/ tmplg 95)))
118: pos 190: incr (/ tmplg sect)
119: ) 191: txtst (list (- xid 1) txtup)
120: 192: txtend (list (- xid 1) txtdn)
121: (defun extract ( data ) 193: )
122: 194:
123: (setvar "dimzin" 0) 195: (if (= cnvt "Yes")
124: (setq semicol (strpos data ";") 196: (progn
125: deci (strpos data ".") 197: (setq
126: spc (strpos data " ") 198: mtr (rtos ch_diff 2 2)
127: geartxt (substr data (1+ spc)) 199: mtrtxt (rtos (abs (atof mtr)) 2 2)
128: ) 200: )
129: 201: (if (= abschn "Absolute")
130: (if (not semicol) 202: (progn
131: (progn 203: (setq tmptxt (strcat kmtxt "," strmtr))
132: (setq mtr (substr data 1 (1- spc)) 204: )
133: ch_val (atof mtr) 205: (progn
134: mtrtxt (rtos (abs ch_val) 2 2) 206: (setq tmptxt mtr)
135: kmtxt nil 207: )
136: ) 208: )
137: ) 209: )
138: (progn 210: (progn
139: (setq mtr (substr data (1+ semicol) (- spc (1+ semicol))) 211: (setq tmptxt mtr)
140: mtrtxt mtr 212: )
141: strmtr mtr 213: )
142: kmtxt (substr data 1 (1- semicol)) 214:
143: ch_val (+ (* (atof kmtxt) 1000.00) (atof mtrtxt)) 215: (command "line" tmpline1 tmpline2 "")
144: ) 216: (command "text" txtst "3" "90" tmptxt
PSPad editor 4.5.3 (2298) www.pspad.com 01/03/2012 11:11:32 Vernon PSPad editor 4.5.3 (2298) www.pspad.com 01/03/2012 11:11:32 Vernon

You might also like