Message 1 of 6
AutoLisp loop not selecting block when looping
Not applicable
03-05-2019
04:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am very new to this and have got something that almost works but just one hiccup. I've got an excel spreadsheet to update the attribute block in multiple layouts but have to select the block for each layout for it to work.
Whenever I run the AutoLisp, it will prompt me to select my block individually as it loops between the layout pages. I just want it to automatically select the block as they are named the same.
Could anyone please help me on this? I have no knowledge in writing the code and can only make a little sense of it. I managed to get this far by just combining a few things I found. Hoping to slowly learn more.
(defun c:upd (/ _delFinder ss e a data b attrvalues)
(foreach layout (layoutlist)
(setvar "ctab" layout)
;;; pBe 21July2014 ;;;
(defun _delFinder (str md / d l str)
(while (setq d (vl-string-position md str nil T))
(setq l (cons (substr str (+ 2 d)) l)
str (substr str 1 d)
)
)
(cons str l)
)
(if (and (setq a nil
data nil
ss (ssget
"_:L:S"
'((0 . "INSERT") (2 . "INDESCO_A1A,`*U*"))
)
)
(eq (vla-get-effectivename
(setq e (vlax-ename->vla-object (ssname ss 0)))
)
"INDESCO_A1A"
)
(setq fn (findfile "RootData.csv"))
)
(progn
(setq of (open fn "r"))
(while (setq a (read-line of))
(setq data (cons (_delFinder a 44) data))
)
(close of)
(setq attrvalues
(vl-remove-if
'(lambda (v)
(member (Car v)
'("LOCATION_ID"
"PIPE_SIZE"
"LENGTH_(IN.)"
"FINISH"
)
)
)
(mapcar '(lambda (at)
(list (strcase (vla-get-tagstring at))
(vla-get-textstring at)
at
)
)
(vlax-invoke e 'Getattributes)
)
)
)
(if (setq b (assoc (cadr (assoc "DRAWING_NO" attrvalues)) data))
(mapcar '(lambda (j h)
(vla-put-textstring (last j) h)
)
(cdr attrvalues)
(cdr b)
)
)
)
)
(princ)
);foreach
)
(vl-load-com)