
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
;;ple.lsp
(vl-load-com)
(defun c:ple (/ elist en i layer layer_list
leng pline row ss sumlen total
x xlApp xlBook xlBooks xlCells xlSheet
xlSheets
)
(setq xlApp (vlax-get-or-create-object "Excel.Application")
xlBooks (vlax-get-property xlApp "Workbooks")
xlBook (vlax-invoke-method xlBooks "Add")
xlSheets (vlax-get-property xlBook "Sheets")
xlSheet (vlax-get-property xlSheets "Item" 1)
xlCells (vlax-get-property xlSheet "Cells")
)
(vla-put-visible xlApp :vlax-true)
;headers
(vlax-put-property xlCells "Item" 1 1 "NO")
(vlax-put-property xlCells "Item" 1 2 "LAYER")
(vlax-put-property xlCells "Item" 1 3 "PANJANG (MTR)")
(setq row 2
total 0)
(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE"))) i -1)
(repeat (sslength ss)
(setq en (ssname ss (setq i (1+ i)))
elist (entget en)
layer (cdr (assoc 8 elist)))
(if (not (member layer layer_list))
(setq layer_list (cons layer layer_list)))
)
(repeat (length layer_list)
(setq layer (car layer_list))
(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE")(cons 8 layer))) i -1 sumlen 0)
(repeat (sslength ss)
(setq pline (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
(setq leng (vlax-curve-getdistatparam pline
(vlax-curve-getendparam pline)))
(setq sumlen (+ sumlen leng)))
(vlax-put-property xlCells "Item" row 1 (1- row))
(vlax-put-property xlCells "Item" row 2 layer)
(vlax-put-property xlCells "Item" row 3 (rtos (/ sumlen 1000) 2 2))
(setq total (+ total sumlen))
;;; (vlax-put-property xlCells "Item" row 2 (rtos (/ sumlen 1000) 2 2)); for metric units
(setq layer_list (cdr layer_list))
(setq row (+ row 1))
)
(setq row (+ row 1))
; footers:
(vlax-put-property xlCells "Item" row 2 "TOTAL:")
(vlax-put-property xlCells "Item" row 3 (rtos (/ total 1000) 2 2))
(vlax-put-property xlCells "Item" row 4 "MTR")
;;;(vlax-put-property xlCells "Item" row 3 (rtos (/ total 1000) 2 2)); for metric units
(mapcar (function (lambda(x)
(vl-catch-all-apply
(function (lambda()
(progn
(vlax-release-object x)
(setq x nil)))))))
(list xlCells xlSheet xlSheets xlBook xlBooks xlApp)
)
(alert "Simpan dan tutup file nya manual")
(alert "Bud's Colletion.......")
(gc)(gc)
(princ)
)
(princ "\t\t***\t Type PLE untuk disimpan di Excel\t***")
(princ "\t\t***\t Bud's Colletion......\t***")
(princ)
Solved! Go to Solution.