Author Topic: Cui - LISP Load Question  (Read 712 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Cui - LISP Load Question
« on: May 20, 2019, 07:10:26 AM »
I have this routine loaded within a CUI under LISP Files.
If a routine is accidently not there, the file will not load any of the routines below.
How can I get keep loading even when a file is not there?

Code: [Select]
(defun C:cui_Loader()
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\85x11_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\85x11_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\11X17_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\11X17_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\22X34_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\22X34_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\24X36_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\24X36_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\30X42_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\30X42_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\36X48_L.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\36X48_P.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-10.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-20.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-30.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-40.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-50.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-60.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-80.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-100.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-200.lsp")
(load "\\\\Server1\\Autodesk\\CUI\\Ribbon\\1-500.lsp")
(princ))
(C:cui_Loader)

Thanks for any help :)
Autodesk Infrastructure Design Suite 2019

gile

  • Water Moccasin
  • Posts: 2231
  • Marseille, France
Re: Cui - LISP Load Question
« Reply #1 on: May 20, 2019, 07:54:11 AM »
You can create a .MNL fil with the same name as your CUIX file (e.g. Foo.cuix, Foo.mnl) in which you just paste the (load ...) expressions.
The MNL file will be loaded and executes when the CUIX file is loaded.
Speaking English as a French Frog

Master_Shake

  • Swamp Rat
  • Posts: 1447
Re: Cui - LISP Load Question
« Reply #2 on: May 20, 2019, 08:08:00 AM »
Instead of loading via lisp, use the built-in loader within the CUIx utility

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #3 on: May 20, 2019, 08:11:02 AM »
So basically load each lisp in the loader and not an overall loading file. I can try that.
Autodesk Infrastructure Design Suite 2019

tombu

  • Newt
  • Posts: 154
  • ByLayer=>Not0
Re: Cui - LISP Load Question
« Reply #4 on: May 20, 2019, 09:47:06 AM »
Many threads on many forums dedicated to options for loading lisp. First thing would be to keep all your lisp in folders in the Support File Search Path to avoid ever having to include paths like that.
Having a large number of lisp loading every time you open a drawing you may not need seems unnecessary.
You seem to have 10 lisp listed for setting scale.  Why not use one lisp with an argument like
Code: [Select]
(defun scale1to (x / temp)where
Code: [Select]
(scale1to 50)would replace the macro for 1-50.
Consider using the lisp function autoload or just have it autoload in the macro like:
Code: [Select]
(or (scale1to)(load "scale1to.lsp")) (scale1to 50) which would load the lisp if it wasn't already loaded and then set the scale to 1:50. This is how 90% of mine are loaded. 
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #5 on: May 20, 2019, 10:00:31 AM »
What are your thoughts on demand load opposed to loaded all these files in every time a drawing opens? I would think it would be harder to manage. Just a question.
Autodesk Infrastructure Design Suite 2019

tombu

  • Newt
  • Posts: 154
  • ByLayer=>Not0
Re: Cui - LISP Load Question
« Reply #6 on: May 20, 2019, 12:45:16 PM »
What are your thoughts on demand load opposed to loaded all these files in every time a drawing opens? I would think it would be harder to manage. Just a question.
While I have a small group of daily used lisp functions loaded with acaddoc.lsp every time a drawing opens and a few in acad.lsp to make profile modifications as necessary most of my routines are demand loaded either in the CUI command macro or with a autoload function call in acaddoc.lsp.

I have a large number of custom CUI commands that require lisp to be loaded.  If there's ever a conflict when using one of these commands from another lisp that may be using the same global variable or function name I'd be able to find and correct the conflict right away.  I use a lot of downloaded lisp and these things happen.  My PC's performance isn't as good as I'd prefer so loading all the lisp I could ever possibly use would degrade that performance more than I could put up with.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

dgorsman

  • Water Moccasin
  • Posts: 2394
Re: Cui - LISP Load Question
« Reply #7 on: May 20, 2019, 01:09:49 PM »
Look into the help for the (load ...) function.  It has an optional argument, when used a failed load doesn't (exit) it returns that optional argument.  By checking the return value you can provide some feedback on exactly *what* failed to load.
If you are going to fly by the seat of your pants, expect friction burns.

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

tombu

  • Newt
  • Posts: 154
  • ByLayer=>Not0
Re: Cui - LISP Load Question
« Reply #8 on: May 20, 2019, 03:25:56 PM »
I have this routine loaded within a CUI under LISP Files.
If a routine is accidently not there, the file will not load any of the routines below.
How can I get keep loading even when a file is not there?
Thanks for any help :)
This will test and load all those files that are found:
Code: [Select]
(defun cui_Loader (lspfile / fpath)
  (setq fpath (strcat "\\\\Server1\\Autodesk\\CUI\\Ribbon\\" lspfile))
  (or (findfile fpath)(load fpath))
  (princ)
)
(cui_Loader "85x11_L.lsp")
(cui_Loader "85x11_P.lsp")
(cui_Loader "11X17_L.lsp")
(cui_Loader "11X17_P.lsp")
(cui_Loader "22X34_L.lsp")
(cui_Loader "22X34_P.lsp")
(cui_Loader "24X36_L.lsp")
(cui_Loader "24X36_P.lsp")
(cui_Loader "30X42_L.lsp")
(cui_Loader "30X42_P.lsp")
(cui_Loader "36X48_L.lsp")
(cui_Loader "36X48_P.lsp")
(cui_Loader "1-10.lsp")
(cui_Loader "1-20.lsp")
(cui_Loader "1-30.lsp")
(cui_Loader "1-40.lsp")
(cui_Loader "1-50.lsp")
(cui_Loader "1-60.lsp")
(cui_Loader "1-80.lsp")
(cui_Loader "1-100.lsp")
(cui_Loader "1-200.lsp")
(cui_Loader "1-500.lsp")
(princ)
It's also an example of one lisp that can be used with many arguments like one that could handle all your scales.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #9 on: May 20, 2019, 03:36:01 PM »
Thank you for sharing this. Its simple and makes sense. Saves a lot of headaches lol.
Autodesk Infrastructure Design Suite 2019

BIGAL

  • Bull Frog
  • Posts: 310
  • 30 + years of using Autocad
Re: Cui - LISP Load Question
« Reply #10 on: May 21, 2019, 01:05:48 AM »
For me it looks like a plot routine so why not use a dcl with a list pick the plot routine then load the lisp required.

Version 2 is like 1 pick the plot size pass that to one lisp that uses a list look up for plot size then read the correct variables to be used only 1 lisp for all sizes.

Post a couple if happy so can have a look at what is going on.

I had two floors of drafters with printers / plotters on 3 floors all was automatic based on user's ID sent to printer closest and relevant colour/mono.
A man who never made a mistake never made anything

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #11 on: May 21, 2019, 06:59:42 AM »
Just to give you guys more information. The routines are tied to a custom ribbon. There are 85 routines that are individually loaded when the CUI is loaded. (I just used the plot scales and page setups as an example to get me to the right direction. lol. However, there are some really interesting ideas on this thread. ;)
Autodesk Infrastructure Design Suite 2019

Master_Shake

  • Swamp Rat
  • Posts: 1447
Re: Cui - LISP Load Question
« Reply #12 on: May 21, 2019, 08:19:22 AM »
Instead of 85 different plotting routines, why not merge them into a more efficient, single-source lisp routine?

tombu

  • Newt
  • Posts: 154
  • ByLayer=>Not0
Re: Cui - LISP Load Question
« Reply #13 on: May 21, 2019, 10:22:55 AM »
Instead of 85 different plotting routines, why not merge them into a more efficient, single-source lisp routine?
Exactly!

I use Lee Mac's Steal from Drawing for importing Layouts, Plot Styles, and everything else. I use one other lisp for deleting Plot Styles first that I wish to update from a template.  Everything I've seen shouldn't take more than a couple routines and they've probably all been written already.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

ronjonp

  • Needs a day job
  • Posts: 7027
Re: Cui - LISP Load Question
« Reply #14 on: May 21, 2019, 10:29:00 AM »
I use a template with predefined pagesetups along with sheet set manager and or CAB's plottabs routine. IMO, 85 routines for plotting is a bit crazy!  :-P


Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #15 on: May 21, 2019, 10:32:08 AM »
lol.... I think I need make sure you guys do not think I am crazy. I agree 85 'routines' for plotted is nuts. The ribbon I have created is not just for plotting but other tools as well. I just need those to load in. I have a lot of commands on the ribbon. lol.

But again, like you guys are suggesting, I would definitely use Lees Steal routine, it is awesome.
Autodesk Infrastructure Design Suite 2019

MP

  • Seagull
  • Posts: 17439
Re: Cui - LISP Load Question
« Reply #16 on: May 21, 2019, 10:52:47 AM »
Casual observation suggests 2 functions that take 85+ arguments between them would be more efficient.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

dgorsman

  • Water Moccasin
  • Posts: 2394
Re: Cui - LISP Load Question
« Reply #17 on: May 21, 2019, 11:01:35 AM »
Casual observation suggests 2 functions that take 85+ arguments between them would be more efficient.

"Change the data, not the code."
If you are going to fly by the seat of your pants, expect friction burns.

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

MSTG007

  • Water Moccasin
  • Posts: 2397
  • I can't remeber what I already asked! I need help!
Re: Cui - LISP Load Question
« Reply #18 on: May 21, 2019, 11:03:43 AM »
Just curious. Is it bad practice to combined multiple routines into one file, rather than a file for each routine?
Autodesk Infrastructure Design Suite 2019

MP

  • Seagull
  • Posts: 17439
Re: Cui - LISP Load Question
« Reply #19 on: May 21, 2019, 11:25:48 AM »
IME what's "bad practice" is duplicated / copied logic -- it's unnecessarily maintenance and trouble shooting heavy. Regarding one file or multiple files -- per my previous post -- it would appear 2 functions taking multiple arguments would suffice. If said functions are ambitious (doesn't appear so) or significantly different (i.e. prone to independent update / maintenance) 2 files might be the better option.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17439
Re: Cui - LISP Load Question
« Reply #20 on: May 21, 2019, 11:49:01 AM »
"Change the data, not the code."

this
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox