AboutScott Cook Expertise I`ve been using AutoCAD since 1987 and programming AutoLISP nearly as long. I can answer questions about programming AutoCAD (except ARX) and production enhancement techniques. I cannot answer questions about AutoCAD crashes or DWG corruption. AutoCAD PROGRAMMING (menus, lisp) related questions only!
Experience Since 1987. Author of Plot2000 software for for AutoCAD, http://www.plot2000.com.
PROGRAMMING QUESTIONS ONLY PLEASE. Questions that are NOT related to programming or AutoCAD customization (menus and lisp only please) are outside the scope of my volunteer services and will NOT BE ANSWERED.
Question I am using AutoCAD 2002 on WIn XP Pro. Networked with a server. I am writing a lisp routine and need to know how to select and entity in the drawing based on a name. For example, I need to select the xref with "TTLBLK" in the name and return the same type of data as the "ENTSEL" command. Got any ideas? I've been trying to get the lisp routine to enter "L" at the Command Prompt, but it only prints an l and then still asks me to select an object. "ENTGET" doesn't seem to have any luck either. Here is a copy of the code:
It then goes on to one of two subroutines based on whether or not there is an xref.
The "ENTSEL" where I am prompted to select thhe titleblock is the problem. I don't want to have to selct the titleblock.
The end goal of this program is to read which titleblock has been xrefed into the drawing and thus set the limits accordingly, run the plot command and set the sheet size accordingly.
Any ideas would be MOST HELPFUL.
Our titleblock name is 04-005_TTLBLK-24x36
However, the sheet size (24x36) can change, hence why I would like to search for just "TTLBLK".
Thank you very much
Answer You will need to use SSGET "X" with a properly formatted argument list. Look at the lisp function reference for SSGET, and the DXF reference for the INSERT entity type, and "common group codes for all entities" in the DXF reference.
It will be something like:
(setq ss1 (ssget "x" '((0 . "INSERT")(2 . "*TTLBLK*"))))
I don't know if I have the group codes correct, but that's the gist of it. You can use wildcards in the block name.
SSGET returns a selection set, which you will have to retrieve the entity name(s) from:
(if ss1
(progn
(setq entityname (ssname ss1 0))
; do some stuff with entity now
)
)