@vishshreevT578L wrote:
(defun CopyLayerColor2 (ent1 ent2 / elist1 elist2 lay1 col1)
....
my question is about declaring variable which i am making bold. (defun CopyLayerColor2 (ent1 ent2 / elist1 elist2 lay1 col1)
The trick is in the use of a function like that, with arguments. Since it does not have a C: before the function name, it is a function, and not a command, which means it must be called inside parentheses, just as with any other AutoLisp function, and not by entering the name at the Command prompt.
The things in the parentheses following the function name are distinguished by whether they are before or after the slash character. Those that are before it are arguments, and you must supply them [I assume that's what you mean by "declaring" them] when you use the function, inside the parentheses calling the function, after the function name, and in the order in the arguments list. They must be the kind of thing that the function will be looking for, in this case entity names. This is how you would use that function:
(CopyLayerColor2 anEntityName anotherEntityName)
Those entity names can be supplied from variables, which you would set by some other means external to this function definition, such as @ВeekeeCZ's first code in Post 4. Or one of them could be (entlast), or either or both could be taken from a list of them with something like (nth) or (car)/(cadr)/(etc.) or (last), or from a selection set with (ssname), or by (entnext), or any other means of conveying an entity name.
Note that the second code in Post 4 doesn't merely redefine the function, but defines it instead as a Command name [with the C: prefixed], without arguments but with selection of entities built into it. That one you would use by just typing in the command name, without surrounding parentheses.
Kent Cooper, AIA