Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(entsel) vs (getpoint) for getting TEXT entity...

16 views
Skip to first unread message

VistaMikeF

unread,
Apr 25, 1996, 3:00:00 AM4/25/96
to
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

sam...@cruzio.com

unread,
Apr 26, 1996, 3:00:00 AM4/26/96
to
ahhh, but you can follow the (getpoint) with a (nentselp) !


>
> Any help would be appreciated...
>
> -Mike


--


Knut Hunstad

unread,
Apr 26, 1996, 3:00:00 AM4/26/96
to

>From: vista...@aol.com (VistaMikeF)

> 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

Alan Williams

unread,
Apr 27, 1996, 3:00:00 AM4/27/96
to

In article: <4loo3f$g...@newsbf02.news.aol.com> vista...@aol.com (VistaMikeF) writes:
> 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
>

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


Reini Urban

unread,
Apr 27, 1996, 3:00:00 AM4/27/96
to

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/

G Rajesh

unread,
Apr 29, 1996, 3:00:00 AM4/29/96
to

Mike wrote:

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

VistaMikeF

unread,
Apr 29, 1996, 3:00:00 AM4/29/96
to

In article <4ltc86$9...@fstgal00.tu-graz.ac.at>, rur...@xarch.tu-graz.ac.at
(Reini Urban) writes:

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

Vladimir Nesterovsky

unread,
May 1, 1996, 3:00:00 AM5/1/96
to

On 27 Apr 1996 14:50:46 GMT, rur...@xarch.tu-graz.ac.at (Reini Urban)
wrote in comp.cad.autocad:

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

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

Reini Urban

unread,
May 1, 1996, 3:00:00 AM5/1/96
to

VistaMikeF (vista...@aol.com) wrote:
: (Reini Urban) writes:
: >use (grread nil 2 4) or similar

: >it returns the point and shows this pickbox. then check with (ssget pt)
: But your grread suggestion should work fine :-)

Vladimir Nesterowsky send me the following tested function:
----------------

----------------
also availaible at
http://xarch.tu-graz.ac.at/autocad/code/vnestr/sel-ents.lsp

(defun remove (item from)
(cond ((atom from) from)
((equal (car from) item) (remove item (cdr from)))
(t (cons (car from) (remove item (cdr from))))))

myj...@vianet.net.au

unread,
May 1, 1996, 3:00:00 AM5/1/96
to

vista...@aol.com (VistaMikeF) wrote:
>
> 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

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)


Vladimir Nesterovsky

unread,
May 9, 1996, 3:00:00 AM5/9/96
to

On 29 Apr 1996 18:48:22 -0400, vista...@aol.com (VistaMikeF) wrote
in comp.cad.autocad:

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


David Stein

unread,
Jul 29, 1996, 3:00:00 AM7/29/96
to

myj...@vianet.net.au wrote:
: vista...@aol.com (VistaMikeF) wrote:
: >
: > 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.
: 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.

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

0 new messages