Author Topic: "ssget everything" for a single point?  (Read 376 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 654
"ssget everything" for a single point?
« on: April 24, 2024, 09:59:40 AM »
I have tons of hatches, usually as solid-hatch-pattern, and sometimes partially or totally overlapping.
I want to select the overlapping ones on a single point - like a needle which I stick on a bunch of paper sheets: all the sheets on this needle-picking-point are selected.

(An option would be to define a cross-poly or a cross-window with very small area, but maybe there is really a "needle-ssget"?)
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ribarm

  • Gator
  • Posts: 3285
  • Marko Ribar, architect
Re: "ssget everything" for a single point?
« Reply #1 on: April 24, 2024, 10:03:25 AM »
Maybe :
Code: [Select]
(sssetfirst nil (ssget "_C" pt pt))
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: "ssget everything" for a single point?
« Reply #2 on: April 24, 2024, 12:18:58 PM »
Marko's suggestion should suffice (though I might be inclined to add some small tolerance to the selection window). For completeness, I would note that you can actually supply a single point to ssget, e.g. (ssget '(1 2 0)), however, this will only usually select a single entity.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: "ssget everything" for a single point?
« Reply #3 on: April 24, 2024, 01:31:15 PM »
This gets everything inside the pickbox:
(setq ss (ssget ":E"))

Peter2

  • Swamp Rat
  • Posts: 654
Re: "ssget everything" for a single point?
« Reply #4 on: April 25, 2024, 03:51:57 AM »
This gets everything inside the pickbox:
(setq ss (ssget ":E"))
For me, only the entity on the top.

Thanks to all; I see a confirmation that "selecting everything under a needle" is not possible.
A point (a needle) picks only the element on the top. To select the other elements too I need an cross-poly or a fence.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Lastknownuser

  • Newt
  • Posts: 28
Re: "ssget everything" for a single point?
« Reply #5 on: April 25, 2024, 06:19:38 AM »
How about you ssget all hatches, then test if point (a needle) is inside a hatch, if yes add it to new selection set

Peter2

  • Swamp Rat
  • Posts: 654
Re: "ssget everything" for a single point?
« Reply #6 on: April 25, 2024, 06:43:31 AM »
Thanks, but maybe this leads to a wrong direction.

The main idea is: "Find overlapping hatches"

The discussion here https://forums.autodesk.com/t5/autocad-forum/check-for-overlapping-hatches/m-p/12730499#M1129617 shows the problem; the linked VLX has problems sometimes.

So the "needle-selection" is only a vague idea for a solution.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Lastknownuser

  • Newt
  • Posts: 28
Re: "ssget everything" for a single point?
« Reply #7 on: April 25, 2024, 07:15:25 AM »
Find them without any additional interaction? How would then this "needle point" be known? I maybe misunderstood first post, because for this "needle point" method you need to define that point
It could be done using this great intersection functions by Lee Mac, https://www.lee-mac.com/intersectionfunctions.html#intersectionsinset, it could be made to work with hatches. But if you found the working solution use that of course.

xdcad

  • Swamp Rat
  • Posts: 501
Re: "ssget everything" for a single point?
« Reply #8 on: April 26, 2024, 05:56:30 AM »
Provide an idea:

Erase completely overlapping (coincide) objects and keep one

https://www.theswamp.org/index.php?topic=59483.0

The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net

JasonB

  • Newt
  • Posts: 38
  • perfectionist trapped inside the mind of an idiot.
Re: "ssget everything" for a single point?
« Reply #9 on: April 26, 2024, 06:22:58 AM »
In BricsCAD (ssget "_+.:E:S") does a single selection, acting like Entsel but will select everything under the cursor.

I also created the attached that does the same thing using a crossing polygon. The PICKBOXCOORD funtion returns a set of coordinates centred on the pick point and relative to the current pickbox size than can be used to define the crossing polygon.

Code - Auto/Visual Lisp: [Select]
  1. ;; PICKBOXCOORD
  2. ;; Pick Box Coordinates
  3. ;; Returns coordinates (list of 4 points defining a square) that are planar to the current display view, relative to the current pickbox size, and centred about the given point.
  4. ;; the given centre point must be in WCS
  5. ;; returned points are also in WCS
  6. ;; Includes an option to apply a scale factor to the current PICKBOX value.
  7. ;;
  8. ;; e.g for
  9. ;; (setvar 'PICKBOX 6) and in plan view
  10. ;; (PICKBOXCOORD (trans (getpoint) 1 0) 1)
  11. ;; ((72.0287613899495 74.940245442679 0.0) (72.0287613899495 75.8325809183257 0.0) (72.9210968655962 75.8325809183257 0.0) (72.9210968655962 74.940245442679 0.0))
  12. ;; (PICKBOXCOORD '(0 0 0) 1)
  13. ;; ((-0.446167737823339 -0.446167737823339 0.0) (-0.446167737823339 0.446167737823339 0.0) (0.446167737823339 0.446167737823339 0.0) (0.446167737823339 -0.446167737823339 0.0))
  14. ;; (PICKBOXCOORD '(0 0 0) 10)
  15. ;; ((-4.46167737823339 -4.46167737823339 0.0) (-4.46167737823339 4.46167737823339 0.0) (4.46167737823339 4.46167737823339 0.0) (4.46167737823339 -4.46167737823339 0.0))
  16.  
  17. (defun PickBoxCoord ( pctr factor / ratio pbox2)
  18.         ;;VIEWSIZE ; Current height of the viewport in drawing units
  19.         ;;SCREENSIZE ; x,y size of the viewport in pixels
  20.         (if (not factor) (setq factor 1))
  21.         (setq ratio (/ (getvar 'VIEWSIZE) (cadr (getvar 'SCREENSIZE)))) ; ratio between drawing units and pixels
  22.         (setq pbox2 (* (getvar 'PICKBOX) ratio 0.5 factor)) ; get 1/2 the current pickbox size in drawing units and apply factor if given
  23.         (setq pctr (trans pctr 0 2)) ; convert the given point to display coordinates
  24.         ;; Create a point list of each of the four corners
  25.         (mapcar '(lambda (pts) (trans pts 2 0))
  26.                         (list
  27.                                 (list (- (car pctr) pbox2) (- (cadr pctr) pbox2) (caddr pctr)) ; bottom left corner
  28.                                 (list (- (car pctr) pbox2) (+ (cadr pctr) pbox2) (caddr pctr)) ; top left corner
  29.                                 (list (+ (car pctr) pbox2) (+ (cadr pctr) pbox2) (caddr pctr)) ; top right corner
  30.                                 (list (+ (car pctr) pbox2) (- (cadr pctr) pbox2) (caddr pctr)) ; bottom right corner
  31.                         )
  32.         )
  33. )
  34.  

SSET Usage Example

Code - Auto/Visual Lisp: [Select]
  1. ;; PICKBOXSSET
  2. ;; Pick Box Selection Set
  3. ;; Creates a crossing box selection set based on the current pickbox size
  4. ;; relative to the given pick box centre point (in WCS)
  5. ;; returns a selection set if entities are found.
  6. ;; If not nil the factor will be applied to size of the current pickbox.
  7. ;;
  8.  
  9. ;; (PICKBOXSSET (trans (getpoint) 1 0) 1)
  10.  
  11. (defun PickBoxSSet ( pctr factor )
  12.         (ssget "_CP" (PICKBOXCOORD pctr factor))
  13. )

Test to visualise the selection box created by PICKBOXCOORD

Code - Auto/Visual Lisp: [Select]
  1. ;; DRAWPICK
  2. ;; Test of PICKBOXCOORD
  3. ;; Creates a 3DPOLY about the selected point
  4. ;; This should always be planar to the current display
  5.  
  6.  
  7. (defun C:DrawPick ( / pt gext coord)
  8.  (setq pt (getpoint "\nPick a point: "))
  9.  (cond (pt
  10.                         (setq pt (trans pt 1 0)) ; convert point to WCS
  11.                         (setq gext (PICKBOXCOORD pt 10))
  12.                                 (entmake
  13.                                                 (list
  14.                                                         '(0 . "POLYLINE")
  15.                                                         '(100 . "AcDbEntity")
  16.                                                         '(100 . "AcDb3dPolyline")
  17.                                                         '(70 . 9) ; 8 = 3DPOLY, 9 = Closed 3DPOLY
  18.                                                 )
  19.                                 )
  20.                                 (foreach coord gext
  21.                                         (entmake
  22.                                                 (list
  23.                                                         '(0 . "VERTEX")
  24.                                                         '(100 . "AcDbEntity")
  25.                                                         '(100 . "AcDbVertex")
  26.                                                         '(100 . "AcDb3dPolylineVertex")
  27.                                                         '(70 . 32)
  28.                                                         (cons '10 coord) ; Coordinate needs to be a list in the form (10 x y z)
  29.                                                 )
  30.                                         )                              
  31.                                 )
  32.                                 (entmake '((0 . "SEQEND")))
  33.                 )
  34.  )
  35.  (prin1)
  36. )

Peter2

  • Swamp Rat
  • Posts: 654
Re: "ssget everything" for a single point?
« Reply #10 on: Today at 09:32:02 AM »
Hi
thanks to all for the contributions. I made now a small code (coarse as usually) with works with a fixed "cross select box" around the cursor, displayed with grvecs. No error routine, no dynamic settings, tons of varibles  and so on, but basically it seem to work - but selecting big hatches stays a challenge.
Code - Auto/Visual Lisp: [Select]
  1. (defun c:nadelwahl ( / osmode_alt trackflag trackdata trackpoint lu lo ro ru nadel_aws)
  2.     (princ "\nPunkt klicken zur Nadelauswahl: ")
  3.     (setq osmode_alt (getvar "osmode"))
  4.     (setvar "osmode" 0)
  5.     (setq trackflag nil)
  6.     (while (not trackflag)
  7.         (setq trackdata (grread T) trackpoint (cadr trackdata))
  8.         (cond  
  9.             ((= (car trackdata) 3)      ; Punkt geklickt - speichern
  10.                 (setq trackflag T)
  11.                 (redraw)
  12.             )
  13.             ((= (car trackdata) 5)      ; Kreuz bewegt - zeichnen
  14.                 (setq lu (polar trackpoint (* 1.25 pi) 1.4)
  15.                       lo (polar trackpoint (* 0.75 pi) 1.4)
  16.                       ro (polar trackpoint (* 0.25 pi) 1.4)
  17.                       ru (polar trackpoint (* 1.75 pi) 1.4)
  18.                 )
  19.                 (redraw)
  20.                 (grvecs (list 6 lu lo lo ro ro ru ru lu lu ro lo ru))
  21.             )
  22.         )
  23.     )
  24.     (if trackpoint
  25.         (progn
  26.             (setq nadel_aws (ssget "_C" ro lu))
  27.             (if nadel_aws
  28.                 (progn
  29.                     (princ (strcat "\nGewählt: " (itoa (sslength nadel_aws)) " Element(e)."))
  30.                     (sssetfirst nadel_aws nadel_aws)
  31.                 )
  32.                 (princ (strcat "\nGewählt: 0 Elemente."))
  33.             )
  34.         )
  35.     )
  36.     (setvar "OSMODE" osmode_alt)
  37.     (princ)
  38. )
  39.  
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

JasonB

  • Newt
  • Posts: 38
  • perfectionist trapped inside the mind of an idiot.
Re: "ssget everything" for a single point?
« Reply #11 on: Today at 05:42:14 PM »
You mentioned in your original post that you were looking mainly for solid hatches. You could refine your SSGET call to limit its selection to just the entities that you seek.

e.g.
changing
Code - Auto/Visual Lisp: [Select]
  1. (setq nadel_aws (ssget "_C" ro lu))

to

Code - Auto/Visual Lisp: [Select]
  1. (setq nadel_aws (ssget "_C" ro lu '((0 . "HATCH")(2 . "SOLID"))))
will only allow selection of hatches with solid fill.

Filtering the selection set to just what you want makes the code following easier as you know what entities are in the selection set.