Author Topic: ssget filter groupcode sequence?  (Read 6011 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
ssget filter groupcode sequence?
« on: August 04, 2012, 09:51:18 AM »
Can the (ssget) function filter for a groupcode sequence?

I am working on an application that currently stores two values (width and height) as 1040 groupcodes values in xdata. Using the code below will select all entities with either the height OR the width set to 1000.0. And I would like to select only those entities that have the width AND height set to 1000.0.

I am now thinking of combining the height and width in a groupcode 1010 (point) value, but would still be interested to know if there is any way to make (ssget) respect a groupcode sequence.

Code - Auto/Visual Lisp: [Select]
  1.   (ssget
  2.     "_X"
  3.     (list
  4.       (list
  5.         -3
  6.         (list
  7.           "MyApp"
  8.           '(1002 . "{")
  9.           (cons 1000 "WIDTH")
  10.           (cons 1040 1000.0)
  11.           '(1002 . "}")
  12.           '(1002 . "{")
  13.           (cons 1000 "HEIGHT")
  14.           (cons 1040 1000.0)
  15.           '(1002 . "}")
  16.         )
  17.       )
  18.     )
  19.   )
  20. )

ronjonp

  • Needs a day job
  • Posts: 7531
Re: ssget filter groupcode sequence?
« Reply #1 on: August 04, 2012, 10:04:53 AM »
I don't think you can filter beyond the appname.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: ssget filter groupcode sequence?
« Reply #2 on: August 04, 2012, 10:47:21 AM »
I don't think you can filter beyond the appname.

Ditto, from the VLIDE Help:

Quote from: VLIDE > Using the AutoLISP Language > Using AutoLISP to Manipulate AutoCAD Objects > Selection Set Handling > Selection Set Filter Lists > Filtering for Extended Data
Using the ssget filter-list, you can select all entities containing extended data for a particular application.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: ssget filter groupcode sequence?
« Reply #3 on: August 04, 2012, 03:41:00 PM »
I guess this feature is unique to Bricscad:
SR32664 - LISP/SDS/BRX: ssget("X" filter) failed to select entities using XData group code specifications, example: (ssget "X" (list (list -3 (list "APPID" (cons 1005 "323")))))
I definitely like it!

But is it generally speaking possible to filter for groupcode sequences? Let's say you want to select rectangles (lwpolylines) with at least two filleted corners. Can this be done with (ssget)?

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: ssget filter groupcode sequence?
« Reply #4 on: August 05, 2012, 10:00:53 AM »
But is it generally speaking possible to filter for groupcode sequences? Let's say you want to select rectangles (lwpolylines) with at least two filleted corners. Can this be done with (ssget)?

After a very brief test, it would seem to appear that this is indeed possible.

To test, I created two simple LWPolylines:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:entmakeit ( )
  2.     (entmake
  3.        '(
  4.             (0 . "LWPOLYLINE")
  5.             (100 . "AcDbEntity")
  6.             (100 . "AcDbPolyline")
  7.             (90 . 3)
  8.             (70 . 1)
  9.             (10 0.0 0.0)
  10.             (10 1.0 0.0)
  11.             (10 1.0 1.0)
  12.         )
  13.     )
  14.     (entmake
  15.        '(
  16.             (0 . "LWPOLYLINE")
  17.             (100 . "AcDbEntity")
  18.             (100 . "AcDbPolyline")
  19.             (90 . 3)
  20.             (70 . 1)
  21.             (10 0.0 0.0)
  22.             (10 1.0 0.0)
  23.             (10 1.0 2.0)
  24.         )
  25.     )
  26. )

Then used the following ssget filter to make a selection:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:ssgetit ( )
  2.     (sssetfirst nil (ssget "_X" '((0 . "LWPOLYLINE") (10 1.0 0.0) (10 1.0 1.0))))
  3. )

The result was as expected with only the first LWPolyline being selected by the filter, though, this simple test obviously isn't conclusive to encompass the claim for all DXF group codes and values.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filter groupcode sequence?
« Reply #5 on: August 05, 2012, 10:37:42 AM »
This works for > one filleted corner, not sure how to test for > 1 corner.

Code: [Select]
(setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "/=") '(42 . 0.0))))
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.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: ssget filter groupcode sequence?
« Reply #6 on: August 05, 2012, 03:54:49 PM »
@ Lee:
Your test is not conclusive because point (1.0 1.0) does not occur in the second lwpolyline.

If I use this version of (c:entmakeit) both entities are selected with your filter:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:entmakeit ( )
  2.     '(
  3.       (0 . "LWPOLYLINE")
  4.       (100 . "AcDbEntity")
  5.       (100 . "AcDbPolyline")
  6.       (90 . 3)
  7.       (70 . 1)
  8.       (10 0.0 0.0)
  9.       (10 1.0 0.0)
  10.       (10 1.0 1.0)
  11.     )
  12.   )
  13.     '(
  14.       (0 . "LWPOLYLINE")
  15.       (100 . "AcDbEntity")
  16.       (100 . "AcDbPolyline")
  17.       (90 . 5) ; Changed to 5.
  18.       (70 . 1)
  19.       (10 0.0 0.0)
  20.       (10 1.0 0.0)
  21.       (10 1.0 2.0)
  22.       (10 1.0 1.0) ; Added point.
  23.       (10 0.0 1.0) ; Added point.
  24.     )
  25.   )
  26. )
« Last Edit: August 05, 2012, 03:57:56 PM by roy_043 »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: ssget filter groupcode sequence?
« Reply #7 on: August 05, 2012, 04:10:41 PM »
This works for > one filleted corner, not sure how to test for > 1 corner.

Code: [Select]
(setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "/=") '(42 . 0.0))))
This will select all lwpolylines without any straight segments. So filleted rectangles will not be selected.

This will select all rectangles with at least one filleted corner:
Code: [Select]
(setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<OR") (cons 42 (- (sqrt 2) 1)) (cons 42 (- 1 (sqrt 2))) '(-4 . "OR>"))))

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: ssget filter groupcode sequence?
« Reply #8 on: August 05, 2012, 05:43:49 PM »
@ Lee: Your test is not conclusive because point (1.0 1.0) does not occur in the second lwpolyline.

:self-faceplam: You're quite right roy, my test is meaningless  :ugly:

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: ssget filter groupcode sequence?
« Reply #9 on: August 06, 2012, 05:26:21 AM »
Code: [Select]
(setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "/=") '(42 . 0.0))))
On reconsidering this filter I am having doubts if Bricscad's behaviour is correct. As explained before Bricscad will only select lwpolylines without any straight segments. It seems not logical that an lwpolyline with a curved segment and a straight segment does not pass the filter...?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget filter groupcode sequence?
« Reply #10 on: August 06, 2012, 08:38:19 AM »
Roy that filter will select any pline with a bulge and does not fit your requirements.
I think it can only be done by simulating the ssget with code.
Or post process the selection set to eliminate unwanted items.
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.