So my end goal is to convert these AutoLISP functions to .NET:
(vl-load-com)
(setq CUSTOM_FNAM (strcat "C:/Users/" (getvar 'loginname) "/Desktop/Action_tile.lsp"))
(defun *error* (msg)
(princ "Error: ")
(princ msg)
(princ)
)
(defun readFunctionPrint (str / JO_file)
(if
(and
CUSTOM_FNAM
(setq JO_file (f_open CUSTOM_FNAM "a"))
)
(progn
(princ str JO_file)
(f_close JO_file)
)
)
)
(if (not f_close)
(progn
(setq f_close close)
(and (not f_open) (setq f_open open))
(setq close
(lambda (file / JO_file)
(if
(and
CUSTOM_FNAM
(setq JO_file (f_open CUSTOM_FNAM "a"))
)
(progn
(princ (strcat "(close " (vl-prin1-to-string file) ")") JO_file)
(princ "\n" JO_file)
(f_close JO_file)
)
)
(f_close file)
)
)
)
)
(if (not f_open)
(progn
(setq f_open open)
(and (not f_close) (setq f_close close))
(setq open
(lambda (key action / JO_file)
(if
(and
CUSTOM_FNAM
(setq JO_file (f_open CUSTOM_FNAM "a"))
)
(progn
(princ (strcat "(open " (vl-prin1-to-string key)) JO_file)
(princ " " JO_file)
(princ (strcat (vl-prin1-to-string action) ")") JO_file)
(princ "\n" JO_file)
(f_close JO_file)
)
)
(f_open key action)
)
)
)
)
(if (not f_action_tile)
(progn
(setq f_action_tile action_tile)
(setq action_tile
(lambda (key action / JO_file)
(if
(and
CUSTOM_FNAM
(setq JO_file (f_open CUSTOM_FNAM "a"))
)
(progn
(princ (strcat "(action_tile " (vl-prin1-to-string key)) JO_file)
(princ "\n\t" JO_file)
(princ (strcat (vl-prin1-to-string action) "\n)") JO_file)
(princ "\n" JO_file)
(f_close JO_file)
)
)
(f_action_tile key (strcat action "(readFunctionPrint (strcat \"(set_tile " key " $value) ; \" $value \"\n\"))"))
)
)
)
)
This code will read all of the code within dialog boxes that work with AutoLISP.
The problem with AutoLISP is that you cannot create optional arguments to functions. In .NET you can and so that is what I am trying to do here. However, I am not familiar with C#.NET with AutoCAD so I am struggling. I need to find a way to export the function name, its arguments, and its result after execution as a comment in a text file.
I would like a way to simply provide a function as an argument to a .NET function. With an anonymous function as a return. This anonymous function will be stored in the symbol of the original function. This function will both invoke the original function and export the data to a file.
I am trying to do this with objects in .NET, based on your description, it seems I cannot do this with objects.