@ВeekeeCZ wrote:
...or named block.
(defun c:MakeBlock (/ ss pt name) ;ctrl+shift N
(if (and (setq ss (ssget ":L"))
(setq pt (getpoint "\nReference point:"))
(setq name (getstring T "\nName: "))
)
(command "_.-BLOCK" name "_non" pt ss ""
"_.-INSERT" name "_S" 1 "_R" 0 "_non" pt))
(princ)
)
This and several other suggestions on this thread can be done without most of the variables. The Block command will supply its own prompts [though in a different order than the above]. And the Insert command will default to scales of 1 and rotation of 0. You just need to save the name, because unlike in the Block dialog box version, where you can choose whether or not to have it converted into a Block Insertion in the process, in the (command)-function version the pieces are always removed from the drawing, and you then need to Insert the same Block.
Try something like this:
(defun C:MakeBlock (/ name)
(command
"_.block" (setq name (getstring)) pause (ssget "_:L") ""
"_.insert" name "@" "" "" ""
)
(princ)
)
Or, you could end the (command) function at the Block name, and leave the other things to the User after the end of the routine [without the (princ) at the end], if you don't necessarily always want it put in at the same location/size/rotation as the pieces selected to be in it.
[You can add the limitation of object-type filtering in the (ssget) function if you want.]
Kent Cooper, AIA