cagorskij Posted July 18 Share Posted July 18 Hiya o/ Just wondering how to make it so that when you load a lisp file into CAD, that it spits out the function's name & not some other sub-function within the lisp file (i.e. if there's 2 'defun's, it usually echos the last defun) What I've been doing is ordering the defuns so the main function appears last, but that feels wrong/messy. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 18 Share Posted July 18 Try adding a (princ) as very last line. 1 Quote Link to comment Share on other sites More sharing options...
cagorskij Posted July 18 Author Share Posted July 18 Thank you! It seems to simply return nothing when loading, and if I add a string it'll output twice, like this: (princ "Function loaded.") : Function loaded."Function loaded." I assume because it's running the princ as well as outputting the return value? Quote Link to comment Share on other sites More sharing options...
fuccaro Posted July 18 Share Posted July 18 You could try to define the second function *inside* the first function. Something like: (defun c:function1() (defun function2(position) (entmake (list '(0 . "POINT") (cons 10 position)) ) ) (setq ang 0.0 ang1 0.1) (repeat 1000 (setq x (sin (* 5.0 ang)) y (cos (* 7.0 ang)) z (* (cos ang) (sin ang)) ang (+ ang ang1) ) (function2 (list x y z)) ) ) If you load this, AutoCAD will report only "function1 loaded". Does this help you? 1 Quote Link to comment Share on other sites More sharing options...
exceed Posted July 19 Share Posted July 19 (edited) 19 hours ago, cagorskij said: Thank you! It seems to simply return nothing when loading, and if I add a string it'll output twice, like this: (princ "Function loaded.") : Function loaded."Function loaded." I assume because it's running the princ as well as outputting the return value? (defun c:foo ( / ) ;~~~~ (princ) ;<- this one ) (defun subfunc1 ( / ) ;~~~~ ) (defun subfunc2 ( / ) ;~~~~ ) (princ "\n function FOO loaded.") (princ) like this Edited July 19 by exceed 1 Quote Link to comment Share on other sites More sharing options...
cagorskij Posted July 19 Author Share Posted July 19 Thank you both ^_^ Quote Link to comment Share on other sites More sharing options...
CyberAngel Posted July 19 Share Posted July 19 On 7/17/2024 at 9:08 PM, cagorskij said: What I've been doing is ordering the defuns so the main function appears last, but that feels wrong/messy. In some languages you have to do it that way. If the subfunctions haven't loaded, you can't call them. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.