Author Topic: Create a layer filter if Attribute tag value = X  (Read 155 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Newt
  • Posts: 67
Create a layer filter if Attribute tag value = X
« on: January 07, 2019, 03:29:49 PM »
I want to use this portion of code...
Code - Auto/Visual Lisp: [Select]
  1. (defun FDN_LayGrpFltr ()
  2.  
  3. (setq osm (getvar 'osmode))
  4.  (setvar 'osmode 0)
  5.  (setvar 'cmdecho 0)
  6.  (defun lm:getattributevalue (blk tag / val enx)
  7.    (while
  8.      (and (null val) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))))
  9.       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  10. (setq val (cdr (assoc 1 enx)))
  11.       )
  12.    )
  13.  )
  14.  
  15.  (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  16.  )
  17.  (setq attvalue (lm:getattributevalue (ssname ss 0) "TITLELINE4"))
  18.  (cond ((wcmatch (strcase attvalue) "FOUNDATION PLAN")
  19.  

with something like this

Code - Auto/Visual Lisp: [Select]
  1.  
  2.   (command "._layer" "Filter" "New" "Group" "" "S-FDN-*" "S_FDN_Layers" "")
  3. (command "._layer" "Make" "S_FDN" "color" "Cyan" "S_FDN" "")
  4. )
  5.     )
  6.   )
  7.  (setvar 'osmode osm)
  8.  (setvar 'cmdecho 1)
  9. )
  10. (FDN_LayGrpFltr)

To create a layer filter group if the TitleLine4 reads "x" (Foundation Plan in this example).

The alternative to using the Attribute tag value would be to use the paper space tab name 'Foundation Plan".

I'm getting the "bad argument type: lselsetp nil. I assume because I'm missing an ssnamex

Code - Auto/Visual Lisp: [Select]
  1.    (if (setq FDNLay (ssget "X" '((8 . "S-FDN"))))
  2.      (foreach x (mapcar 'cadr (ssnamex FDNLay))

Or something to this effect.

J. Logan
ACAD 2018

I am one with the Force and the Force is with me.

Dlanor

  • Newt
  • Posts: 118
Re: Create a layer filter if Attribute tag value = X
« Reply #1 on: January 08, 2019, 03:11:19 AM »
The error means there is nothing in the selection set, i.e. there are no objects on layer "S-FDN"

jlogan02

  • Newt
  • Posts: 67
Re: Create a layer filter if Attribute tag value = X
« Reply #2 on: January 08, 2019, 12:00:58 PM »
Gaaaaahhh!!! I knew that. Simple things.

I kept saying it's not find what it's looking for.

Thank D.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.