I need help getting a text value from a specific coordinate (x,y). All I can find is "setq txt (car (entsel "Pick Text")))". I will aslo need to set a value (",") if there is no text at the location. I have hundreds of files I need to do so I don't want to manually enter anything.
I don't know what happened to the forum editor, but it really does some stange formatting and I couldn't find any code tages
The justification of the text at 0,0 was middle. As soon as I changed it to left it worked fine. Will I need to change all the text justification before I run my program or is there a different way to do this?
I am confused at using (ssget "_X" ) with a point location. Just does not feel right.
You want to select text blind? What if there is a space at your selection point?
I am not so certain it would be reliable, but I have been wrong before. I think I might try creating a points list from the point that would represent a small polygon centered on your pick point, and pass that to (ssget "_CP" pnt_lst '((0. "TEXT,MTEXT ) (8 . "only_the","layers I","want")))
You would have to decide the size and shape of the crossing box.
Selection sets based on WP and CP are really cool, as is F. I am working on architectural plans, and I have a polyline describing a room. I can select everything IN the room with a points list from the polyline and CP.
ooh, and remember when you are selecting text entities, 10 is not always the same as 11 based on too many variables for me to keep straight. If the justification is bottom left, as I seem to recall, 11 does not get set, and you may have nothing to grab at 11. Stuff like that is why I would hesitate to grab text by a specific point location.
Edited by: curmudgeon on Mar 28, 2009 10:59 AM
I want to pick specific locations and if nill then I need to use ",". I might look at crossing as it could help if the text isn't where it should be. Could you post how to set the list for using a crossing. Perhaps how to modify the list.
as I read your results from (entget (car (entsel)))) , your dxf 10 is -2,-3, and your text was "N" and your dxf 11 was 0,0.
this is where the dxf code is more complicated, I think that piece of text your routine is failing to grab is middle center justified, and that is the 11 code. the 10 code is where the insertion point would be if it were lower left justified but appeared in the same location on the screen.
I seem to remember that lower left is default, and that is the dxf 10. 11 is only added to a text entity for other than default justification. not being able to see your screen, here is what I would try.
I assume this piece of text is always in the same place in different drawings. if not, this would still be a starting point.
(setq my_text (ssget "_CP" '((-3 -4)(3 -4)(3 4)(-3 4)) '((0 . "TEXT")(8. "TEXT")))
this is of the form (ssget "_WP" pt_list '((0 . "LINE") (62 . 5))) like in the Vlisp help file for ssget except it filters for text entities on the layer "text", and uses a window selection instead of a crossing selection.
I picked '((-3 -4)(3 -4)(3 4)(-3 4)) for a point list because it would define a rectangle that should include (10 -2.44799 -3.67198 0.0) .
I think you could
(setq my_text (ssget "_C" '((-3 -4)(3 4)) '((0 . "TEXT")(8. "TEXT")))
and get the same results. that should be a crossing selection like responding "C" to a standard prompt.
then there is the what to do with the what you get, or failed to get.
I guess it is good form to have kind of standard names for selections sets so that one remembers they are selections sets and not lists or integers, or things that get manipulated directly. so
and then you could
(setq my_text (cdr (assoc 1 (entget (ssname ss1 0)))))
(setq my_text ",")
ssname returns the first, and only item in the selection to
enget which gets the association list for the entity ,
which associates dxf code 1 with the text content dotted pair and
cdr is that dotted pair minus the first item.
inside out, that is the then to the if statement and the else would be ","
to make this look in places other than 0,0,0 all you would need to do would be to pass a point location other than the origin to the routine.
one thought, and then I think I will get back to my project. you might need to , in the program, set your UCS to world first. I forget from time to time, but some lisp is dependent on the current UCS, and some is dependent on whether entities are actually visible. some depend on your pick box, so it would be possible to be zoomed in too close for some selection methods to reliably select intermittent entities such as text or lines with other than continuous line type.
It slipped my mind again that text insertion points are inconsistent in AutoCAD, which I wish they would fix. The 10 code is the left end of the base line, regardless of the justification. When the justification is Left, that is also the insertion point. With any other justification, the insertion point (what you would get with Osnap Insert) is stored in the 11 slot in the entity data; that is always 0,0,0 for Left-justified text, regardless of its location.
If it's always middle-justified, you can just change the 10 to 11 -- no need to change the text's justification. If the justification would vary, you would need to get more sophisticated.