DocActivated question

Started by Matt W, October 18, 2007, 06:23:26 AM

Previous topic - Next topic

Matt W

I've got a dockable form with a treeview control.  When I close all open drawings the treeview is cleared (using the EnteringNoDocState event).  When I open or start a new drawing, the treeview remains empty....but I don't want it to.  I want it to repopulate itself.  I've got code in place for the DocActivated event, but nothing seems to happen when a new drawing is started or an existing drawing is opened.

Also, should I be loading the LSP within my ACAD.lsp so it's available with each drawing?  I'm confused on what the "best practices" would be for something like this.

Thanks (and yes, I've cross-posted at the Swamp).

jb

I have a custom menu which handles loading all my lisp / fas apps through the associated mnl file.  I would think you would want to use the acaddoc.lsp file - which loads with every drawing (like a .mnl file).  I have the following code at the bottom of the form control code which handles floating forms:

;;; ;
;;; Floating Form ;
;;; Document Opened ;
;;; ;

(defun jb:Layerstates_IsFloating  (/ )
  (jbLoadARX)
  (defun EnsureProjectLoaded  (project / project-path)
    (if (not (setq project-path (dcl_Project_Load project)))
      (progn
(alert (strcat "ODCL project \"" project "\" failed to load!"))
(exit)
)))
  (EnsureProjectLoaded "jb501")

  (if dcl_HideErrorMsgBox
    (progn
  (if (dcl_Form_IsActive jb501_00)
    (c:jb501_00_OnDocActivated)))
    (alert "The OpenDCL arx module did not load!"))
  (princ))

(jb:Layerstates_IsFloating)


The code ensures the ARX is loaded, the project is loaded, and if the form is active runs the onInitialize sub routine.
James Buzbee
Managing Memeber
Black Horse Development, LLC

owenwengerd

Quote from: Matt W on October 18, 2007, 06:23:26 AM
Also, should I be loading the LSP within my ACAD.lsp so it's available with each drawing?  I'm confused on what the "best practices" would be for something like this.

You should load and initialize your form in AcadDoc.lsp (not Acad.lsp).  The lisp will run every time a new drawing is opened.  In your lisp, check whether the form is already active -- if it is, just repopulate the controls.  If you don't want the form displayed automatically at startup, you have to set a global flag on the blackboard to signal your startup code whether or not the form is to be displayed. :)
Owen Wengerd (Outside The Box) / ManuSoft