Author Topic: ssget for specific layer and color byt not bylayer  (Read 3941 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
ssget for specific layer and color byt not bylayer
« on: November 11, 2012, 10:05:02 AM »
Probably simple, but I'm not finding the right syntax.  I am trying to filter entities by color and layer, but I need to exclude entities that have an RGB color set in dxf code 420.  I've tried a number of variants of this:

(setq color1 1)
(setq layer1 "power"
(setq selset (ssget "_X" (list (cons 62 color1) (cons 8 layer1) (-4 . "!=") (cons 420 "*") )))

The problem is in the "but with no value for dxf code 420" syntax.

Thanks for any suggestions. 

"Science is the belief in the ignorance of experts." - Richard Feynman

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ssget for specific layer and color byt not bylayer
« Reply #1 on: November 11, 2012, 10:41:37 AM »
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.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: ssget for specific layer and color byt not bylayer
« Reply #2 on: November 11, 2012, 11:56:11 AM »
Try:
Code - Auto/Visual Lisp: [Select]
  1. (ssget "_X"
  2.    '(
  3.         (62 . 1)
  4.         (8 . "power")
  5.         (-4 . "<NOT")
  6.             (-4 . "*")
  7.             (420 . 0)
  8.         (-4 . "NOT>")
  9.     )
  10. )

hmspe

  • Bull Frog
  • Posts: 362
Re: ssget for specific layer and color byt not bylayer
« Reply #3 on: November 11, 2012, 06:06:30 PM »
Thanks for the suggestions.  Closer, but I'm not quite there yet.

CAB's code works, but I haven't managed to convert it to an automatic routine.  I need something that does not require any manual selections.  A description of what I'm working on is at the bottom of this post.

Lee's code is perfect for a hard-coded value for color, but I need to iterate through all the colors.  If I change
Code: [Select]
(ssget "_X" '((62 . 1) (8 . "power")  (-4 . "<NOT")  (-4 . "*")  (420 . 0)  (-4 . "NOT>")))to
Code: [Select]
(ssget "_X" '((62 . COUNTER) (CONS 8 layer_name) (-4 . "<NOT") (-4 . "*") (420 . 0) (-4 . "NOT>")))Bricscad reports error : bad argument type <(62 . COUNTER)> ; expected <INTEGER> at [DXF/XED DATA]    Autocad is not as helpful in its error message.  This is with a (setq counter 1) just before.

With
Code: [Select]
(ssget "_X" '((CONS 62 COUNTER) (CONS 8 layer_name) (-4 . "<NOT") (-4 . "*") (420 . 0) (-4 . "NOT>")))the color is ignored and I get all entities.


I'm playing with a routine to simulate locked layer fading in Bricscad.  The concept is to copy all entities on the layer-to-fade to a new temporary layer, take the blocks on the temporary layer to linework, then reset entity colors on the temporary layer to RGB colors that are 60% of the original RGB values.  The original layer is then locked, frozen, and turned off and the temporary layer is locked.  Each faded layer has a separate temporary layer so that unfading a layer just requires deleting the temporary layer then restoring the original layer.  I have a version that works fairly well but that creates the temporary entities from blocks by exploding vla objects.  It does not handle all entities as well as I'd like.  I had the idea that it would be a lot easier to do a process using COPYBASE to get entities to the temporary layer, then iBurst (Lee's program slightly modified to accept a passed-in layer name) to take the blocks to linework, then handle the color changes on the temporary layer by getting a selection set for each entity color and changing the colors of the selection set with CHPROP.  The problem I'm running in to is that when I assign an RGB color to an entity by assigning a dxf 420 code entry the normal color code (dxf 62) is automatically changed to a color visually close to the RGB color.  For example red entities are changed to color 14 in dxf code 62.  If I'm looping for color 1 to color 255 that means red entities get changed to 14 on the first step of the loop, and when the loop reaches color 14 those entities get dimmed a second time.  Starting the loop at color 255 and going down to 1 changes which entities get dimmed more than once but doesn't eliminate the problem.  My idea was to eliminate entities that  already have a dxf 420 code when I get a selection set for a particular entity color, but I have not been successful so far in getting both the layer and the current color passed in to a filter as variables.  My though is that having ssget do the filtering will be faster than having a post-filter.  I could always do hard coded calls for each of the colors.  That worked for Microsoft in early versions of Word, but it doesn't seem like good practice.




 
"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: ssget for specific layer and color byt not bylayer
« Reply #4 on: November 11, 2012, 06:58:31 PM »
The apostrophe is used to mark an expression as literal; if you need expressions to be evaluated, use:

Code - Auto/Visual Lisp: [Select]
  1. (setq color 1
  2.       layer "power"
  3. )
  4. (ssget "_X"
  5.     (list
  6.         (cons 62 color)
  7.         (cons 8 layer)
  8.        '(-4 . "<NOT")
  9.            '(-4 . "*")
  10.            '(420 . 0)
  11.        '(-4 . "NOT>")
  12.     )
  13. )

hmspe

  • Bull Frog
  • Posts: 362
Re: ssget for specific layer and color byt not bylayer
« Reply #5 on: November 11, 2012, 07:30:05 PM »
Perfect.  Thanks.
"Science is the belief in the ignorance of experts." - Richard Feynman