View Full Version : error: no function definition: AUTOLOAD
Ldill
2014-07-23, 07:40 PM
Is anyone less getting this error? error: no function definition: AUTOLOAD
It only happens when you start AutoCAD 20 /13/14/15. After that you never see it again.
It only happen in my first call to "Autoload" in my custom lisp. I have determined that the Acad20XXdoc.lsp is not being load first. (which is where the AutoLoad function is). The fun thing is it looks like the menu files are being loaded twice. and the second time it works. see:
Customization file loaded successfully. Customization Group: UTILITY2013
Regenerating model.
ACAD.mnl Loaded
... My Menu loading ...
... Program ; error: no function definition: AUTOLOAD
AutoCAD menu utilities
*Acad2014doc loaded*
ACAD.mnl Loaded
... My Menu loading ...
... Program 1
... My Menu loaded ...
Command:
Is there a way to control the order in which menus load?
Coloradomrg
2014-07-23, 08:56 PM
To start with... are you adding custom code to the acad20XXdoc.lsp? In general that's a no-no. Your autoload should be in your acaddoc.lsp.
I don't push custom menu's with lisp, but my first guess is that your CUI is loading the menu and then your lisp is loading it also.
RobertB
2014-07-24, 12:43 PM
I don't think Ldill is editing Acad20xxDoc.lsp to add the autoload function... that function comes from Autodesk and is part of Acad20xxDoc.lsp.
Ldill, Looking at the error, it looks to me like you are using the autoload function in your MNL, but because the MNL is loading before Acad20xxDoc.lsp, the function has not been defined yet.
There are several approaches you can take.
Move most of your code from the MNL to AcadDoc.lsp. This is a user-created file that loads after Acad20xxDoc.lsp. I load in the MNL only functions that are directly used by the CUI elements, and not my C: functions or toolbox functions.
Copy the autoload function into your MNL (I discourage this, functions should never be defined in more than one location).
Create your own autoload function and stop using Autodesk's. I took this approach too, because Autodesk's autoload has some significant shortcomings.
BlackBox
2014-07-24, 02:17 PM
A couple more options, to accomplish same:
Modify your CUI item's macro to provide the 'if not defined load the .LSP and then call the command' (I haven't used this in years personally):
^C^C^P(if (not c:FOO) (load "foo.lsp"));FOO;^P
... Or, you could just use an Autoloader .bundle to load your components; making sure to specify a given Command XmlNode and the applicable LoadOnCommandInvocation="True" XmlAttribute and value respectively.
[Edit] - PackageContents.xml snippet:
<!--snip-->
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*" SeriesMax="R20.0" SeriesMin="R18.2" SupportPath="./Contents/Support" />
<ComponentEntry AppDescription="FOO for AutoCADĀ® does BAR" AppName="FOO" LoadOnCommandInvocation="True" ModuleName="./Contents/Support/foo.lsp" PerDocument="False" >
<Commands GroupName="FOO">
<Command Local="FOO" Global="FOO" />
</Commands>
</ComponentEntry>
</Components>
<!--snip-->
Cheers
Tom Beauford
2014-07-24, 03:07 PM
A couple more options, to accomplish same:
Modify your CUI item's macro to provide the 'if not defined load the .LSP and then call the command' (I haven't used this in years personally):
^C^C^P(if (not c:FOO) (load "foo.lsp"));FOO;^P
Cheers
That's pretty much how I've always done it.
^C^C^P(or c:FOO (load "foo.lsp"));FOO;^P
80% of these are used no more than once a week, no point in having them loaded all the time. I have a few functions in acaddoc.bat that are used all the time. I've seen a few autoloaders provided by AutoCAD, two in Express Tools. The code above doesn't require any of them to work.
RobertB
2014-07-25, 02:44 PM
80% of these are used no more than once a week, no point in having them loaded all the time. I have a few functions in acaddoc.bat that are used all the time. I've seen a few autoloaders provided by AutoCAD, two in Express Tools. The code above doesn't require any of them to work.
Getting off track a bit, but...
I wrote my own autoloader, not to support C: functions, but to support my toolbox functions (years before Autodesk got around to the new packaging). I have functions that are related to each other stored in common library LSP files and needed a reliable way to autoload those functions. Autodesk's autoloader does not handle that, nor did I want to add explicit loads in every top-level application.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.