Community
@bart_van_tuyl wrote:
Hi, I'm sorry I'm unable to post code but I'm ussing a mobile phone today.
I would like to count blocks and adjust the attribute accordingly thus if I have 5 blocks on screen and insert one more that the attribute of the new block says 6. At the moment I can only change the attribute of all the blocks of that type. How can I archive this with lisp?
As a "demo"
(defun c:demo (/ ss) (if (setq ss (ssget "_X" (list '(0 . "INSERT") '(2 . "MyBlock");; change to your block name '(66 . 1) (cons 410 (getvar 'CTAB)) ) ) ) (command "-insert" "MyBlock" pause 1 1 0 (itoa (1+ (sslength ss))) "")");; change to your block name (command "-insert" "MyBlock" pause 1 1 0 "1" "")");; change to your block name ) (princ) )
Henrique
If you want to change your function to all Block Inserts and not just a specific Block Name then remove these two lines from your code:
'(2 . "MyBlock");; change to your block name '(66 . 1)
If you want the user to enter a specific block name then you'll have to add:
(setq blkname (getstring"\nEnter Block Name to Insert: "))
Then replace:
'(2 . "MyBlock");; change to your block name
with this:
(cons 2 blkname)
and replace these:
(command "-insert" "MyBlock"
with this:
(command "-insert" blkname