Jump to content
Lee Mac

Tutorial: Loading Programs Automatically

Recommended Posts

Lee Mac

I finally got around to writing this tutorial which hopefully encompasses everything a user might need to know on the topic of loading programs on startup.

 

Loading Programs Automatically

 

As always, your feedback is very welcome should you have any suggestions for improvement, criticism, or indeed discover mistakes in the content.

 

Enjoy!

 

Lee

Edited by Lee Mac

Share this post


Link to post
Share on other sites
pBe

Great tutorial Lee.

Thank you for the lessons my friend :)

 

Question for you.

Is it advisable to load lisp that are programmed to run upon loading and not as a sub for the current active lisp?

 

(defun c:Drawline ()
  (setq ...)
        (if ()
   (load "C:\\My Folder\\MyProgram\\ChangeProgram")
   )
 )

 
(defun c:ChangeMe ()
  (...
   ...)
 );defun
(c:ChangeMe)

 

or is it better this way?

 

 
;;ACADDOC.lsp
 (.......
 (autoload "LineProgram" '("DrawLine"))
 (autoload "ChangeProgram" '("ChangeMe"))
 (.....

 

 

 
(defun c:Drawline ()
  (setq ...)
        (if ()
   (ChangeMe)
   )
 )

 

or neither?

or better yet stick with sub-routine from the toolbox functions?

 

This are jsut few from my collection "Bad Habits for Coding in Vlisp: Don't do it" :)

Edited by pBe
Typo error

Share this post


Link to post
Share on other sites
Lee Mac

Thanks pBe :)

 

With regards to your question, if the LISP is programmed to run automatically upon loading, then using 'autoload' will cause the LISP to run twice since the autoload function will also call the program following loading.

 

I suppose it depends on what kind of behaviour you are looking for. For example, with some reactors, you might want them to be loaded and running in the background when you open a new drawing - and so programming these to run when loaded then using the 'load' function in the ACADDOC.lsp is perhaps the easiest solution.

 

However, if you are just looking to load a normal program to be called at the command line when the user needs it, then I would just use the 'autoload' function within the ACADDOC.lsp which will handle the first-time loading for you (otherwise, perhaps write your own autoload function as demonstrated here).

 

Lee

Share this post


Link to post
Share on other sites
Fnuik

An other id is when u have a CUI file and a corresponding .MNL (Lisp) file with the same name in the same folder, the mnl file will load automaticly with the cui file.

 

:) Thats how i do it

Share this post


Link to post
Share on other sites
Bhanson

Thanks for the tutorial.

 

I did have a question though. Would it be advantageous to use the autoload command in ACADDOC.lsp when testing new code so that every time I would go to type in the function name it would re-load the file and any changes that have been made since I opened the drawing?

 

Just Wondering.

Thx

Share this post


Link to post
Share on other sites
Lee Mac
Thanks for the tutorial.

 

You're welcome :)

 

I did have a question though. Would it be advantageous to use the autoload command in ACADDOC.lsp when testing new code so that every time I would go to type in the function name it would re-load the file and any changes that have been made since I opened the drawing?

 

Autoload will not 'reload' the function everytime you type the command syntax - it will only load the file once, the first time the user types the command.

 

Why not edit/reload code using the VLIDE?

Share this post


Link to post
Share on other sites
Bhanson

Thanks :D, I've been teaching myself AutoLisp for about a year now but there are a quite a few little tricks I simply haven't learned yet.

Share this post


Link to post
Share on other sites
Lee Mac
Thanks :D, I've been teaching myself AutoLisp for about a year now but there are a quite a few little tricks I simply haven't learned yet.

 

The VLIDE really is the way to go - even if you are just going to use AutoLISP and not stray into Visual - its got great debugging capabilities and the Help documentation is only a click away.

 

Lee

Share this post


Link to post
Share on other sites
alanjt
The VLIDE really is the way to go - even if you are just going to use AutoLISP and not stray into Visual - its got great debugging capabilities and the Help documentation is only a click away.

 

Lee

Hell, I'd use it simply because it has automatic formatting and you can load it directly into AutoCAD for testing, etc.

Share this post


Link to post
Share on other sites
Lee Mac
Hell, I'd use it simply because it has automatic formatting and you can load it directly into AutoCAD for testing, etc.

 

Exactly. I sometimes use Notepad++ because it has more formatting tricks, but mostly the VLIDE due to how directly something can be loaded.

Share this post


Link to post
Share on other sites
alanjt
Exactly. I sometimes use Notepad++ because it has more formatting tricks, but mostly the VLIDE due to how directly something can be loaded.

Ehh, the formatting is close enough for me and I couldn't trade the ability to load directly.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...