- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I am currently trying to create a .lisp program that automates the editing of attributes in a dynamic block. I have written the code and uploaded it to AutoCAD but am getting the error : malformed list on input. This shows up above the command line after I load it in the load/unload applications tab.
The code works by taking a csv file and separating the entries by columns. The csv file has 5 columns: Block, ID, ID_value, Attribute, Attribute_Value.
This is my first time working on AutoLISP so really anything could be wrong.
Thank you so much for your time and help.
Here is my code, I will also upload the file below:
(defun c:replaceAttributes (filePath)
(if (setq fp (open filePath "r"))
(progn
(while (setq line (read-line fp))
(if (> (length line) 0)
(progn
(setq values (mapcar 'atoi (strsplit line ",")))
(setq blockName (nth 0 values))
(setq attribName (nth 1 values))
(setq newValue (nth 2 values))
(if (setq b (ssget (list (cons 0 "INSERT") (cons 2 blockName))))
(progn
(foreach b (entget b)
(if (and (equal (cdr (assoc 2 b)) blockName) (equal (cdr (assoc 70 b)) 1))
(progn
(if (setq a (ssget (list (cons 0 "ATTRIB") (cons 8 b) (list (cons 2 attribName)))))
(progn
(setq attribs (entget a))
(if (setq index (assoc 2 attribName attribs))
(progn
(setq newAttribs (subst (cons 2 newValue) index attribs))
(entmod newAttribs)
)
)
)
)
)
)
)
)
)
)
)
(close fp)
(alert "Attributes replaced.")
)
(alert (strcat "File " filePath " not found."))
)
)
Solved! Go to Solution.