속성블럭의 속성을 export하는 리습인데 수정 부탁드립니다
컨텐츠 정보
- 450 조회
- 2 댓글
- 0 추천
- 0 비추천
-
목록
본문
(defun c:demo ( / ss i vl_e ins_point valid_tag All_data filetowrite xlCells Excel_exist col row)
;; pBe May 2018
(if
(and
(setq All_data nil
ss (ssget "_X" '((0 . "INSERT")(66 . 1)(410 . "Model"))))
(repeat (setq i (sslength ss))
(setq vl_e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(setq ins_point (vlax-get vl_e 'Insertionpoint))
(if (setq valid_tag
(Cdr (assoc "TYPE"
(mapcar '(lambda (at)
(list (vla-get-tagstring at) (vla-get-textstring at))
)
(vlax-invoke vl_e 'GetAttributes)
)
)
)
)
(setq All_data (cons (list (vla-get-EffectiveName vl_e)
(Car valid_tag) (rtos (car ins_point) 2) (rtos (cadr ins_point) 2) (rtos (caddr ins_point) 2) (Cadr valid_tag)
)
All_data))
)
All_data
)
)
(cond
( (null All_data) )
( (setq Excel_exist (vlax-get-or-create-object "Excel.Application"))
(setq col 1 row 1)
(setq xlCells (vlax-get-property
(vlax-get-property
(vlax-get-property
(vlax-invoke-method
(vlax-get-property Excel_exist "Workbooks")
"Add"
)
"Sheets"
)
"Item" 1
)
"Cells"
)
)
((lambda (n)
(foreach val '("Block Name" "Value" "X" "Y" "Z" "Level" )
(vlax-put-property xlCells 'Item row (setq n (1+ n)) val)
)
)
0
)
(vlax-put-property xlCells 'ColumnWidth 15.00)
(foreach itm (vl-sort All_data '(lambda (a b)(< (Car a)(car b))))
(setq row (1+ row))
((lambda (n)
(foreach val itm
(vlax-put-property xlCells 'Item row (setq n (1+ n)) val)
)
)
0
)
)
(vla-put-visible Excel_exist :vlax-true)
(mapcar (function (lambda (obj)
(and obj (eq 'VLA-OBJECT (type obj)) (not (vlax-object-released-p obj))
(not
(vl-catch-all-error-p
(vl-catch-all-apply
(function vlax-release-object) (list obj)
)
)
)
)
)
)
(list Excel_exist xlCells))
(setq Excel_exist nil
xlCells nil)
)
( (setq csvfile (getfiled "Enter CSV file name"
(strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname))) "CSV" 1))
(setq filetowrite (open csvfile "w"))
(foreach itm (vl-sort All_data '(lambda (a b)(< (Car a)(car b))))
(write-line (strcat (Car itm) "," (Cadr itm)) filetowrite))
(close filetowrite)
(startapp "notepad")
)
)
)
(princ)
)
이건데 태그가 TYPE인 속성만 export가 되고 있는데 태그가 LEVEL인 속성도 함께 출력되도롭하고싶은데 수정하다가 막혔네요 ㅠㅠ