LISP routine in startup suite doesn't seem to work

LISP routine in startup suite doesn't seem to work

phHNEPB
Contributor Contributor
507 Views
9 Replies
Message 1 of 10

LISP routine in startup suite doesn't seem to work

phHNEPB
Contributor
Contributor

Hi all,

 

I'm very new to autoCAD and especially to LISP. I'm creating some drawings where I use a lot of different lineweights and I find it annoying that I have to set 'LWDISPLAY' on everytime I open a new drawing. That's why I wanted to create a LISP routine that automatically sets the 'LWDISPLAY' on. 

I used chatGPT to create it and this is what I got:

 

(defun c:SetLwDisplayOn ()
(setq old-lw (getvar "LWDISPLAY")) ; Get the current value of LWDISPLAY
(setvar "LWDISPLAY" 1) ; Set LWDISPLAY to ON
(princ "\nLWDISPLAY is now ON.") ; Print confirmation message
(princ) ; End quietly
)

 

Then I added this file to the startup suite with 'APPLOAD' but it doesn't seem to work. 'LWDISPLAY' is always off when I open a new drawing.

 

So I tried another option where I call this routine with the acaddoc.lsp file. This is what I wrote in this file:

 

(load "C:\\Users\\MyName\\Documents\\AutoCAD\\2025\\startup_lwdisplay.lsp")
(SetLwDisplayOn) ; Run the function to set LWDISPLAY to ON

 

acaddoc.lsp is located in: C:\Program Files\Autodesk\AutoCAD 2025\Support

 

Then I added the acaddoc.lsp file to the startup suite but it still doesn't work.

 

Is there something I'm missing or is there another way to accomplish this?

 

Thank you in advance!

0 Likes
Accepted solutions (1)
508 Views
9 Replies
Replies (9)
Message 2 of 10

annoisscary
Advocate
Advocate

Personally i would just put the function inside of acaddoc.lsp instead of have it load it from the outside. On another note, you could check if your acaddoc.lsp is loading by putting a princ statement in it so that if it is loaded it puts a message to the console. If its not loading its probably an issue with your support paths or something.

0 Likes
Message 3 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

So you want to always set 'lwdisplay on right after you open any drawing automatically, without any user interactions right?

 

It that's true, add just this line to your acaddoc.lsp and make that the path is between "trusted locations" or lower SECURELOAD sysvar.

(if (= 0 (getvar 'lwdisplay)) (progn (setvar 'lwdisplay 1) (princ "\nLWDISPLAY turned on.")))

0 Likes
Message 4 of 10

phHNEPB
Contributor
Contributor

Yes I tried the princ statement but it never showed me the statement. I did get a warningbox with the message "The publisher of this executable file could not be verified and the file is not located in a trusted folder. What do you want to do?" I clicked on the option 'Always load' so I assume that the path is correct. But maybe it's still a problem that the file is located in a 'not trusted' folder?

0 Likes
Message 5 of 10

phHNEPB
Contributor
Contributor

Yes, that's what I would like to happen.

 

My acaddoc.lsp now looks like this correct?

 

(load "C:\\Users\\MyName\\Documents\\AutoCAD\\2025\\startup_lwdisplay.lsp")
(SetLwDisplayOn) ; Run the function to set LWDISPLAY to ON
(if (= 0 (getvar 'lwdisplay)) (progn (setvar 'lwdisplay 0) (princ "\nLWDISPLAY turned on.")))

 

Unfortunately it still doesn't work. 

 

I made an exclusion in my windows defender to make my folder a trusted folder.

0 Likes
Message 6 of 10

cadffm
Consultant
Consultant

Hi,

 

for usual I will not support chatgpt code, but in this case, your welcome 🙂

 

>>"annoying that I have to set 'LWDISPLAY' on everytime I open a new drawing"

A new drawing?

Command: LWDISPLAY<enter>[F1]

Read about lwdisplay, this setting is save per file, also per template file.

Solution: Edit your template file! Or if that one is one of the original standard .dwt files, create your own template!

 

If you don't know which template you are using, create a new one:

Command: NEW

Command: LWDISPLAY 1

Command: SAVEAS

select extension *.dwt

fill your description

Acad jumped to another folder where templates are stored

save the new template with senseful name.

For example, if you used acad.dwt, save the new one as ACAD_LWDon.dwt

This way you can easier remember about the .dwt and the changes.

 

Now, close the file, run command NEW and select this new template

SAVEAS

well done.

 

>". That's why I wanted to create a LISP routine that automatically sets the 'LWDISPLAY' on. "

No need, (setvar 'LWDISPLAY 1) is enough

 

 

>"Then I added this file to the startup suite with 'APPLOAD' but it doesn't seem to work. 'LWDISPLAY' is always off when I open a new drawing."

Because you added a .lsp file, what define a new command "SetLWdisplayOn", NOTHING ELSE!

What is missing? To start the command..

;----would work----

(defun c:SetLwDisplayOn ()
(setq old-lw (getvar "LWDISPLAY")) ; Get the current value of LWDISPLAY
(setvar "LWDISPLAY" 1) ; Set LWDISPLAY to ON
(princ "\nLWDISPLAY is now ON.") ; Print confirmation message
(princ) ; End quietly
)

(c:SetLwDisplayOn)

;---

 

>>"So I tried another option where I call this routine with the acaddoc.lsp file. This is what I wrote in this file:

>(load "C:\\Users\\MyName\\Documents\\AutoCAD\\2025\\startup_lwdisplay.lsp")
>(SetLwDisplayOn) ; Run the function to set LWDISPLAY to ON

The new created Lispfunction name is C:setlwdisplayon,

so you have to write

(c:SetLwDisplayOn)

 

 

If you edited your (new=) template, it works for new files.

If you want to turn LWD on in all files you will open, use

the acaddoc.lsp way

and add (setvar 'LWDISPLAY 1)

 

Get rid of all chatGPT output

 

HTH

 

 

 

Sebastian

0 Likes
Message 7 of 10

ВeekeeCZ
Consultant
Consultant

@phHNEPB wrote:

....

My acaddoc.lsp now looks like this correct?

...


 

No, forgot about your lisp, use just my line (updated one with fixed typo).

Message 8 of 10

phHNEPB
Contributor
Contributor

Thank you for your answer. This looks like a solution that's handy if you always design yourself and that you can use your own template. 

For my job I need to work a lot with designs from other companies so I don't think creating my own template is the best solution here. I just want lwdisplay (and also other commands in the future) to be set to my preferred working style so I don't have to do this manually when opening a lot of designs from other people.

0 Likes
Message 9 of 10

cadffm
Consultant
Consultant

Clear up your acaddoc.lsp and add 

my (setvar line.

Sebastian

0 Likes
Message 10 of 10

phHNEPB
Contributor
Contributor

I adjusted to setvar 0 to setvar 1 and it works perfectly. Thank you very much!

0 Likes