블럭 속성값 변경
컨텐츠 정보
- 230 조회
- 0 추천
- 0 비추천
- 목록
본문
안녕하세요
그냥 인풋박스로 값을 적어서
블럭 속성에 있는 'SIZE'란 테그 값을 변경하고 싶은데
샘플 자료 가 없을까요?
엑셀에서 올리는 건 있는 것 같은데
응용하려고 하는데 주석이 없어서 이해하기 좀 힘듭니다.
도와 주시면 감사하겠습니다.
책을 다 뒤져도 안 나와서요
아니면 아래 코드 설명이라도 부탁드려도 될까요?
감사합니다.
(defun c:aaa( / dir dwgs csv )
(sPTE:111230-j)
(setq dir (LM:DirectoryDialog "Select Lisp Fold….." nil 1)
dwgs (LM:GetAllFiles dir nil "*.dwg")
csv (LM:GetAllFiles dir nil "*.csv")
)
(if (= (length csv) 1)
(progn
(setcfg "appdata/pte/temp" (car csv))
(PTE:script dwgs "(PTE:Csv->AttText)" t)
)
(alert "1개의 csv파일이 존재해야 합니다.")
)
)
(defun c:bbb( / dir csv )
(sPTE:111230-j)
(setq dir (getvar 'DWGPREFIX))
(if (eq "\" (substr dir (strlen dir)))
(setq dir (substr dir 1 (1– (strlen dir))))
)
(setq csv (LM:GetAllFiles dir nil "*.csv"))
(if (= (length csv) 1)
(progn
(setcfg "appdata/pte/temp" (car csv))
(PTE:Csv->AttText)
)
(alert "1개의 csv파일이 존재해야 합니다.")
)
)
(defun PTE:Csv->AttText( / ss lst )
(sPTE:111230-k)
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
lst (PTE:ReadCSV (getcfg "appdata/pte/temp"))
)
(if (setq ss(ssget "x" '((0 . "INSERT") (66 . 1))))
(progn
(vlax-for block (vla-get-ActiveSelectionset doc)
(foreach attrib (LM:GetAttributes block)
(if (setq l(assoc (car attrib) lst))
(LM:SetAttributeValue block (car attrib) (cadr l))
)
)
)
)
)
)
(defun sPTE:111230-j nil
(defun PTE:script ( dwgs cmd save / fname f )
(setq fname (vl-filename-mktemp "ST-script.scr")
f (open fname "w")
)
(if (= (getvar 'DWGTITLED) 1)
(progn
(write-line "_.QSAVE" f)
(write-line "_.CLOSE" f)
)
)
(foreach dwg dwgs
(progn
(write-line (strcat "_.OPEN "" dwg """) f)
(write-line cmd f)
(if save (write-line "_.QSAVE" f))
(write-line "_.CLOSE" f)
)
)
(close f)
(command "_.SCRIPT" fname)
(vl-file-delete fname)
)
(defun LM:DirectoryDialog ( msg dir flag / Shell HWND Fold Self Path ac )
;; ? Lee Mac 2010
(setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object))"Shell.Application")
HWND (vl-catch-all-apply 'vla-get-HWND (list ac))
Fold (vlax-invoke-method Shell 'BrowseForFolder
(if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)
)
(vlax-release-object Shell)
(if Fold
(progn
(setq Self (vlax-get-property Fold 'Self) Path (vlax-get-property Self'Path))
(vlax-release-object Self)
(vlax-release-object Fold)
(and (= "\" (substr Path (strlen Path)))
(setq Path (substr Path 1 (1– (strlen Path))))
)
)
)
Path
)
(defun LM:GetAllFiles ( Dir Subs Filetype / _GetSubFolders )
(defun _GetSubFolders ( folder )
(apply 'append
(mapcar
(function
(lambda ( f )
(cons (setq f (strcat folder "\" f)) (_GetSubFolders f))
)
)
(vl-remove "." (vl-remove ".." (vl-directory-files folder nil -1)))
)
)
)
(apply 'append
(mapcar
(function
(lambda ( Filepath )
(mapcar
(function
(lambda ( Filename ) (strcat Filepath "\" Filename))
)
(vl-directory-files Filepath Filetype 1)
)
)
)
(cons Dir (if subs (_GetSubFolders Dir)))
)
)
)
)
(defun sPTE:111230-k nil
(defun LM:SetAttributeValue ( block tag value ) (setq tag (strcase tag))
(vl-some
(function
(lambda ( attrib )
(if (eq tag (strcase (vla-get-TagString attrib)))
(progn (vla-put-TextString attrib value) value)
)
)
)
(vlax-invoke block 'GetAttributes)
)
)
(defun LM:GetAttributes ( block )
(mapcar
(function
(lambda ( attrib )
(cons (vla-get-TagString attrib) (vla-get-TextString attrib))
)
)
(vlax-invoke block 'GetAttributes)
)
)
(defun PTE:str->lst ( s d / p )
(if (setq p (vl-string-search d s))
(cons (substr s 1 p) (PTE:str->lst (substr s (+ p 1 (strlen d))) d))
(list s)
)
)
(defun PTE:ReadCSV ( f / l n )
(cond
(
(setq f (open f "r"))
(while (setq n (read-line f))
(setq n (PTE:str->lst n ","))
(setq l (cons (cons (strcase (car n)) (cdr n)) l))
)
(close f)
)
)(reverse l)
)
)