Cant get lisp to work properly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear forum members,
I made an lisp that needs to open a few dwg's from a list and then do some things
Credits for owners of small lisps I used from them are not for me. They earn the credits for there work
On my system I cant get it to work so I wonder if I made an mistake.
Can someone please help me to get this to work?
What I need to do is following
1. make an list of all dwg files in DIR1 including subfolders
2. process that list to read out specific ATT values
3. write that to an txt file
(defun c:dwglijst ()
(setvar "sdi" 1)
(defun GrabAllFiles (Path FileExt / tempPath FileList)
; [Path] is the path to search it, and all it's sub-directory
; [FileExt] is the extenstion (with the period) of the type of files to look for.
; Example (GrabAllFiles "c:\\" ".dwg")
(setq Path
(if (= (substr Path (strlen Path)) "\\")
Path
(strcat Path "\\")
)
)
(foreach file (vl-directory-files Path)
(setq tempPath (strcat Path file))
(if
(not
(or
(= file ".")
(= file "..")
)
)
(if (vl-file-directory-p tempPath)
(setq FileList (append FileList (GrabAllFiles tempPath FileExt)))
(if (= (strcase FileExt) (strcase (vl-filename-extension tempPath)))
(setq FileList (cons tempPath FileList))
)
)
)
)
FileList
)
(setq a (GrabAllFiles "P:\\Acad\\P3D\\project templates\\Empty Metric Project\\Orthos\\DWGs" ".dwg"))
(foreach dwg a
(command "fileopen" dwg)
(defun LM:getattributevalue ( blk tag / val enx )
(while
(and
(null val)
(= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
)
(if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
(setq val (cdr (assoc 1 enx)))
)
)
)
(setq blk (ssname (ssget "x" (list (cons 0 "INSERT") (cons 2 "Title Block")))0))
(setq strname (LM:GetAttributeValue blk "DWGNAME" ))
(setq iso_str (LM:GetAttributeValue blk "REV" ))
;write to file
(setq fn "D:\\output.txt"
fp (open fn "a")
)
(princ strname fp)
(princ "," fp)
(princ iso_str fp)
(princ "\n" fp)
(close fp)
(setq strname nil)
(setq iso_str nil)
;(setvar "sdi" 0)
;(command "close")
);end foreach
(setvar "sdi" 0)
(command "close" "n")
)
Best regards
Kind Regards