Author Topic: Combine multiple lisp routines?  (Read 3568 times)

0 Members and 1 Guest are viewing this topic.

DanB

  • Bull Frog
  • Posts: 367
Combine multiple lisp routines?
« on: July 31, 2018, 08:25:14 AM »
I'm putting together a custom ribbon to share with co-workers. My first run through has about 10 custom commands. Customization will be stored on the server. I've compiled the individual routines into *.fas files. Is it possible to go a step further and combine all the routines into a single file? Recommended?

ChrisCarlson

  • Guest
Re: Combine multiple lisp routines?
« Reply #1 on: July 31, 2018, 08:52:05 AM »
Just combine all of the files into a single lisp file and then compile.

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
Re: Combine multiple lisp routines?
« Reply #2 on: July 31, 2018, 09:11:28 AM »
I use a different approach.  My ribbon calls many custom lisp commands.  I don't preload the lisp for any of them.  Using either the autoload (AutoLISP) function or the acet-autoload2 (Express Tool) function allows your users to enter the command name of a lisp routine and have it automatically load if it hasn't already been loaded and run without preloading any of them.  Much easier to avoid or find conflicts with lisp routines when they're loaded as needed.  What happens when one of them doesn't work as expected with your next upgrade?

Most of my lisp is run from the ribbon so I'll use a macro like:
Code: [Select]
^P(or C:Rotoggle (load "Rotoggle.lsp"));Rotoggle which loads the lisp only if it's not already loaded, then runs the command.  As this particular macro toggles text rotation between horizontal and 0 I put it in the Shortcut for Text & Mtext Object & Objects Menus.  Putting most modify commands for specific object types in the Shortcut Menus simplifies the ribbon.  Our custom CUI has two Tabs with many Panels and I keep it trimmed down as best I can.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

DanB

  • Bull Frog
  • Posts: 367
Re: Combine multiple lisp routines?
« Reply #3 on: July 31, 2018, 09:29:59 AM »
Just combine all of the files into a single lisp file and then compile.

That goes back to my question, is this simply cut-n-paste from each routine into a single *.lsp or is there an additional process available (i.e. in VLIDE)?

tombu - I like that macro, thanks.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Combine multiple lisp routines?
« Reply #4 on: July 31, 2018, 09:59:50 AM »
While it's easier to load a single file, if things start getting complicated it can be a bit of a bother trying to track down something in a 10k+ line file.  If you have more than a few files, create a loader routine (in it's own file 'cause you know - organization  :-P ) to handle the rest.

And whatever you do, don't lose track of the source code.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Combine multiple lisp routines?
« Reply #5 on: July 31, 2018, 12:53:36 PM »
It depends on how large they are, it used to be that I would put all LISP routines into a few files, but the problem is that when loaded this can become a drain on memory. So I divided them out and used an autoload routine so they only load when someone uses the command.

Now mind you I made this change many years ago when computers were much more limited on RAM than they are now, but I find it still is a good practice and keep the same technique going. It also makes editing LISP routines much easier down the road.

DanB

  • Bull Frog
  • Posts: 367
Re: Combine multiple lisp routines?
« Reply #6 on: July 31, 2018, 01:09:27 PM »
Thanks for all the feedback. Think I am going to keep as individual files and incorporate the demand loading.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Combine multiple lisp routines?
« Reply #7 on: July 31, 2018, 01:24:10 PM »
Another approach:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:LOADALL (/ LispPath LispList n)
  2.         (setq LispPath "I:/Acad2019/Programs/")
  3.         (setq LispList (vl-directory-files LispPath "*.fas" 1))
  4.         (foreach n LispList
  5.                 (load (strcat LispPath n))
  6.         )
  7.         (princ "\nALL .FAS-FILES LOADED.\n")
  8. )
Vault Professional 2023     +     AEC Collection

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Combine multiple lisp routines?
« Reply #8 on: July 31, 2018, 01:35:13 PM »
That's kinda what I do. I have a whole folder with subfolders of each commands. Then I can void out the older lisp and still keep it with the original if I ever need to go back. Works well. I also call the routine on demand. its not preloaded.
Civil3D 2020

DanB

  • Bull Frog
  • Posts: 367
Re: Combine multiple lisp routines?
« Reply #9 on: July 31, 2018, 02:58:55 PM »
Keeps getting better, thanks for that one too Crank.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Combine multiple lisp routines?
« Reply #10 on: July 31, 2018, 04:29:11 PM »
(i.e. in VLIDE)?
good idea

run vlide
create a project
add all your lisps to it
check toggle 'Single module for all'
build project fas