CompuServe Thread

Mystery variable

3 messages in this thread
#22175From: Michael MurphreeApr 24, 1988 10:31 PM
Anyone, I have a client who does a lot of repetitive work that references the last block inserted into his drawing. We're trying to do some lisp routines to help avoid some of this, but for the life of me I can't figure out how to "default" to the last block inserted. I know there's a variable in there somewhere, since AutoCAD defaults to the block itself when using the insert command. Is it accessible to users or not? If so, what is it? For instance, I insert a block, I want to offset it, dimension it according to their conventions, and a couple of other things. I'd like to execute this routine, and have it default to the block that I just inserted. Any help? Michael
#22215From: Duff Kurland [Adesk]Apr 25, 1988 5:27 PM
Michael – AutoCAD has a number of built-in "default variables" -such as the last hatch pattern and style, the last text rotation angle, the last system variable referenced by the SETVAR command, and the ending angle for the last line or arc drawn (for continuation) — that are not saved with the drawing and do not have corresponding user-accessible system variables. The name of the last Block inserted is one of these internal variables. You could make the name accessible by redefining the INSERT command in the following fashion: (defun C:INSERT () (setq lastblock (getstring "Block name: ")) (command ".INSERT" lastblock) ) Then issue an "UNDEFINE INSERT" command to cause your revised version to override the built-in version. You could extend this simple example to include the previous value of LASTBLOCK (if non-null) in the prompt, etc. .
#22217From: Training [ADESK]Apr 25, 1988 7:33 PM
Michael — I might redefine the INSERT command, or use a new command similar to the one below: .. (defun C:INST () (command "insert" pause pause pause pause pause) (setq e (entlast)) ) .. or simply run this routine after a block INSERTion: .. (defun C:EL () (setq e (entlast)) ) .. the end result being that the global variable E is bound to the entity name of the last block inserted into the drawing. It's easy to use this variable in response to whatever "Select objects:" prompt you encounter after that. — Brad ..