LISP to run a script on startup?

LISP to run a script on startup?

Colby_MickelberryAEN2P
Contributor Contributor
1,748 Views
26 Replies
Message 1 of 27

LISP to run a script on startup?

Colby_MickelberryAEN2P
Contributor
Contributor

I have a script that I want to run on start up, it basically changes the width factor of our standard text since we did a company wide style change. The script i wrote works but I would like the LISP to run the script when someone opens a cad file. From all the forms i read it looks possible but Im struggling the right code in the lsp file (since the start up suit doesnt work with scripts). I know i have to appload the lsp and add it to the start up suite.

 

If anyone could help provide some direction I would really appreciate it! 

0 Likes
1,749 Views
26 Replies
Replies (26)
Message 2 of 27

pendean
Community Legend
Community Legend

May I ask, why are you only wishing to use a script, and not convert it to a startup LISP?

And what is the content of the SCRIPT?

0 Likes
Message 3 of 27

JGranata_GdB
Enthusiast
Enthusiast

in the ACAD.LSP or ACADDOC.LSP you can add in the following:

(load "LISPNAME")
or 
(load "C:/FOLDER/FOLDER/LISPNAME.LSP")

0 Likes
Message 4 of 27

paullimapa
Mentor
Mentor

Since you already have the lisp file that would load automatically at startup then just add the following command at the end of that lisp file to launch the script ie assuming script is named "C:\\Autodesk\\My Script.scr":

(command "_.Script" "C:\\Autodesk\\My Script.scr")

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

No reason I was just following along with what someone else did. would it be easier to convert this to an lisp?

 

0 Likes
Message 6 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

I can seem to find th acad.lsp. Im looking the cd 3d 2025 support folder under users, is it somewhere else in the file structure?

0 Likes
Message 7 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

Colby_MickelberryAEN2P_0-1743107688287.png

this is what i currently have in lsp but when i load it in the start up suit and restart cad and open file doesnt seem to loading

 

0 Likes
Message 8 of 27

paullimapa
Mentor
Mentor

Your script file path has a “\” when it should be “/“


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

I made those changes. Still when I open a new drawing its not seeming to work. 

Colby_MickelberryAEN2P_1-1743117329355.png

 

I added it to the start up suite

0 Likes
Message 10 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

I added / made an acaddocs.lsp created (load "R:/CADD/Lacey Ribbons/LISP Files/Change_Width.src"), also added it to the start up suite. Still doesnt seem to be working, am I missing something?

0 Likes
Message 11 of 27

paullimapa
Mentor
Mentor

Script file typically has a file extension of .scr and not .src...so you have a typo there now...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 12 of 27

paullimapa
Mentor
Mentor

You cannot load a script file to run it like this. Only lisp files can be loaded. Script file requires it to be called using command like this:

(command "_.SCRIPT" "R:/CADD/Lacey Ribbons/LISP Files/Change_Width.SCR")

and again Script files typically has a file extension of ".scr" and not ".src"


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 13 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

Great thank your for your help. Sorry I am new to this just trying to learn. So if I take that code you provided and added it an lsp so that way it references the script, how do i get it to auto load every time i open a drawing. I am adding the lsp to the start up suit

0 Likes
Message 14 of 27

paullimapa
Mentor
Mentor

once you add the lisp to the startup suite, the lisp should run each time you open a dwg and since at the end of the lisp code you included the command to run the script file then that would run automatically from now on...have you tried to see what happens?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 15 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

Ya I just reloaded it in and tried it and still wont run when I open a cad file

Script code:

-STYLE

Arial

Arial

0

0.95

0

No

No ;

Which works when i load it in directly

 

LSP:

Colby_MickelberryAEN2P_0-1743119675836.png

lsp loaded into start up suite.

 

I appreciate your help on this!

 

0 Likes
Message 16 of 27

paullimapa
Mentor
Mentor

What's the name of the lisp file that you added the command code to?

Is that lisp file also saved under a folder added under command: Options>Files tab>Trusted Locations?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 17 of 27

Sea-Haven
Mentor
Mentor

Try replacing the "/" with two "\\" you have spaces in the file names and it may be stopping at Lacey so not found.

 

We had a Autoload.lsp that had all sorts of stuff in it. Like your run this on startup. Multiple defuns and set stuff, this was loaded via Appload Start up Suite. So as script is short make it lisp code. The advantage of having a custom start up lisp was did not have to find acad.lsp etc we could keep it with all our other custom stuff, do a CAD upgrade and no need to find acad.lsp again.

0 Likes
Message 18 of 27

Kent1Cooper
Consultant
Consultant

@Colby_MickelberryAEN2P wrote:

..../Change_Width.src"....


Should that be:

..../Change_Width.scr"

?

Kent Cooper, AIA
0 Likes
Message 19 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

I added the folder to the trusted locations. The name is Change Width_Factor.lsp. 

 

Still doesnt seem to be working, I think I am missing something lol. 

 

I have other lsp file that specifiy similar file paths with spaces and works just fine so I dont think that is the issue.

0 Likes
Message 20 of 27

Colby_MickelberryAEN2P
Contributor
Contributor

Is it an issue with the first part of the code, (command Script)" I see some people put load or add a start up command before some of the code? But I dont know if that makes sense since we are adding it to the start up suite

0 Likes