Quick question... I want to have the user select a text entity. If the
user selects a text entity, then I want to change that text entity.
Otherwise, I want to add text where the user clicked.
(entsel) returns a point, but only if an entity is selected.
(getpoint) returns a point automatically, but doesn't have the cute little
square pick that is used with (entsel), and it would be pretty darn
difficult to determine whether that point is near the text because the
text could be arbitrary...
Any help would be appreciated...
-Mike
>
> Any help would be appreciated...
>
> -Mike
--
> Quick question... I want to have the user select a text entity. If the
>user selects a text entity, then I want to change that text entity.
>Otherwise, I want to add text where the user clicked.
>(entsel) returns a point, but only if an entity is selected.
>(getpoint) returns a point automatically, but doesn't have the cute little
>square pick that is used with (entsel), and it would be pretty darn
>difficult to determine whether that point is near the text because the
>text could be arbitrary...
A quick answer to a quick question:
Use getpoint to obtain a point. Then use ssget "W" with this point and another
dummy-point just a little apart. You can then scan the selection set you get
and look for text entities in it. If you want to be picky, I guess you could
calculate what the square around the pick point would have been if you had
used entsel and use that square in ssget...
Of course, you won't get the square on the screen while the user is picking
his point. But this was the only way I could think of...
Good luck!
Knut Hunstad
SINTEF Building and Environmental Technology, Highway Engineering
Trondheim, Norway
Mike
As you say, GETPOINT doesn't have the pickbox but that aside I
would use something similar to the following.
(if (setq pt (getpoint))
(if (setq ss (ssget pt))
(progn
(setq ename (ssname ss 0)
elist (entget ename)
)
(if (= "TEXT" (cdr (assoc 0 elist)))
(progn
; text entity selected change text
);end progn
(progn
; entity selected but not text
);end progn
);end if
);end progn
(progn
; No entity selected so add text
);end progn
);end if
(progn
; No point selected
);end progn
);end if
Alan Williams EMail al...@awol.demon.co.uk
use (grread nil 2 4) or similar
it returns the point and shows this pickbox. then check with (ssget pt)
Ex:
(if (and (setq x (grread nil 2 4))
(setq pt (cadr x)))
(if (and (setq ss (ssget pt))
(= (cdr (assoc 0 (setq ent (ssname ss 0)))) "TEXT"))
;; text found
(command "DDEDIT" ent)
;; else create new
(command "TEXT" ...)
)
)
not tested.
---
Reini Urban <rur...@sbox.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/
>Hello-
> Quick question... I want to have the user select a text entity. If the
>user selects a text entity, then I want to change that text entity.
>Otherwise, I want to add text where the user clicked.
>(entsel) returns a point, but only if an entity is selected.
>(getpoint) returns a point automatically, but doesn't have the cute little
>square pick that is used with (entsel), and it would be pretty darn
>difficult to determine whether that point is near the text because the
>text could be arbitrary...
>Any help would be appreciated...
>
>-Mike
You can try the following line
(setq ss (ssget (setq pt (getpoint))))
Select a point. If the user has selected over a text or any entity then it would
return a line showing a selection set no. If not the value will be nil for the
selection set and the value for PT can be used to further programming.
You can use this expression inside any logical functions like
if , while ,cond .
Hope this helps.
G.Rajesh
//Autodesk Product Support on the Internet//
>
>use (grread nil 2 4) or similar
>it returns the point and shows this pickbox. then check with (ssget pt)
Thanks :-)... (Thanks to everyone for all the suggestions...) I was
looking for a way to get the pretty little pick-square on the screen :-).
I haven't ever really used grread, grclear, grdraw, etc... I've always
used (getXXX) for user input...
But your grread suggestion should work fine :-)
-Mike
--
Mike Fredericks
Vista Integration Services
Vista...@aol.com
>VistaMikeF (vista...@aol.com) wrote:
>: (entsel) returns a point, but only if an entity is selected.
>: (getpoint) returns a point automatically, but doesn't have the cute little
>: square pick that is used with (entsel), and it would be pretty darn
>: difficult to determine whether that point is near the text because the
>: text could be arbitrary...
>use (grread nil 2 4) or similar
>it returns the point and shows this pickbox. then check with (ssget pt)
>Ex:
>(if (and (setq x (grread nil 2 4))
> (setq pt (cadr x)))
> (if (and (setq ss (ssget pt))
> (= (cdr (assoc 0 (setq ent (ssname ss 0)))) "TEXT"))
> ;; text found
> (command "DDEDIT" ent)
> ;; else create new
> (command "TEXT" ...)
> )
>)
>not tested.
>---
>Reini Urban <rur...@sbox.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/
Hello.
Yes, using GRREAD seems to be the only way.
The little trick here is to convert a point to Display
Coordinate System, and then it all will work just fine
even on twisted (rotated) views.
If you want to be perfect, you might collect a keystrokes from user
(I'm ignoring them for simplicity) and respond to some keywords etc.
Here's something tested and used:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SELect ENTities by picking a point
;; (C.) 1996 by Vladimir Nesterovsky <vne...@netvision.net.il>
;; You're free to use it *unaltered* for any NON-COMMERCIAL
;; purpose (or you must contact me for permission).
;; USE IT AT YOUR OWN RISK. NO WARRANTIES ARE GIVEN WATSOEVER.
;; Select Entities -- main routine to use
(defun sel-ents( / p q got_inpt) ;; ret {{e1 [e2 ... en]} pt}
(while (not got_inpt)
(setq p (grread nil 4 2)) ;; show pick-cursor shape
(if
(or (= (car p) 3)
(member p ;; allow to exit via Return/Esc
'((2 3)(2 10)(2 13)(2 32)(2 27))))
(setq got_inpt T)
))
(if (and (= 3 (car p)) ;; got UCS point from GRREAD
(setq q (selfindp (setq p (cadr p)) 1)) )
(list q p) ;; return {{e1 [e2 ... en]} pt}
))
;; Selection-Entities-List Find by Point
(defun selfindp (p xcs / FUZZ sel p1 p2 )
;;xcs: 0-- p is WCS, 1 -- UCS, etc.
;;RET EN-LIST of all entities near point
(graphscr) ;; a must for (SSGET "C"...) to work(?)
(setq FUZZ (* (pixelsize) (getvar "pickbox")))
(setq p (trans p xcs 2) ;; translate to DisplayCS
p1 (mapcar '- p (LIST FUZZ FUZZ))
p2 (mapcar '+ p (LIST FUZZ FUZZ))
sel(ssget "C" (trans p1 2 1) (trans p2 2 1))
)
(sel2lst sel)
)
;; Pixel Size in drawing units
(defun pixelsize()
(/ (GETVAR "viewsize") (CADR (GETVAR "screensize"))))
;; sel2lst is also on Reini Urban's site (see URL in the quotings).
;; convert SELection set to LiST of e-names
(defun sel2lst ( sel / l len )
(if (= 'PICKSET (type sel))
(repeat (setq len (sslength sel))
(setq len (1- len) l (cons (ssname sel len) l)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Best wishes,
=Vladimir Nesterovsky= ADS/LISP/C/C++ etc
Vladimir Nesterowsky send me the following tested function:
----------------
----------------
also availaible at
http://xarch.tu-graz.ac.at/autocad/code/vnestr/sel-ents.lsp
---
Reini Urban <rur...@sbox.tu-graz.ac.at> http://xarch.tu-graz.ac.at/~rurban/
(defun remove (item from)
(cond ((atom from) from)
((equal (car from) item) (remove item (cdr from)))
(t (cons (car from) (remove item (cdr from))))))
Hi Mike,
I would like to suggest that you make sure you only select TEXT
entities (ssget '((0 . "TEXT"))) and try to make sure something is
selected (while (nil (ssget '((0 . "TEXT"))))).
If you then extract the text insertion point you are almost done. To
be perfect you can turn "blipmode" on to show where this point is and
give the user some backfeed from a user friendly program.
In this case (entsel) would be the correct choice.
Regards
Manfred Houzer
12 Alabaster Tce.
Hillarys WA 6025
Australia (DOWN UNDER)
>(Reini Urban) writes:
>>
>>use (grread nil 2 4) or similar
>>it returns the point and shows this pickbox. then check with (ssget pt)
Hello, Mike.
Please note that (ssget pt) will return to you only
ONE entity found, but there may be many.
Look into my response from 1/05/96 for more
complete solution. You also must use (grread nil 4 2).
--
Vladimir Nesterovsky ADS/LISP/C/C++ etc
<vne...@netvision.net.il>
: I would like to suggest that you make sure you only select TEXT
: entities (ssget '((0 . "TEXT"))) and try to make sure something is
: selected (while (nil (ssget '((0 . "TEXT"))))).
: If you then extract the text insertion point you are almost done. To
: be perfect you can turn "blipmode" on to show where this point is and
: give the user some backfeed from a user friendly program.
: In this case (entsel) would be the correct choice.
Although a much more difficult method, you could also use an arbitrary
initget scheme (bit 128) to first check for an entity-selection, second
to return the pick point. Then you could filter for the entity type
within the first section thereafter. I think the previous method is
better though.
D. Stein
dst...@cnu.edu
Sr. AutoCAD LAN Administrator
Dept. E-65
Newport News Shipbuilding Co.
NN, Va. USA