OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Emiliano on May 04, 2012, 05:48:32 AM

Title: Check if a form is loaded and visible
Post by: Emiliano on May 04, 2012, 05:48:32 AM
Hello,
how can I check whether a certain form is loaded and visible?

I tried

(dcl_Form_IsVisible NomeApp_FormP)

but does not work if the project is not loaded
Do you have any suggestions?
Title: Re: Check if a form is loaded and visible
Post by: roy_043 on May 04, 2012, 07:38:14 AM
Perhaps this:
Code (autolisp) Select
(and
  (dcl_Form_IsActive NomeApp_NomeForm)
  (dcl_Form_IsVisible NomeApp_NomeForm)
)


From the explanation in the Help you would expect that just (dcl_Form_IsVisible NomeApp_NomeForm) would be enough. But somehow that is not the case.
Title: Re: Check if a form is loaded and visible
Post by: owenwengerd on May 04, 2012, 08:08:34 AM
The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
Code (autolisp) Select
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))
Title: Re: Check if a form is loaded and visible
Post by: Emiliano on May 04, 2012, 09:41:14 AM
Hello,
thanks for the answer.
Unfortunately now I can not verify.
But I think your solution does not work when the project Nome.odcl is not loaded in the file.
Title: Re: Check if a form is loaded and visible
Post by: roy_043 on May 05, 2012, 01:47:37 AM
Quote from: owenwengerd on May 04, 2012, 08:08:34 AM
The (dcl_form_IsVisible) function is enough, but you can't pass a NIL argument. This should work though:
Code (autolisp) Select
(and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm))

Somehow that does not work.

Test:

Files:
NomeApp.lsp
NomeApp.odcl
From: http://www.opendcl.com/forum/index.php?topic=1790.msg8820#msg8820 (http://www.opendcl.com/forum/index.php?topic=1790.msg8820#msg8820)

1. Load and start the lisp.
2. Close the form.
3. !NomeApp_NomeForm => <Entity name: #>
4. (and NomeApp_NomeForm (dcl_Form_IsVisible NomeApp_NomeForm)) => No object instance error.

Bricscad 12.2.4 Beta + ODCL 7.0.0.4
Bricscad 11.4.6 + ODCL 7.0.0.4
Title: Re: Check if a form is loaded and visible
Post by: owenwengerd on May 05, 2012, 11:57:36 AM
You are correct, I forgot that the form symbol has a value as long as the project is loaded.
Title: Re: Check if a form is loaded and visible
Post by: Fred Tomke on May 07, 2012, 12:01:34 AM
Hi, I want to add that dcl_form_isactive will go on returning T if a none-modal form is being hidden by calling dcl_form_hide. That's why dcl_form_isvisible exists.
You should avoid calling dcl_form_show if dcl_form_isactive is returning T because no form could be shown twice (even one of them is invisible).
For modeless forms you should check it this way:

Code (autolisp) Select

(cond
  ((not myproj_mymodeless)
   (dcl_project_load "myproj")
   (dcl_form_show myproj_mymodeless))
  ((not (dcl_form_isactive myproj_mymodeless))
   (dcl_form_show myproj_mymodeless))
  ((not (dcl_form_isvisible myproj_mymodeless))
   (dcl_form_hide myproj_mymodeless nil))
);cond


Regards,
Fred
Title: Re: Check if a form is loaded and visible
Post by: Emiliano on May 09, 2012, 09:36:20 PM
Thanks to all for their valuable advice.
I solved the problem by modifying the application's workflow.
But these suggestions will certainly help in the future.

thanks