therealjd Posted February 6, 2020 Share Posted February 6, 2020 (edited) I'm hoping someone could help me with a lisp that will do the following.. 1. swap all instances of a block with another block (keeping location, rotation, scale) 2. change that new block to a new layer. i'd like to automate this through the use of a csv file. If the old block doesn't exist, skip it. oldblock1,newblock1,newlayer1 oldblock2,newblock2,newlayer2 Any help would be appreciated I did find this code on the forum, but i'm unsure how to alter it. ; ; thanks to Lee-mac for this defun (defun _csv->lst ( str / pos x lst lst2) (if (setq pos (vl-string-position 44 str)) (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2)))) (list str) ) ) (defun c:ins->csv ( / fo x) (setq fo (open (getfiled "Choose CSV file" "G:/AutoCAD/Lisp/" "CSV" ) "R") (while (setq ans (read-line fo)) (setq lst (cons (_csv->lst ans) lst)) ) (setq y (length lst)) (setq x (- y 1)) (repeat y (setq lst2 (nth x lst)) ;(setvar 'clayer (nth 6 lst2)) (command "insert" (nth 0 lst2) (strcat (nth 1 lst2)","(nth 2 lst2)","(nth 3 lst2)) 1 (nth 5 lst2) (nth 7 lst2) (nth 8 lst2)) (setq x (- x 1)) ) ) ; end defun Edited February 6, 2020 by therealjd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.