@Anonymous wrote:
all of these seem to work for what I'm trying to build but @Kent1Cooper first sol'n seems very elegant:
(setq textcontent (cdr (assoc 1 (entget (car (entsel "\nSelect DWG Number: "))))))
Execution of commands is from right to left, so you can take parts of this expression and run it in console, just copy, past and hit enter. So with text entity we have
Command: (entsel "\nSelect DWG Number: ")
Select DWG Number: (<Entity name: 25147bf3440> (1024.89 433.124 0.0))
Here is a list that contains two entries, entity name and pickpoint where we clicked on entity.
Functions car, cadr adn varios combination access diferent entity in a list. Car fetches first, cadr second. Or you can use command (NTH num list) starting from 0.
Command: (car (entsel "\nSelect DWG Number: "))
Select DWG Number: <Entity name: 25147bf3440>
To read definition of this entity we use command entget
(entget(car (entsel "\nSelect DWG Number: ")))
Select DWG Number: ((-1 . <Entity name: 25147bf3440>) (0 . "TEXT") (330 . <Entity name: 25147bf81f0>) (5 . "274") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbText") (10 1019.87 433.069 0.0) (40 . 2.5) (1 . "aaa") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 0))
Text value is stored in association list (1 . "aaa"). To fetch it we use (cdr (assoc keyvalue list))
And at last this value is stored in variable textcontent using command setq.
For a key values for some entity you can look in autocad help - search for DXF ENTITIES Section
Under -> Developer Documentation -> Reference guide you have almost everything you need to start learning autolisp. Google will help you a lot. There is a lot of code in this forum. Check AFRALISP
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.