ymg, I couldn't make better gif as it's big for the site... I'll explain :
- you told us to delete tin.dcl from temp folder, but you could make it be deleted automatically after usage, so I removed "fn" variable from locals and used (vl-file-delete fn) after two places (unload_dialog ...)... Now you can make updates to dcl and every new one will be actual...
- subfunction (regular) which is used in XSHAPE command had some typos, so I've modified it, not so important thing as it works and without my mod, but I think this was to be written correctly...
- finally at the end when main program is working, I've found that sometime CAD can't find distatpoint as point isn't on selected line, pline and to me it returned for first point dist nil and it should return 0.0...
So this line :
(if (= opt 1)
(progn
(setq disl (mapcar '(lambda (a) (vlax-curve-getDistAtPoint en a)) pol))
...
I've replaced with :
(if (= opt 1)
(progn
(setq disl (mapcar '(lambda (a) (vlax-curve-getDistAtPoint en (vlax-curve-getClosestPointTo en a))) pol))
...
and it worked - command PROFILE didn't fail...
Also I've noticed that you must start PROFILE command and cancel dialog to get displayed min and max Z values of section TIN, but I think that's not so important... DATUM values are recognized correctly in dialog, only this is little unexpected procedure for someone that wants to modify DATUM values...
So that's all that I've found till now... It works fine, congrats ymg...