How to appload without dialogue box

How to appload without dialogue box

Anonymous
Not applicable
3,770 Views
24 Replies
Message 1 of 25

How to appload without dialogue box

Anonymous
Not applicable

Hello, everyone

 

I'd like to execute an appload command without the dialogue box.

I don't know how to do that, so I wrote PowerShell codes below:

# PowerShell codes
[System.Windows.Forms.SendKeys]::SendWait("_appload ") [System.Windows.Forms.SendKeys]::SendWait("%n") # Alt+N [System.Windows.Forms.SendKeys]::SendWait("xyz.lsp") [System.Windows.Forms.SendKeys]::SendWait("%(lc)") # Alt+L & Alt+C

and run it.

 

 

But I don't like SendWait because it runs asynchronously, that is, it doesn't wait until the command finishes. Instead, I'd like to do that like next:

# PowerShell codes
$acad = New-Object -ComObject AutoCAD.Application $doc = $acad.Documents.ActiveDocument $doc.SendCommand("(command `"_appload`" `"xyz.lsp`")") # This doesn't work

The last line causes the dialogue box, but `xyz.lsp' isn't entered to the text box in it.

 

 

Does anyone have a good idea?  I don't care if you use another command except appload.

 

I use AutoCAD 2011 on Windows 7.

I'd like to draw tens of cross sectional views, and each view has hundreds of LWPolylines. I have as many AutoLISP files as sections to draw. Each file (like xyz.lsp) is for a section drawing.

 

Thank you.

0 Likes
Accepted solutions (1)
3,771 Views
24 Replies
Replies (24)
Message 21 of 25

Kent1Cooper
Consultant
Consultant

@hmunsell wrote:

... the Load command seems to only work with SHX.... any update on this? is there a work around for loading LSP from the command prompt for 2023?


The AutoCAD LOAD command is not for AutoLisp routines, as confusing as it may be that AutoLisp uses the function name (load) for that.  The AutoCAD APPLOAD command has no command-line version, only the dialog box, so try:

(load "YourAutoLispRoutine.lsp")

Kent Cooper, AIA
0 Likes
Message 22 of 25

hmunsell
Mentor
Mentor

@Kent1Cooper wrote:

(load "YourAutoLispRoutine.lsp")


so, LOAD and (LOAD) do 2 different things?

 

We tried (load "lisp routine.lsp") and it didn't work :-(. 

Howard Munsell
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.



EESignature


0 Likes
Message 23 of 25

Kent1Cooper
Consultant
Consultant

@hmunsell wrote:
....so, LOAD and (LOAD) do 2 different things?

We tried (load "lisp routine.lsp") and it didn't work :-(. 


HELP is your friend -- always start there:

 

Kent1Cooper_0-1697123536676.pngKent1Cooper_1-1697123588115.png

What does "it didn't work" mean?  Were there any messages?  Did it fail to load entirely?  Did it load but not recognize the command or function defined in it?  Did it accept a command name, but not do what you expected?  Did it do nothing, or something different from what you expected?  What was different?  Etc., etc.

 

My suggestion at Message 21 is the same as the accepted solution at Message 3 -- nothing is changed about any of this since then.

Kent Cooper, AIA
Message 24 of 25

hmunsell
Mentor
Mentor

actually, just heard back from my Standards person who was trying to use it, and he got it to work using the (LOAD "xxx") command. not sure why it wasn't working the first time we tried it. 

 

I thought it was weird it didn't work, I had used that command for years.  i thought maybe Autodesk had changed the command LOL... 

Howard Munsell
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.



EESignature


0 Likes
Message 25 of 25

Sea-Haven
Mentor
Mentor

If you do (load "xxx") it may fail, the most obvious reason is that the lisp program is not located in a preset Support path, Options File Support & Trusted paths for Acad. When loading a lisp just using name the Cad will search through the support paths looking for it, note the 1st found copy is used even if lisp is multi saved.

 

(load "c:\\cadprograms\\mylisps\\xxx") is using full path for file name.

 

Another way is using a lisp in the Startup Suite that contains the "AUTOLOAD" function, this demand loads your lisp when you type a matching command.

 

 

 

 

(autoload "COPY0" '("0COPY"))
(autoload "COPYCOMMAND" '("ZZZ"))
(autoload "COVER" '("COVER"))
(autoload "DIMFLIP" '("DIMFLIP"))

 

 

 

0 Likes