AllExperts > AutoCAD 
Search      
AutoCAD
Volunteer
Answers to thousands of questions
 Home · More AutoCAD Questions · Answer Library  · Encyclopedia ·
More AutoCAD Answers
Question Library

Ask a question about AutoCAD
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Scott 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.
 
   

You are here:  Experts > Computing/Technology > Computer-Aided Design > AutoCAD > AutoLisp

AutoCAD - AutoLisp


Expert: Scott Cook - 1/13/2005

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:

(DEFUN C:PFS()
 (GRAPHSCR)
 (COMMAND "VISRETAIN" "1")
 (COMMAND "ZOOM" "E")
 (COMMAND "XREF" "R" "*")
 (COMMAND "PLOTSTAMP" "LOC" "BL" "V" "" ".4000,.5000" "" "T" "" "3/32" "" "ON" "")
 (setq TTL (ENTSEL "\nSELECT TITLEBLOCK.... "))
             (IF (= TTL NIL)(SETQ R "2")
        (SETQ R "1"))

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
 )
)


Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.