Palette issues

Started by honkinberry, May 21, 2015, 03:45:26 PM

Previous topic - Next topic

honkinberry

I'm struggling quite a bit with my first Palette.

First issue, after turning on Auto-Hide once, now that it is the way the dialog always comes up.  If I uncheck Auto-hide and close the form, firing it up again, it's auto-hidden.  Primarily I just need this set for me, couldn't find it in the registry.  But eventually I'll need to know how to make sure it will always come up Docked, instead of Auto-hidden.

Secondly, having issues with my action button to place blocks.  It needs to set a layer active, uses a (command) call to insert a block, and other activities like that.  The only way I can get it to work from the Palette is by a delayedInvoke call.  Without that, I get errors even setting CLAYER.

Lastly, and possibly related, having some difficulty with the difference between Asynchronous and Synchronous event invoke.  Does this only apply to the standard events, DocActivated, Close, Initialize, etc?  If so, then that would explain it, and I'm fine.  But as I was trying to determine why my button can't create a layer and set it current, I was toggling that setting to see no difference.

Any tips will be most appreciated!

--J

owenwengerd

Setting your EventInvoke to Asynchronous is the correct approach to allowing use of (command) in your event handler. Events which return a result cannot be executed asynchronously, but otherwise the setting applies to all OpenDCL events.

Palette settings get saved in your profile (Profile.aws file) when you close AutoCAD. Dock your palette, close AutoCAD, then the docked state should be saved.

I hope that helps.
Owen Wengerd (Outside The Box) / ManuSoft

honkinberry

Ah beautiful, having the palette docked as I wished when I closed AutoCAD was the trick, thank you.

Now to the other issue.
I have a button on my palette, Click event calling a function.  That function starts out setting a system variable (setvar "LWDISPLAY" 1).  Yet regardless if my event invoke is Synchronous or Asynchronous, I get an "AutoCAD variable setting rejected".  The only way around this I have found is to have the Click event fire a delayedInvoke with 1 millisecond, calling the same function -- then the sysvar is set, the block is inserted, and everything works the same as from a dialog.
Is this going to be the best way for me to transition similar dialog-based code to being palette-based, or am I just missing something simple?

Thanks again.

--J

owenwengerd

Some things to check:
1) After you change the Event Invoke property to Asynchronous, make sure you save the file and note exactly where you save it.
2) Make sure you load (or reload) the correct modified project file that you just saved.
3) Make sure there I nothing else going on, and no other command active, when you press the button that triggers the problematic code.
4) Try putting the problem code directly into the event handler preceded by some diagnostic code to verify that the correct event handler and code is being called.

To be really certain about the Event Invoke property of your palette form, you can check (or change) it at runtime to make sure it is set correctly.
Owen Wengerd (Outside The Box) / ManuSoft

honkinberry

Test file attached.
Many thanks if you have time to look at it.

--J

owenwengerd

Sorry, I misled you by referring to the form's Event Invoke property. The button's Event Invoke property must be set to Asynchronous. When I changed that, it worked for me.
Owen Wengerd (Outside The Box) / ManuSoft

honkinberry

Of course!  I should have seen that.
Thank you.

Which leads me to a wishlist request -- this is a classic situation, I will be keeping some of my buttons with Synchronous so that they can process return values, and do not need to access the command line.  So I would *love* a Property in the Studio, of "Comments" for every object.  Definitely helps for so many situations, reminding myself why Use Bottom From Bottom is set a certain why, what other caption values need to be accounted for, archiving various size or placement values used, you name it.

But as always, you rock, thank you!

--J

owenwengerd

You're welcome. Just to clarify, you don't need to set your buttons to Synchronous so that return values are processed properly; any events that need return values (like CancelClose) simply ignore the Event Invoke property and automatically get sent synchronously.
Owen Wengerd (Outside The Box) / ManuSoft