Jump to content

Retrieve pick point from a selected text entity


dax

Recommended Posts

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • dax

    12

  • Tharwat

    6

  • tombu

    4

  • Roy_043

    4

Top Posters In This Topic

(cadr (entsel)) will give the coordinates of the center of the pickbox aperture at the time of selection.

 

Alternatively, you can store a point returned by (getpoint) and then use (nentselp ) or (ssget ) to obtain a selection.

 

Or you can retrieve the selection information from an (ssget) call using the (ssnamex) function.

Link to comment
Share on other sites

Hi Lee,

 

Thanks for your response, your correct on (cadr (entsel)) but this function prompt for a user action (select object) , I'm looking for a function that return pick points without user interaction to select an object from this I will add this function to the auto search text function I used.

 

Thanks

Link to comment
Share on other sites

I'm looking for a function that return pick points without user interaction

 

What do you mean by 'pick points' if not points picked by the user?

Link to comment
Share on other sites

Yes, I have a lisp program that search a text automatically from the drawing then from their I want to get the pick point/coordinates (x, y, z) from the selected text entity. is it possible with lisp or is their a working function on it to retrieve the pick point like what the entsel can do?

 

Thanks

Link to comment
Share on other sites

Hi Tharwat,

 

(cdr (assoc 10 (entget )))

 

I've used the above code but give me a invalid point error, and also I notice it give me wrong point.

 

See my code below :

 

(defun findString (/ str ss) ; = Find String(s)*by Content

**(setq str "DAX")

**(if (setq ss (ssget "_X" (list (cons 0 "*TEXT") (cons 1 str) (cons 410*

(getvar 'ctab)))))

****(sssetfirst nil ss); select/highlight/grip

**); if

); defun

 

This program find and select "DAX" entity.

 

Upon selected. I run below command.

 

Command: (setq a (entlast))

Command: (cdr (assoc 10 (entget a)))

(10.0 10.0 10.0)

 

This is different when using the (entsel).

 

Command : (entsel)

 

Select object: ( (619.0 333.0 0.0))

 

My goal is to get (619.0 333.0 0.0) from the selected text entity. I need the coordinates from the text entity to create a small circle which will be the mid point of the circle,

 

and from their all object inside the circle will be selected for data extraction.

 

Hope you can help me on this one.. Many thanks.. :)

Link to comment
Share on other sites

Did you read what Lee described earlier? and the differences between the entsel return list and the ssget function?

The second list of the return of the function entsel which represents the cursor position is completely different than the position of the selected object?

 

Which on would like to use? entsel or ssget ?

Link to comment
Share on other sites

Hi Tharwat,

 

Thank you for your response, I used the ssget function then ssnamex and got this result ((1 0 (0 (619.0 332.0 0.0)))), however I'm finding it hard to retrieve only the coordinates (619.0 332.0 0.0).

 

Dax

Link to comment
Share on other sites

Hi Tharwat,

 

Thank you for your response, I used the ssget function then ssnamex and got this result ((1 0 (0 (619.0 332.0 0.0)))), however I'm finding it hard to retrieve only the coordinates (619.0 332.0 0.0).

 

Dax

 

Hi Dax,

 

Please try the following:

(if (setq ss (ssget '((0 . "TEXT"))))
 ((lambda (i / sn)
    (while (setq sn (ssnamex ss (setq i (1+ i))))
     (setq l (cons (cadr (cadadr sn)) l))
      )
    )
   -1
   )
 )

Link to comment
Share on other sites

The coordinates would be assigned to variable 'l' so if you running the coding from Vlisp console just type l on the console and hit enter but if you are in AutoCAD command line just type !l and hit enter.

Link to comment
Share on other sites

Sorry Tharwat I just accidentally delete the other thread. I will try you suggest hope I remember what have you answer on my issue.. :)

Link to comment
Share on other sites

Sorry Tharwat I just accidentally delete the other thread. I will try you suggest hope I remember what have you answer on my issue.. :)

 

You did delete the last two replies accidentally? very odd!

Link to comment
Share on other sites

Yes, I have a lisp program that search a text automatically from the drawing then from their I want to get the pick point/coordinates (x, y, z) from the selected text entity. is it possible with lisp or is their a working function on it to retrieve the pick point like what the entsel can do?

 

Thanks

 

You're definitely not talking about "pick points", maybe insert points? Post the lisp or better yet a link to where you found it then tell us what is it you want the lisp to do differently. The textbox function may be more helpful depending on what you want to do with those points. The clearer you questions the more chance you have of getting the response you're looking for.

Link to comment
Share on other sites

@ dax:

I hope you are aware that the result of ssget (and therefore of ssnamex) will vary depending on the selection method. Only if the entities are selected with single picks will you get a result in the format you have posted. You should do additional testing with the (Crossing) Window, Fence and All selection methods.

 

Your best bet is to use a point from the entity. You may have to use the trans function to translate from the OCS of the entity to the current UCS or the WCS.

Edited by Roy_043
Link to comment
Share on other sites

Hi tombu, Roy_043, thank you for your responses, I'm having difficulty on the routine such a newbie of me on LISP, however I already resolved the invalid point error and I noticed that it give me wrong point. Please see below code, I just get this from other forum site.

 

; search text entity with "DAX" content

(setq str "DAX")

 

*(if (setq ss (ssget "_X" (list (cons 0 "*TEXT") (cons 1 str) (cons 410*

(getvar 'ctab)))))

****(sssetfirst nil ss); select/highlight/grip

**); if

 

; return "(nil )"

 

(setq ent (entlast))

; return ""

 

(setq a (entget ent))

 

; return "((-1 . ) (0 . "TEXT") (330 . ) (5 . "CDD4") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0-BORDER-0") (62 . 7) (100 . "AcDbText") (10 21.0 12.0 0.0) (40 . 2.0) (1 . "ACAD2014::ical 2014v3b RIVERAD1") (50 . 1.5708) (41 . 1.0) (51 . 0.0) (7 . "romcal") (71 . 0) (72 . 0) (11 20.0 12.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbText") (73 . 2))"

 

 

but when using (entsel) then select the text entity (with "DAX" content) it return this one ( (615.0 332.0 0.0)), for my code above I did'nt get the (615.0 332.0 0.0) it gives me (10 21.0 12.0 0.0).

 

Thanks,

Link to comment
Share on other sites

To translate the coordinate of the text to the current UCS use this:

(trans (cdr (assoc 10 (entget ent))) ent 1)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...