Hi Maxim,
Thanks for directing me to these resources, they appear to do exactly what I need.
Unfortunately I am a total newbie to AutoLISP and was unable to get Mark's routine over at theswamp.org you referenced here to work. I'll repost my edited version and hopefully you wouldn't mind pointing out where I went wrong.
Retracing my steps:
1) Modified the code to count multiple blocks and saved as BLOCK_COUNT.lsp, here's my modified version (I renamed the test blocks 1 2 and 3:
(defun c:recount (/ block_list cnt env_name)
(setq block_list
(list
(cons '2 "1")
(cons '2 "2")
(cons '2 "3")
)
)
(foreach i block_list
(if
(setq ss (ssget "X" (list '(0 . "INSERT") i)))
(progn
(setq
cnt (itoa (sslength ss))
env_name (strcat "BLOCK_COUNT_" (cdr i))
)
(setenv env_name cnt)
(princ (strcat "\nSet " env_name " to " cnt))
)
)
)
(princ)
)
2) used the APPLOAD command to load the routine named BLOCK_COUNT.lsp
3) inserted three fields into my drawing using the DieselExpression type with the following expressions:
$(getenv, BLOCK_COUNT_1)
$(getenv, BLOCK_COUNT_2)
$(getenv, BLOCK_COUNT_3)
4) ran the command UPDATEFIELD
... and nothing happened.
Any help would be greatly appreciated 🙂