Input data from .txt file
Input data from .txt file
(OP)
I wrote a lisp program for draw profile.
But I have trouble with input data from text file , ex : I input data in Excel file after that save as to text file.
In data have two colunme
Elev Distance
2.0 100
1.0 300
I need a advice for write this sub-code.
Hope someone help me.
Thanks you very much.
But I have trouble with input data from text file , ex : I input data in Excel file after that save as to text file.
In data have two colunme
Elev Distance
2.0 100
1.0 300
I need a advice for write this sub-code.
Hope someone help me.
Thanks you very much.





RE: Input data from .txt file
I can give you a hand if you send me a copy of your file.
Roberttx.
RE: Input data from .txt file
I done with manual input.
Thanks
;;;;;;;;;;;;;;;;;;;;;;;;
;lisp file, file name QpB.lsp command qpb
(defun prof (/ cm p1 p2 dist1 dist2 d1 d2 d3 d4 in1 in2 in it1 it2 it do)
(if (tblsearch "layer" "C-SSWR1")
(command "-layer" "S" "C-SSWR1" "")
(command "-layer" "N" "C-SSWR1" "c" 3 "C-SSWR1" "L" "Continuous" "C-SSWR1" "s" "C-SSWR1" "")
)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq vs (atof vs))
(setq hs (atof hs))
(setvar "osmode" 512)
(setq p2 (getpoint "\nElevation 0.0: "))
(print p2)
(if (= p2 nil)(quit))
(setvar "osmode" 0)
(setq d1 (getreal "\Provide start Elevation: "))
;(if (= d1 "")(quit))
(setq d2 (* vs d1))
;(print d2)
(setq d3 (cadr p2) )
;(type d3)
;(print d3)
(setq d4 (- d3 d2))
;(print d4)
; (setq d5 (rtos d4 2 3))
;(print d5)
; (setq k (- (cadr p2) d) )
(setq p1 (list(car p2) (+ d3 d2)))
;(print p1)
(setq dist (getreal "\Provide Horiz. Distance: "))
(if (= dist "")(quit))
(setq dist2 (* hs dist))
(setq dist1 (rtos dist2))
(setq it (getreal "\nProvide Elevation: "))
(if (= it "")(quit))
(setq it2 (-(* vs it)d2))
(setq it1 (rtos it2))
(setq do (strcat "@" dist1 "," it1))
;(print do)
(command "pline" p1 do "")
(command"pedit" "l" "" "")
(command "select" "l" "")
(setq d5 (* vs it))
(while
(setq dist (getreal "\Provide Horiz. Distance or press return when done: "))
(if (= dist "")(quit))
(setq dist2 (* hs dist))
(setq dist1 (rtos dist2))
(setq in (getreal "\nProvide Elevation: "))
(if (= in "")(quit))
(setq in2 (-(* vs in) d5 ))
(setq in1 (rtos in2))
(setq do (strcat "@" dist1 "," in1))
(setq do (strcat "@" dist1 "," in1))
(command "pline" "" do "")
(command"pedit" "l" "" "")
(command "pedit" "l" "j" "p" "" "")
(command "select" "l" "")
(setq d5 (* vs in))
)
(setvar"cmdecho" cm)
(princ)
)
;===============================================================
(defun eb1 ()
(setq vs (get_tile "eb1"))
)
;===============================================================
(defun eb2 ()
(setq hs (get_tile "eb2"))
)
;===============================================================
(defun rb1 ();(/ man)
(setq man (get_tile "rb1"))
)
;===============================================================
(defun rb2 ();(/ fil)
(setq fil (get_tile "rb2"))
)
;===============================================================
(defun hlp()
(help"qpb")
)
;===========================================================;===========================================================(defun c:qpb (/ eb1a eb2a)
(setq vs nil)
(setq hs nil)
(setq man nil)
(setq fil nil)
(setq dcl_id (load_dialog "qpb.dcl"))
(if (not (new_dialog "qpb" dcl_id)) (exit))
(setq rrb1 "1")
(set_tile "rb1" rrb1)
(mode_tile "rb1" 2)
(setq eb1a "1")
(set_tile "eb1" eb1a)
(mode_tile "eb1" 2)
(setq eb2a "1")
(set_tile "eb2" eb2a)
(mode_tile "eb2" 2)
(action_tile "eb1" "(eb1)")
(action_tile "eb2" "(eb2)")
(action_tile "rb1" "(rb1)")
(action_tile "rb2" "(rb2)")
;
(action_tile "accept" "(done_dialog)")
(action_tile "cancel" "(exit)")
(action_tile "help" "(hlp)")
;
(start_dialog)
(unload_dialog dcl_id)
;=======================================================
(if (= vs nil)(setq vs "1"))
(if (= hs nil)(setq hs "1"))
(if
(and
(= man nil)
(= fil nil)
)
(setq man "1")
)
(cond
((= man "1")(prof))
((= fil "1")(alert"\nComming Soon...I am working on it!"))
)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;dcl file, file name QpB.dcl
dcl_settings : default_dcl_settings { audit_level = 3 ; }
qpb : dialog {
initial_focus = "rb1" ;
key = "qpb" ;
label = "qpb" ;
value = "Quick Profile Builder" ;
: row {
key = "r1" ;
: edit_box {
fixed_width = true ;
key = "eb1" ;
label = "Vertical Scale:" ;
width = 10 ;
}
: spacer {
fixed_width = true ;
width = 4 ;
}
: edit_box {
fixed_width = true ;
key = "eb2" ;
label = "Horizontal Scale:" ;
width = 10 ;
}
}
: radio_row {
key = "rr1" ;
: radio_button {
key = "rb1" ;
label = "Manual" ;
width = 2 ;
}
: radio_button {
key = "rb2" ;
label = "From File" ;
width = 2 ;
}
: spacer {
fixed_width = true ;
width = 22 ;
}
}
ok_cancel_help ;
}
RE: Input data from .txt file
Also with this procedure, you can control the scaling of the x or y within excel before pasting.
RE: Input data from .txt file
Nobody could say it better. I guess that's the simplest solution to create a profile with such data.
Roberttx.
RE: Input data from .txt file
Your method is Ok. but it does not look like professional way.
Roberttx : how is your comment about lisp file ? Too mess ;)
RE: Input data from .txt file
I read it. I am not into dialog boxes. I am sorry. Good luck. Anyway, using Bayou's suggestion, you can still modify the profile using custom made lisp apps, like labeling slope, endpoints, lengths, etc. For instance, I am sending you a slope program I made.
Robertx.
(defun c:sc5 ()
(setvar "cmdecho" 0)
(setq old_osnap (getvar "osmode"))
(setvar "osmode" 512)
(princ "\nSlope on x-section grid.")
(setq
p1 (getpoint "\nFrom point.")
p2 (getpoint "...to point...")
dify (- (cadr p2) (cadr p1))
difx (- (car p2) (car p1))
sl5 (/
(* dify 5.0)
(* difx 10.0)
)
invslope (/ 1.0 sl5)
sl5 (rtos sl5 2 3)
invslope (strcat (rtos invslope 2 2) ":1")
)
(princ "\nSlope= ")(princ sl5)(princ " or ")(princ invslope)
(setvar "osmode" old_osnap)
(princ)
);defun