I have a script in AUTOCAD lisp, it gets data from block - see below code. Please write…
- User
I have a script in AUTOCAD lisp, it gets data from block - see below code. Please write similar escript that will import all the attributes into all instances of the mentioned block.
CODE:
(defun c:ExportBlockAtts (/ sel blkObj atts fname fh tag val) (vl-load-com)
;; Prompt for source block (if (setq sel (car (entsel "\nSelect source block: "))) (if (= "INSERT" (cdr (assoc 0 (entget sel))))
;; Get attributes and ask for CSV filename (progn (setq blkObj (vlax-ename->vla-object sel) atts (vlax-invoke blkObj 'GetAttributes) fname (getfiled (strcat "Save attributes for “" (vla-get-effectivename blkObj) "”") (strcat (vla-get-effectivename blkObj) ".csv") "csv" 1)) (if fname ;; Write CSV (progn (setq fh (open fname "w")) (write-line "Tag,Value" fh) (foreach a atts (setq tag (vla-get-tagstring a) val (vla-get-textstring a)) (write-line (strcat tag "," val) fh)) (close fh) (princ (strcat "\nExported " (itoa (length atts)) " attributes to “" fname "”.")) ) (princ "\nOperation canceled.") ) ) (princ "\nSelected entity is not a block.") ) (princ "\nNo selection made.")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.