Jump to content

Autoload and CUI problem


Shoey

Recommended Posts

Hi all

 

I have a partial CUI menu that has a supplementary MNL file. The MNL file contains a series of 'AUTOLOAD' functions e.g.

(autoload "AddObjectsToBlockV1-1" '("ADD2BLOCK" "REMOVE"))

 

Upon starting AutoCAD 2013 and earlier, the Autoload works fine.

 

But there is a small problem when using this with AutoCAD 2014 which bugs me.

 

An error appears on the command line after the CUI is loaded. This error is-

; error: no function definition: AUTOLOAD

 

I have searched for a solution for this but not really come across an answer that would keep on using the MNL file.

What i have found is to use the ACADDOC.lsp / ACAD.lsp files.

I have also come across that there may be an issue with the ACAD2014doc.lsp as this contains the Autoload function?

 

The above does not affect the loading of the functions and they all work when activating the commands from the Ribbon in the CUI.

 

To add to the above i also have approx 80 AUTOLOAD functions in my MNL.

Can anybody tel me if this has an impact on AutoCAD performance. Is it recommended? I dont seem to notice any issues, but a colleague of mine says there is a performance issue with his AutoCAD 2014 and using the CUI/MNL.

 

Also, if i copy and paste all the Autoload functions in my MNL file into the Command Line, i dont get the above error.

 

Any help is appreciated.

 

Regards

Shoey

Link to comment
Share on other sites

Hi Shoey,

 

Attached is my version of the AutoLISP autoload function (the native version of this function is defined on line 178 of the acad20##doc.lsp).

 

My version uses exactly the same syntax as the in-built function (so you will not need to alter your existing autoload expressions), but has several advantages over the in-built autoload function:

 

  • My version handles both forward slash and double-backslash filepath delimiters.
    (the in-built function can only use forward slash delimiters).

 

  • My version does not result in an infinite recursive loop (returning a hard error when the stack limit is reached) if the command listed in the command list argument is not defined in the given application file.

Since the acaddoc.lsp is loaded before any MNL files, and after the acad20##doc.lsp is loaded, I would suggest either loading the attached function from your acaddoc.lsp, or copying the code directly into your acaddoc.lsp.

 

I hope this helps; comments/suggestions are welcome.

autoload.lsp

Link to comment
Share on other sites

Hi Lee

 

Thanks for your reply, suggestions and code.

 

I am at a loss on how to apply my existing autoload code to your code.

Do I place this code (autoload "AddObjectsToBlockV1-1" '("ADD2BLOCK" "REMOVE"))

into yours??

 

Do I do away with the MNL?:?

 

As always, your help is appreciated.

 

Shoey

Link to comment
Share on other sites

Hi Shoey,

 

My code is intended as a replacement definition for the standard autoload function, hence there is no need to alter your existing code contained in your MNL file in any way. :)

 

Since all MNL files load after the acaddoc.lsp has loaded, you can retain your existing MNL file and keep all the autoload expressions that it contains unaltered.

 

Simply perform the following operations:

 

  • Save the above attached file (autoload.lsp) to an AutoCAD Support Path.

 

  • At the AutoCAD command-line, type:
    (findfile "acaddoc.lsp")

    If the above returns a valid filepath, navigate to this filepath and in the operations that follow, modify the existing acaddoc.lsp file.

 

  • If the above expression returns nil, open notepad and save the file as acaddoc.lsp to an AutoCAD Support Path
    (Ensure 'Save As Type' is set to 'All Files' as you would with any other LISP file).

 

  • In the new/existing acaddoc.lsp, type the following:
    (load "autoload.lsp" "Unable to load autoload.lsp")

    And save the file.

 

  • Restart AutoCAD.

Link to comment
Share on other sites

Hi Lee

 

I have followed your instructions but the error message still appears.

I have renamed the ACAD2014DOC.lsp so it does not load and so that it uses your replacement AUTOLOAD.lsp

 

As mentioned, its not a problem as the programs in the MNL do load and function.

Its just the error message that's annoying!

 

Cheers pal.

 

Shoey

Link to comment
Share on other sites

Hi Lee

 

I have followed your instructions but the error message still appears.

I have renamed the ACAD2014DOC.lsp so it does not load and so that it uses your replacement AUTOLOAD.lsp

 

As mentioned, its not a problem as the programs in the MNL do load and function.

Its just the error message that's annoying!

 

I see - from your reports, it would seem that either the standard autoload function is not defined (or erroneously defined) in the acad2014doc.lsp, or that subsequent code loading on startup (after the MNL files) is overwriting or nullifying the autoload definition.

 

I would not recommend renaming the acad2014doc.lsp, as this file will contain definitions for other functions required by AutoCAD.

 

However, you have several options:

 

If it is true that the autoload function is not being defined in the acad2014doc.lsp file, you could load my autoload.lsp file from within the acad.lsp (create this file if it doesn't already exist), since this loads before the acad20##doc.lsp in the startup load order. However, you would also need to ensure that the ACADLSPASDOC system variable is set to 1 to ensure that the acad.lsp file is loaded for each drawing.

 

Alternatively, you could add the following to the acad2014doc.lsp, after the definition of the standard autoload function

(on line 313 I believe):

(load "autoload.lsp" "Unable to load autoload.lsp")

This will ensure that an autoload function is available.

 

However, for others reading this thread, I would state that it is not recommended that you modify the acad20##.lsp or acad20##doc.lsp, since any modification can be overwritten following an update from Autodesk.

Link to comment
Share on other sites

I was aware of the importance of not touching or renaming any defined acad*.lsp functions. I renamed the acad21014doc.lsp just to test your code and I promptly renamed it back when tested!

 

I apologise to you Lee for having to take your time to flag up the importance of not renaming any built-in acad*.lsp start-up files to other users reading this thread.

I should have thought and re-read my reply more carefully and will do for future posts.

 

I will try out your other alternative.

 

Ta

Shoey

Link to comment
Share on other sites

  • 1 month later...

Hello all

 

 

Been away hence late reply.

Eventually managed to work around this problem thanks to a work colleague.

We appended the autoload functions into the S::STARTUP function.

 

Code typically as follows..

 

 

(defun-q s::startup ()

(autoload "COMMAND" '("CMD1" "CMD2"))

(princ)

)

 

 

Error message - ; error: no function definition: AUTOLOAD now gone!

 

 

Ta

Shoey

 

 

Ps - Sorry for not putting code above in code tags as per forum protocol. I cant seem to get them to work when posting.

Link to comment
Share on other sites

  • 2 years later...

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