TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: w64bit on July 16, 2021, 05:07:48 AM

Title: Selection set of regions with non-default materials
Post by: w64bit on July 16, 2021, 05:07:48 AM
How can I make a selection set of regions having materials other than default materials (ByBlock, ByLayer or Global)?
Title: Re: Selection set of regions with non-default materials
Post by: Marc'Antonio Alessi on July 17, 2021, 03:39:39 AM
If I understand correctly this can help:
Code: [Select]
; PrpVal wcmatch style
; (ALE_SelSet_RemoveByProperty #SSet1 'EntityTransparency  "70") >  = 70
; (ALE_SelSet_RemoveByProperty #SSet1 'EntityTransparency "~70") > /= 70
;
(defun ALE_SelSet_RemoveByProperty (SelSet PrpNam PrpVal / Countr EntNam EntObj)
  (if SelSet
    (repeat (setq Countr (sslength SelSet))
      (and
         (setq EntNam (ssname SelSet (setq Countr (1- Countr)))  EntObj (vlax-ename->vla-object EntNam))
         (vlax-property-available-p EntObj PrpNam)
         (wcmatch (vlax-get EntObj PrpNam) PrpVal) ; 20210630 sostituito eq con wcmatch
         (setq SelSet (ssdel EntNam SelSet))
      )
    )
  )
  SelSet
)
Title: Re: Selection set of regions with non-default materials
Post by: roy_043 on July 17, 2021, 07:05:10 AM
Code - Auto/Visual Lisp: [Select]
  1.   lst (dictsearch (namedobjdict) "ACAD_MATERIAL")
  2.   enm-bylayer (cdadr (member '(3 . "ByLayer") lst))
  3.   enm-byblock (cdadr (member '(3 . "ByBlock") lst))
  4.   enm-global (cdadr (member '(3 . "Global") lst))
  5.   ss
  6.     (ssget
  7.       "_X"
  8.       (list
  9.         '(0 . "REGION")
  10.         '(-4 . "<NOT")
  11.           '(-4 . "<OR")
  12.             (cons 347 enm-bylayer)
  13.             (cons 347 enm-byblock)
  14.             (cons 347 enm-global)
  15.           '(-4 . "OR>")
  16.         '(-4 . "NOT>")
  17.       )
  18.     )
  19. )
  20. (sssetfirst nil ss)
Title: Re: Selection set of regions with non-default materials
Post by: w64bit on July 18, 2021, 06:23:15 AM
Excellent.
Thank you all very much.