Jump to content

Tutorial: Loading Programs Automatically


Lee Mac

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...