-
Notifications
You must be signed in to change notification settings - Fork 5
/
_elevation_profile.lsp
46 lines (35 loc) · 1.81 KB
/
_elevation_profile.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
; DRAW ELEVATION PROFILE
; ----------------------
;; Written by: Gyanendra Gurung ;;
; This program draws an elevation profile along the E-W direction
(vl-load-com)
(setq acadDocument (vla-get-activeDocument (vlax-get-acad-Object ))) ; set active Document
(setq mspace (vla-get-modelSpace acadDocument)) ; Set modelSpace
(setq file (getfiled "Select CSV file" "" "csv" 16)) ; Get CSV file
; (a) Draw profile along E-W direction
; ------------------------------------
(setq xValues '())
(progn
(setq fso (vlax-create-object "Scripting.FileSystemObject")
fileobject (vlax-invoke fso "GetFile" file)
openfileas (vlax-invoke fileobject "OpenasTextStream" 1 0)
)
(setq temp (vlax-invoke openfileas "ReadLine"))
(setq pos (vl-string-search "," temp 0))
(setq pt1 (substr temp 1 pos)) ; Read z value (height)
(setq pt2 (substr temp (+ pos 2) (strlen temp))) ; Read m value (EASTING)
; Read y value (NORTHING)
(setq startPoint (vlax-3d-point (atof pt1) (atof pt2) 0)) ; Prepare Start Point of LINE feature
(while (= (vlax-get openfileas "AtEndOfStream") 0) ; while end-of-file is FALSE (0)
(setq temp (vlax-invoke openfileas "ReadLine"))
(setq pos (vl-string-search "," temp 0))
(setq pt1 (substr temp 1 pos))
(setq pt2 (substr temp (+ pos 2) (strlen temp)))
(setq endPoint (vlax-3d-point (atof pt1) (atof pt2) 0))
(setq myLine (vla-addLine mspace startPoint endPoint)) ; Draw line
(setq starPoint endPoint)
)
(vlax-release-object openfileas)
(vlax-release-object fileobject)
(vlax-release-object fso )
)