Author Topic: ssget selection by coordinates and the layer  (Read 2733 times)

0 Members and 1 Guest are viewing this topic.

ozimad

  • Guest
ssget selection by coordinates and the layer
« on: December 30, 2010, 06:49:41 AM »
Hi everyone!
Can someody help me with the selections. I need to select text object, on defined layer. i have write the code but it doesnt work. Any ideas why?
thank for help
i was using the info from the topic below.
http://www.cadtutor.net/forum/showthread.php?41479-SSGET-select-block-by-coordinates

Code: [Select]
(defun c:geta ()
    (setq cmd (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    (setq fuz 40)
    (setq ss (ssget "_X"
                    (list '(-4 . "<,<,<")
                          (cons 11
                                (list (+ (car pt) fuz)
                                      (+ (cadr pt) fuz)
                                      (+ (caddr pt) fuz)
                                )
                          )
                          '(-4 . ">,>,>")
                          (cons 11
                                (list (- (car pt) fuz)
                                      (- (cadr pt) fuz)
                                      (- (caddr pt) fuz)
                                )
                          )
                          (0 . "TEXT")
                          (8 . "KM_AA")
                    )
             )
    )
    (print ss)
    (princ)
)

[code]
[/code]

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget selection by coordinates and the layer
« Reply #1 on: December 30, 2010, 07:30:26 AM »
I haven't looked at the other site ..


Ask the question another way  -

Do you want to select TEXT only , on a specific layer,  within a crossing window, the size of which is an 80 unit square about a provided point.

Is that correct ?

In your example, where is the point pt defined ??

« Last Edit: December 30, 2010, 07:59:02 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget selection by coordinates and the layer
« Reply #2 on: December 30, 2010, 07:54:17 AM »
Perhaps something like this :

Code: [Select]
[color=teal];; doit_geta.lsp[/color]
 
(defun [color=navy]c:doit[/color] (/ pt fuz ll ur ss)
  (setq pt (getpoint [color=brown]"Select a selection Point."[/color]))
  (setq fuz 40
        ll  (mapcar '- pt (list fuz fuz fuz))
        ur  (mapcar '+ pt (list fuz fuz fuz))
        ss  (ssget [color=brown]"_C"[/color] ll ur '((0 . [color=brown]"TEXT"[/color]) (8 . [color=brown]"KM_AA"[/color])))
  )
  (alert (strcat (itoa (sslength ss))
                 [color=brown]" Selected"[/color]
                 [color=brown]"\n First value is "[/color]          
                 (cdr (assoc 1 (entget (ssname ss 0))))
         )
  )
  (princ)
)
 
« Last Edit: December 30, 2010, 07:58:21 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget selection by coordinates and the layer
« Reply #3 on: December 30, 2010, 12:22:46 PM »
Or maybe:
Code: [Select]
  (setq ss (ssget "C" (polar pt (* pi 0.25) (* fuz (sqrt 2)))
                      (polar pt (* pi 1.25) (* fuz (sqrt 2)))
                     '((0 . "TEXT")(8 . "KM_AA"))))

-David
R12 Dos - A2K

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget selection by coordinates and the layer
« Reply #4 on: December 30, 2010, 03:19:27 PM »
Clever David!
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget selection by coordinates and the layer
« Reply #5 on: December 31, 2010, 06:40:56 AM »
I've never tested it, but does ssget use the insertion point ( 10 or 11 ) based on the justification flags, or should it pick up any geometry of the text entity?  I would think there would be a lot erroneous returns on selecting text with a crossing.  -David
R12 Dos - A2K

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget selection by coordinates and the layer
« Reply #6 on: December 31, 2010, 09:23:17 AM »

In 2011 It selects as I expected David .. The insertion Point is not relevant. .. but a good thought :)

A Piccy to demonstrate
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget selection by coordinates and the layer
« Reply #7 on: December 31, 2010, 10:22:46 AM »
So it looks like the font shapes geometry.  Cool.

40 seems like a large fuzz factor.   unless the text is 400 units tall.   And then if the point is located in a space or multiple spaces in the text string I would expect a nil return.  -David
R12 Dos - A2K

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget selection by coordinates and the layer
« Reply #8 on: December 31, 2010, 10:47:28 AM »
In production code, the notifying alert should be conditional on there being a valid Selection Set, yes.

 
I had imagined the op was looking for text in a relationship to a preselected feature David.
Thats one of the difficulties with trying to answer questions without all the relevant data and without additional response from the op ... one has to make assumptions or walk away.


but you know that :)

Regards
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

curmudgeon

  • Newt
  • Posts: 194
Re: ssget selection by coordinates and the layer
« Reply #9 on: December 31, 2010, 10:47:55 AM »
Maybe I am not getting it, but in the original post I don't see why it is using ssget "x" if you intend to pass points to it.
And in the perhaps overdone listing of points, I think you would need to add quotes of the 0 and 8 group codes.

For myself, in similar situation I like to use ssget "cp" , but I have to use a zoom command to get the selection set process to behave.
Never express yourself more clearly than you are able to think.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget selection by coordinates and the layer
« Reply #10 on: December 31, 2010, 11:51:49 AM »
R12 Dos - A2K

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget selection by coordinates and the layer
« Reply #11 on: January 02, 2011, 06:21:57 AM »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ozimad

  • Guest
Re: ssget selection by coordinates and the layer
« Reply #12 on: January 04, 2011, 05:33:37 AM »
Amazing! it boosted my lisp a lot! thank everyone for help!   :-)