Reload on changing drawing with modeless dialog

Started by Lube, September 05, 2018, 07:52:41 AM

Previous topic - Next topic

Lube

Hi there, I've a simple question :)

How do I accomplish that task?
"This event is triggered when the user switches to a different open AutoCAD drawing. Note that opening a new drawing will not trigger any event. An application that uses modeless dialogs must be installed so that its code is loaded into each newly created drawing document, and the application's initialization code must check for already active dialogs that it must manage."

I've a modeless dialog with that inside the code
(defun c:cordoli/cordoli#OnInitialize (/)
....
)


When I switch to another drawing it will be very cool if i dind't have to reload the *.fas

I've tried with that but of course it doens't work and I don't get how to check the already active dialogs :S
(defun c:cordoli/cordoli#OnDocActivated (/)
(c:cordoli/cordoli#OnInitialize)
)


Thank for your help !

Dennis

AbuSimbel

Hello Lube.
You have to write the following code in the file ACAD.lsp, so that it is loaded in each drawing.

(defun c:cordoli/cordoli#Onanclajeactivado (/)  (load "cordoli") (c:cordoli) (princ))

(and (zerop (getvar "sdi"))
     (member "CORDOLI" (mapcar 'strcase (dcl_getprojects)))
     (dcl_form_isactive cordoli/cordoli)
     (c:cordoli/cordoli#Onanclajeactivado)
)

Lube

Thank you mate!

Can I trigger the "OnInitialize" lisp part? Every drawing has a dictionary with items that need to be reloaded.

Thanks for your help :)

Lube

#3
Quote from: AbuSimbel on September 05, 2018, 11:34:16 PM
Hello Lube.
You have to write the following code in the file ACAD.lsp, so that it is loaded in each drawing.

(defun c:cordoli/cordoli#Onanclajeactivado (/)  (load "cordoli") (c:cordoli) (princ))

(and (zerop (getvar "sdi"))
     (member "CORDOLI" (mapcar 'strcase (dcl_getprojects)))
     (dcl_form_isactive cordoli/cordoli)
     (c:cordoli/cordoli#Onanclajeactivado)
)
Anyway I get this error
; error: no function definition: DCL_GETPROJECTS

I don't know how to fix that.. :S

Peter2

a) Both ways should be working, but (dcl-getprojects) is the current typing; (dcl_getprojects) is the older one.
b) ; error: no function definition: DCL_GETPROJECTS shows that you have not loaded opendcl. Check your installation if it is installed correctly, and call "opendcl" to load the software before you use functions from it
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10