Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello every one
I search for a lisp code to check
if the filter group with name "formwork" exist make a list of the layers inside this filter group
ifnot exist make a list of the layers in the DWG
i've made this trial the issue is about the filter group
(defun c:GetLayerList ()
(setq layerList '()) ; Initialize an empty list for layers
(setq layerTable (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) ; Get the Layers collection
; Try to find the "Formwork" filter group
(setq filterGroupExists nil)
(setq formworkLayers '())
; Check if a group filter exists
(vl-cmdf "_.-LAYER" "_FILTER" "_Edit" "Formwork" "_List" "_exit" "")
(if (= (getvar "CMDNAMES") "LAYER")
(progn
(setq filterGroupExists T)
(vl-cmdf "_List")
(while (> (getvar "CMDACTIVE") 0)
(command "")
)
; Collect layers from the "Formwork" filter (assuming output goes to command history)
(setq formworkLayers (read (vl-string-trim "\n" (getvar "CMDLINE"))))
)
)
; If the group exists, use its layers; otherwise, get all layers
(if filterGroupExists
(setq layerList formworkLayers)
(vlax-for layer layerTable
(setq layerList (cons (vla-get-name layer) layerList)) ; Add layer names to the list
)
)
; Return the layer list
layerList
)
and see the attached dwg
thanks in advance
Solved! Go to Solution.