- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm super new to all of this, so I'm sorry if it seems like a stupid question. I am writing a LISP file that exports all blocks' x and y position data in the currently open AutoCAD Electrical drawing. Is there a way to change it from the currently open drawing to iterating or looping through all of the drawings in a specific folder or .wdp project file?
Thanks
Here is my current code:
(defun c:ExportBlockPositionData ()
(setq file (getfiled "Select File to Save" "" "csv" 1))
(setq blk_list '())
(setq ss (ssget "_X" '((0 . "INSERT"))))
(if ss
(progn
(setq count (sslength ss))
(setq output_string "Block Name,X Position,Y Position\n")
(setq i 0)
(while (< i count)
(setq blk (ssname ss i))
(setq blk_name (cdr (assoc 2 (entget blk))))
(setq blk_pos (cdr (assoc 10 (entget blk))))
(setq output_string (strcat output_string blk_name "," (rtos (car blk_pos) 2 2) "," (rtos (cadr blk_pos) 2 2) "\n"))
(setq i (1+ i))
)
(setq file_id (open file "w"))
(write-char (ascii "sep=,\n") file_id) ; Excel separator
(write-line output_string file_id)
(close file_id)
(princ "\nBlock position data exported successfully.")
)
(princ "\nNo blocks found in the drawing.")
)
(princ)
)
Solved! Go to Solution.