LISP for Experts

LISP for Experts

Anonymous
Not applicable
1,204 Views
8 Replies
Message 1 of 9

LISP for Experts

Anonymous
Not applicable
1- Is there a way to prevent you from closing the DWG through LISP?
2- Can I execute a command when I click close (X) the DWG?
3- Is there any variable that is not excluded when closing the DWG? To save information from the current project and retrieve it when reopening the project? I know you can do it by creating a file (exporting data in a file) but does AUTOCAD not have a database of variables that store user information for later reading?
Thanks for the personal help! Any information is very welcome!
(I'm Brazilian and translated by GoogleTranslate, sorry if the grammar was strange)
 
ORIGINAL:
 
Olá amigos, estou criando uma lisp para um projeto que algumas pessoas irão trabalhar em conjunto. Gostaria de saber algumas coisas pra melhorar minha lisp.
1- Tem como impedir que feche o DWG através de LISP?
2- Tem como executar comando quando clicar em fechar (X) o DWG?
3- Existe alguma variavel que não se exclui ao fechar o DWG? Para salvar informações do projeto atual e buscá-las ao reabrir o projeto? Sei que dá pra fazer criando arquivo (exportando dados em arquivo) mas o AUTOCAD não possui um banco de variáveis que guardam informação de usuário para leitura posterior?
Obrigado pela ajuda pessoal! Qualquer informação é muito bem vinda!

0 Likes
1,205 Views
8 Replies
Replies (8)
Message 2 of 9

pendean
Community Legend
Community Legend
Do you just need to force a QSAVE so you/your users do not lose their changes?

0 Likes
Message 3 of 9

Shneuph
Collaborator
Collaborator
Accepted solution

#s 1 and 2 would involve the use of reactors.  In limited time I can only point you towards some learning materials here:

https://www.afralisp.net/visual-lisp/tutorials/reactors-part-1.php

https://help.autodesk.com/view/ACD/2018/ENU/?guid=GUID-82B7F0D1-02AD-4463-A8A3-BF87EFCC83A4

 

1- Is there a way to prevent you from closing the DWG through LISP?

2- Can I execute a command when I click close (X) the DWG?


3- Is there any variable that is not excluded when closing the DWG? To save information from the current project and retrieve it when reopening the project? I know you can do it by creating a file (exporting data in a file) but does AUTOCAD not have a database of variables that store user information for later reading?

 

#3, you can use global variables using the setenv function.  Variables are saved to the registry and thus remain available after closing autocad and re-opening.  Setenv and Getenv functions.

 

envreg.PNG

gettestvariable.PNG

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 4 of 9

Anonymous
Not applicable

Thank you for the precious information!

0 Likes
Message 5 of 9

Anonymous
Not applicable

One question: Doesn't using variables in the registry change the performance of the operating system?

0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor
Accepted solution

Yes, you can by creating a reactor using Visual Lisp.  Of course every user will have to have the Lisp loaded.

As to storing special data in a dwg, you can do that too using dictionaries.  And with vlax-ldata-put and vlax-ldata-get you can even store lists and lists of lists such as entity data dxf codes, your wedding anniversary date, and the definition of "peavey" which is my favorite fictionary word.

Now if you want to store entity data, don't use the ename (dxf -1), because the names change from session to session.  You must use the entity handle instead (dxf 5).

John F. Uhden

Message 7 of 9

Anonymous
Not applicable
Accepted solution

Thank you! I will study more VLX to better understand and apply it to my lisp. About DXF5 I didn't know that there was a permanent name for each object. It will help my development a lot.

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:
3- Is there any variable that is not excluded when closing the DWG? To save information from the current project and retrieve it when reopening the project? I know you can do it by creating a file (exporting data in a file) but does AUTOCAD not have a database of variables that store user information for later reading?....

For that, in the case of numerical  variable information, you can store that in each drawing in a way that is retained -- Real numbers in the USERR1 through USERR5 System Variables, and Integers in the USERI1 through USERI5 System Variables.  [There are also USERS1 through USERS5 System Variables for text Strings, but for some reason those are not  retained when the drawing is closed.]

Kent Cooper, AIA
0 Likes
Message 9 of 9

Anonymous
Not applicable
Accepted solution

Quizás te pueda interesar un texto sobre el tema en español. Este ebook incluye un capítulo dedicado a reactores.

https://www.amazon.com.br/dp/B07NJ9MPY5

El libro completo son cuatro volúmenes en formato Kindle. También lo hay como un solo volumen en papel:

https://www.amazon.com/dp/1728774748

 

0 Likes