OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: MiD-AwE on December 10, 2013, 10:16:17 AM

Title: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 10, 2013, 10:16:17 AM
 ???
Hi all,
I'm trying to add a ribbon button that will allow the user to toggle the appearance of a palette. The first time it's clicked the palette should be shown. Each time it is clicked after the first, it should toggle ( show / hide ) the palette. I would prefer that the palette be set to an Anchored Auto-hide state if possible, instead of closed, but I'll take what I can get.

Below is the code that I tried and it gives me an automation error. Undoubtedly, the error is because the  "DCL_FORM_ISVISIBLE" function returns an error if the form is not visible. <- that's as far as I get. What next?

Code (autolisp) Select
(DEFUN c:CNTRL ()
  (DCL_PROJECT_LOAD "CNTRL-PNL" T)
  (IF (DCL_FORM_ISVISIBLE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_CLOSE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_SHOW CNTRL-PNL_CPL-CAD)
  )
  (PRINC)
)


Thank you in advance for any help.
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: owenwengerd on December 10, 2013, 11:15:02 AM
It would be helpful if you could provide more precise information, such as the exact error message. Your code has some issues, but it should never produce an automation error. I suspect it is not an automation error at all, but let's clarify that before proceeding.
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 10, 2013, 12:33:23 PM
I must've had something else going wrong at the time.

I just tried it again and it says:

Application Error: 2 :- ADS request error

Does that sound right?
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 10, 2013, 12:38:32 PM
missed the OpenDCL Runtime Error. Now attached.
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: owenwengerd on December 10, 2013, 02:06:06 PM
I suspect that the 'No object instance' error is due to reloading your project every time. Try this:

Code (autolisp) Select

(DEFUN c:CNTRL ()
  (DCL_PROJECT_LOAD "CNTRL-PNL") ;do *not* reload every time
  (IF (DCL_FORM_ISACTIVE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_CLOSE CNTRL-PNL_CPL-CAD)
    (DCL_FORM_SHOW CNTRL-PNL_CPL-CAD)
  )
  (PRINC)
)

Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 11, 2013, 06:40:04 AM
Thank you Owen,

Unfortunately, I got the exact same error.  :-\
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: owenwengerd on December 11, 2013, 07:04:46 AM
Hmm, strange. Can you reproduce the problem with the _masterdemo sample form? Which CAD/OS versions are you testing on?
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 11, 2013, 09:01:35 AM
I'll give it a try. I'm on Win7 & AC2013.

BRB
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 11, 2013, 09:34:15 AM
 :( I recieved two error messeges with the _MasterDemo_Main.

I also noticed that with the MasterDemo code it is not using DCL_FORM_ISVISIBLE, but instead utilizes DCL_FORM_ISACTIVE.

Any thoughts?
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: MiD-AwE on December 11, 2013, 09:42:30 AM
 8) Ok, I decided to change DCL_FORM_ISVISIBLE to DCL_FORM_ISACTIVE, and is works great.
Owen, I can't thank you enough.
Title: Re: How to toggle dcl_form_show / dcl_form_close?
Post by: owenwengerd on December 11, 2013, 09:52:00 AM
The code I posted earlier for you to try did use (dcl_Form_IsActive), but I forgot to mention that.