Autolisp user function overloading -


you can read on autocad knowledge website:
"note: can define multiple user functions same name, have each definition accept different number or type of arguments."
has using feature? tried not work @ all. can call latest defined function.if call (file::appendfile arg1) autocad said give less argument
enter image description here

i'm not @ computer autocad installed, can't check if autolisp works way documentation says should, know i've seen workaround pass variable number of arguments function.

the trick pass arguments single list, , process list in body of function. example:

(defun myfunction (argslist / path header)   (setq path (car argslist))   (setq header (cadr argslist))   (somefunction path "a" header) ) 

... , you'd call function (myfunction '(arg1)) or (myfunction '(arg1 arg2)).

note in examples above i'm using list constructor literal, pass in actual strings "arg1" , "arg2". if want pass in contents of variables, you'd need use form (myfunction (list var1 var2)) instead.

it's little bit ugly, it's option.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -