LISP for addressing dynamic blocks just by clicking on them in order

LISP for addressing dynamic blocks just by clicking on them in order

filip_novoselec
Explorer Explorer
546 Views
3 Replies
Message 1 of 4

LISP for addressing dynamic blocks just by clicking on them in order

filip_novoselec
Explorer
Explorer

Hi everyone!

 

Im in need of a lisp that will prompt you to enter loop number and ordinal number within the loop (just two attributes divided by a fixed constant attribute "/") and then once you click on the first dynamic block it will assign the attributes you wrote in, but afterwards any block you click on (of the same kind) it will assign the loop number as is, but the ordinal number it will increase by one for each block you press on next depending on what the last number was. Ive tried using ChatGPT and the likes but none seem to figure it out... Could i get some help with coding? Also could it be that this just isnt possible in AutoCAD LT?

 

Thanks in advance!

 

 

0 Likes
Accepted solutions (2)
547 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

Avoid ChatGP it still has a way to go.

 

"Also could it be that this just isn't possible in AutoCAD LT?" only if you have LT2024. Please post a dwg before and after. 

Message 3 of 4

komondormrex
Mentor
Mentor
Accepted solution

hey there,

most simplest code

(defun c:number_ordinal (/ number ordinal block)
	(setq number (getint "\Enter number: ")
		  ordinal (getint "\Enter ordinal: ")
	)
	(while (setq block (car (entsel "\nPick block: ")))
		(setpropertyvalue block "Number" (itoa number))
		(setpropertyvalue block "Ordinal" (itoa ordinal))
		(setq ordinal (1+ ordinal))
	)
)
Message 4 of 4

filip_novoselec
Explorer
Explorer
Accepted solution

My apologies for taking so long to get back to this, I have been bombarded with other work so I had no time to get back to this. After trying out your code I am more than happy to report that it works perfectly! Thank you so much kind person!

0 Likes