Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change attributes block

3 REPLIES 3
Reply
Message 1 of 4
bart_van_tuyl
259 Views, 3 Replies

change attributes block

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?
3 REPLIES 3
Message 2 of 4
hmsilva
in reply to: bart_van_tuyl


@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

EESignature

Message 3 of 4
paullimapa
in reply to: hmsilva

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)

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 4
paullimapa
in reply to: hmsilva

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


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost