Author Topic: ssget CrossingPolygon error  (Read 1593 times)

0 Members and 1 Guest are viewing this topic.

DraxJDM

  • Newt
  • Posts: 48
ssget CrossingPolygon error
« on: August 26, 2022, 10:56:34 AM »
hey everyone,

I have a problem with the ssget _CP function.
with some forms of polyline I get a nil back instead of the elements inside.

attached there is a dwg file with 2 polylines and blocks.

the other attachment has code for 4 small routines that make the point list.

The first snippet works on both polylines, the other 3 only work on the small polyline.

These polylines are a small selection from a larger drawing, where I noticed that occasionally no selectionset was created.

Is there something that i do wrong?

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: ssget CrossingPolygon error
« Reply #1 on: August 26, 2022, 03:33:09 PM »
Are the objects visible within the drawing area when the selection is performed?

Graphical selection methods (such as Crossing/Window/Polygon/Fence etc.) require the target objects to be visible on screen in order to be selected; as such, you may need to perform a zoom to the selection window (or to an area slightly larger than the selection window) prior to performing the selection, and then perform a zoom previous to restore the original view.

DraxJDM

  • Newt
  • Posts: 48
Re: ssget CrossingPolygon error
« Reply #2 on: August 29, 2022, 02:43:01 AM »
good morning Lee,

yes al the objects are on screen, i do a zoom boundingbox on the polyline before using the ssget '_CP.

the strange thing is that the selection works on the most polylines but not on all.

BIGAL

  • Swamp Rat
  • Posts: 1436
  • 40 + years of using Autocad
Re: ssget CrossingPolygon error
« Reply #3 on: August 29, 2022, 09:02:45 PM »
"the strange thing is that the selection works on the most polylines but not on all."

Rather than a bounding box have you thought about using ZOOM C scale. If the objects are of a size that you would know then can set scale.

The other may be make the zoom window a bit bigger than the bounding box rather than exact size.
Code: [Select]
(setq LL (mapcar '+ minpoint (list -20 -20 0.0)))
(setq UR (mapcar '+ maxpoint (list 20 20 0.0)))
(command "zoom" "w" ll ur)
A man who never made a mistake never made anything

mhupp

  • Bull Frog
  • Posts: 250
Re: ssget CrossingPolygon error
« Reply #4 on: August 30, 2022, 03:09:41 AM »
This is what I came up with to select things inside polylines. it only calculates the points needed to make the selection set.

if the polyline only has line segments it only calculates the current vertex's
if the polyline has arc's it then calculates 4 more points along each arc. (is accurate for what i use it for, but use more segments on larger arcs)

Will allow you to keep making selections (more then one area if repeated). and alert you if anything is crossing the poyline.

it also picked up everything inside/crossing your poylines.
https://ibb.co/wMqL2my

Code - Auto/Visual Lisp: [Select]
  1. ;;----------------------------------------------------------------------------;;
  2. ;; Select entity's Inside Polyline
  3. (defun C:SI (/ ent SS1 SS2 n SS3)
  4.   (if (ssget "_I")          ; if there are preselected objects [= Implied selection]
  5.     (sssetfirst nil (setq SS (ssget "_I")))
  6.   )
  7.   (if (setq ent (car (entsel "\nSelect Polyline To Select Objects Inside ")))
  8.     (progn
  9.       (SELECTINSIDE ent)
  10.       (if (> (- (sslength SS2) 1) (sslength SS1))
  11.         (progn
  12.           (setq n (- (- (sslength SS2) 1) (sslength SS1)))
  13.           (alert (strcat "\n" (itoa n) " Entitys Crossing Selection Area"))
  14.           (if SS
  15.             (vl-cmdf "_.Select" SS SS2 "")
  16.             (vl-cmdf "_.Select" SS2 "")
  17.           )
  18.  
  19.         )
  20.         (if SS
  21.           (vl-cmdf "_.Select" SS SS1 ent "")
  22.           (vl-cmdf "_.Select" SS1 ent "")
  23.         )
  24.       )
  25.       (setq SS3 (ssget "_P"))
  26.       (sssetfirst nil SS3)
  27.     )
  28.   )
  29.   (princ)
  30. )
  31. ;;----------------------------------------------------------------------------;;
  32. ;; ssget "WP" doesn't work well with arc this fixes it
  33. (defun SELECTINSIDE (ent / poly obj seg lst len)
  34.   (setq poly (vlax-invoke (vlax-ename->vla-object ent) 'explode)) ;this creates an exploded copy of the polyline
  35.   (foreach obj poly ;steps though each segment of the exploded polyline to create the points list
  36.     (cond
  37.       ((eq (vla-get-Objectname obj) "AcDbArc")
  38.         (setq seg (/ (vla-get-arclength obj) 5))
  39.         (setq lst (cons (vlax-curve-getPointAtDist obj 0) lst))
  40.         (setq len seg)
  41.         (repeat 4
  42.           (setq lst (cons (vlax-curve-getPointAtDist obj len) lst))
  43.           (setq len (+ len seg))
  44.         )
  45.         (vla-delete obj)
  46.       )
  47.       ((eq (vla-get-Objectname obj) "AcDbLine")
  48.         (setq lst (cons (vlax-get obj 'StartPoint) lst))
  49.         (vla-delete obj)
  50.       )
  51.     )
  52.   )
  53.   (setq SS1 (ssget "_WP" lst))
  54.   (setq SS2 (ssget "_CP" lst))
  55. )
« Last Edit: August 30, 2022, 03:13:34 AM by mhupp »

DraxJDM

  • Newt
  • Posts: 48
Re: ssget CrossingPolygon error
« Reply #5 on: August 30, 2022, 03:46:19 AM »
Thx for the respons.

@Bigal
i used the bounding box to make the zoom window.
Tried your code to make the window bigger, with the same result.

@Mhupp
Your code also returned a nill to the polyline i am having trouble with.

At this point i think there is something with the polyline that gives my something strange in de point list to make CP.

mhupp

  • Bull Frog
  • Posts: 250

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: ssget CrossingPolygon error
« Reply #7 on: August 30, 2022, 07:42:52 AM »
I got it to work with my own way of coding.
 

DraxJDM

  • Newt
  • Posts: 48
Re: ssget CrossingPolygon error
« Reply #8 on: August 30, 2022, 10:10:42 AM »
tharwat, how did you do it.

in the code i posted, the first part is yours that creates 1000 points.
that code always worked for me  8-).

in the other parts that are not working, i try to use just the vertexes off the polyline to keep the points low and have no troubles in the corners.

Did you used your code that takes a 1000 points or a other?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: ssget CrossingPolygon error
« Reply #9 on: August 30, 2022, 10:13:42 AM »
I have sent you a private message since morning, so check it out.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: ssget CrossingPolygon error
« Reply #10 on: August 30, 2022, 02:35:13 PM »
Curious to see if the the code works with this drawing.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

mhupp

  • Bull Frog
  • Posts: 250
Re: ssget CrossingPolygon error
« Reply #11 on: August 30, 2022, 03:24:00 PM »
Curious to see if the the code works with this drawing.

Holy mother of god 177648 vertices! My computer almost crashed just selecting the polyline. took it about 1 min to make the selection and then crashed lol.
99% of the polylines I'm using that on only have max 100-200 vertexes with maybe 30-50 arcs.


ronjonp

  • Needs a day job
  • Posts: 7531
Re: ssget CrossingPolygon error
« Reply #12 on: August 30, 2022, 04:43:05 PM »
Curious to see if the the code works with this drawing.

Holy mother of god 177648 vertices! ...
:lol: :lol: I'm pretty sure the length of the list is limited with the ssget "CP" or "WP" options.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

DraxJDM

  • Newt
  • Posts: 48
Re: ssget CrossingPolygon error
« Reply #13 on: August 31, 2022, 03:33:26 AM »
@Muhupp
i have done that exact check  :-)

i still not have found wat makes that  it is not working on some polylines  :-(

mhupp

  • Bull Frog
  • Posts: 250
Re: ssget CrossingPolygon error
« Reply #14 on: August 31, 2022, 08:29:51 AM »
@Muhupp
i have done that exact check  :-)

i still not have found wat makes that  it is not working on some polylines  :-(

1037 objects audited
Total errors found during audit 1, fixed 1