@istvan_voiculescu wrote:
1. Select the target layer by selecting one object in the drawing.
2. Display target layer in a dialog box. or list it in the command line.(So we know what layer is selected)
3. Provide a command line where we can type a layer or list box of the layers in the CAD file to select from for the source data to be matched.
4. Apply the change.
;; List Box - Lee Mac
;; Displays a DCL list box allowing the user to make a selection from the supplied data.
;; msg - [str] Dialog label
;; lst - [lst] List of strings to display
;; bit - [int] 1=allow multiple; 2=return indexes
;; Returns: [lst] List of selected items/indexes, else nil
(defun LM:listbox ( msg lst bit / dch des tmp rtn )
(cond
( (not
(and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
(strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
(if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}"
)
des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch)
)
)
(prompt "\nError Loading List Box Dialog.")
)
( t
(start_list "list")
(foreach itm lst (add_list itm))
(end_list)
(setq rtn (set_tile "list" "0"))
(action_tile "list" "(setq rtn $value)")
(setq rtn
(if (= 1 (start_dialog))
(if (= 2 (logand 2 bit))
(read (strcat "(" rtn ")"))
(mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
)
)
)
)
)
(if (< 0 dch)
(unload_dialog dch)
)
(if (and tmp (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
rtn
)
(defun c:match-layer-prop (/ source target)
;; _gile | pbe 2021 ;;
(defun _Layerlist (cs / a ln ls)
(while (setq a (tblnext "Layer" (null a)))
(cond
((or (vl-string-search "$0$" (setq ln (cdr (assoc 2 a))))
(member ln (list "0" "Defpoints" cs))))
((setq ls (cons ln ls)))))
ls
)
(if
(and
(setq target (car (entsel "\nSelect an object on target layer: ")))
(setq target (entget (tblobjname "layer"
(setq lnm (cdr (assoc 8 (entget target)))))))
(setq layList (_Layerlist lnm))
(setq source (car (LM:listbox (strcat "Select layer to matched with " lnm ) layList 0)))
(setq source
(entget (tblobjname "layer" source)
)
)
)
(progn
(entmod
(append (vl-remove-if
'(lambda (x) (member (car x) '(70 62 6 290 370 390 347)))
target
)
(vl-remove-if-not
'(lambda (x) (member (car x) '(70 62 6 290 370 390 347)))
source
)
)
)
(entupd (cdr (assoc -1 target)))
)
)
(princ)
)
Command: MATCH-LAYER-PROP
Select an object on target layer:

@istvan_voiculescu wrote:
It fails at the selecting the source section where I get an lentityp error... What am I missing?,,
This will fail
...
(setq source (getstring 1 "\nWhat layer should be matched to: "))
(setq source
(entget (tblobjname "layer" (cdr (assoc 8 (entget source))))
)
)
...
As source is a string as a result from getstring and entget requires an ename to work
...
(setq source (getstring 1 "\nWhat layer should be matched to: "))
(setq source
(entget (tblobjname "layer" source)
)
)
HTH