OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: hanslammerts on November 09, 2016, 02:39:39 PM

Title: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 09, 2016, 02:39:39 PM
Hi
I was wondering it would be possible to programm a menu in Autocad that act similar to the entity snap toolbar in Bricscad. Because autocad doesn't support dynamic toolbars <state> this could only be done with a menu that 'stays open'.. Can this be done with opendcl?
Thanks upfront hans

https://www.bricsys.com/bricscad/help/en_US/V13/UsrGui/source/01_User_Interface/Art/01_Toolbar10_Entitysnaps.png
Title: Re: Possibilities for menu, dynamic buttons
Post by: Peter2 on November 10, 2016, 01:59:44 AM
For OpenDCL - yes, it is a standard feature to create "something" (palette, modeless dialogue) which stays open and displays different icons for different states.

For AutoCAD - a "simple workaround" could be that you take the "zoom" toolbar, modify it to "my zoom" and change every icon to a flyout which different icons - one icon enables the zoom option, the other one disables it. The visual result is the same, the usage needs the click to open the flyout.

I think that there are menucommands in Cuix which does the command you need and can change the displayed icon. But I'm not sure ... :-\
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 11, 2016, 12:10:11 AM
Thanks for your reply peter,
Modifing any existing AutoCAD toolbar isn't going to do what i would like the toolbar to (not a fan of flyout buttons) but i thought opendcl could do just that. Thanks for your reply anyway!

I have made a simple form to illustrate the idea. *EDIT* I figured out it should be a modeless dialog..
These buttons i thing have a "event when clicked", change appaerance and should trigger command that i called.
The lisps have the code to to this.

(set_os_end)
(set_os_mid)
(set_os_cen)

- how to activate the lisp in the opendcl dialog.
- how to load a .odcl. file ?

Thanks for some helping out..


Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 12, 2016, 12:47:37 PM
Edit:
Version 20180417:
Two checks have been added to the code.
Version 20170129:
The position of the form is now stored relative to the top left corner of the CAD window.
Version 20170125:
If the stored position of the form would cause it to be (partially) outside the CAD window, the form is centered.
Version 20170118:
Several improvements for the 20170117 code.
New function c:Osnaps-Toggle: Toggles the osnaps and changes the display of the form to match.
Version 20170117:
For every workspace the position and state (hide/show) of the form is saved/restored separately.
New function c:Osnaps-FormToggle: Toggles the form.
Version 20161126:
Added OZ (OSNAPZ) button.
The form now has KeepFocus set to false.
Version 20161116B:
Event handlers for INT and APP were not correct.
Version 20161116:
Updated code to hide GCE button.
Revised event handlers. Behavior now matched that of the BricsCAD toolbar.
Modified the ODCL: flat buttons 30x30.
Version 20161114:
Added X button (switch OSMODE to zero).
(dcl-Sendstring) is no longer used.

My suggestion:
Title: Re: Possibilities for menu, dynamic buttons
Post by: Peter2 on November 12, 2016, 01:40:40 PM
 8)
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 13, 2016, 02:05:03 PM
Thanks for this amazing good work!!  Highly effective and will same a lot of clicking.
I'm allmost there where i would want it to be.

The big wish i still have is to have a 'clear osnap' button to work.
I called it 'btnCln' in the same fashion as the other buttons are called.
btnCln would be the one that would make them all red, a hard osnap=0 value.

Here is my code ..for revision & idea's..

Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 14, 2016, 12:23:05 AM
Quote from: hanslammerts on November 13, 2016, 02:05:03 PM
Thanks for this amazing good work!!  Highly effective and will same a lot of clicking.
Thanks.

Quote from: hanslammerts on November 13, 2016, 02:05:03 PM
The big wish i still have is to have a 'clear osnap' button to work.
Have you tried the existing 'ON' button? This will not set the OSMODE to zero but does disable all osnaps.
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 14, 2016, 01:00:50 AM
@hanslammerts:
I notice that you have changed the existing button event handlers.
Does this mean that:
Code (autolisp) Select
(dcl-Sendstring "'_endpoint ")
does not work on AutoCAD?
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 14, 2016, 03:25:33 AM
I have update the code anyway. See reply #3.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 15, 2016, 02:34:43 PM
Mucias gratias.

.. A few remarks after testing and doing my things.

1. shouldn't hide the gce button (>AutoCAD 2017 has gce), i turned it this off ;   (dcl-Control-SetVisible Osnaps/Main/btnGce nil)
2. i cannot figure out how to set osmode = 0 seems some kind of bug that this will automaticly turn it on/off instead of resetten it all (to red buttons)
3. strange thing that the toolbar is shortening everytime i active it..(?) Why is this..? so i have set the 'enable resize button' : on
   (the button aligenment need some fixing, i can do that :) But what about the strange behaviour of the shortening at start up ??

.. still, this is amazing stuff.. :) Thanks!
Fun to do some testing / programming on a multi-platform basis..

https://youtu.be/mvAVqWTVKAI
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 16, 2016, 02:07:03 AM
1.
Actually AutoCAD >=2016 has the GCE snap. I'll revise my code accordingly.
2.
If you press the 'X' button all buttons to the left of it should turn red and the 'X' button itself should turn green.
The 'ON/OFF' button has three states:
- ON+white: Osnap is on and one or more osnaps are active.
- OFF+black: Osnap is off and OSMODE is zero.
- OFF+gray: Osnap is off but OSMODE is not zero.
3.
I do not see misaligned buttons. You have to be more specific.
The resizing bug you see is caused by your own modifications of the code.
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 16, 2016, 06:07:55 AM
See reply #3 for the updated version.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 16, 2016, 12:21:35 PM
Awsome!!!!! Will get back to you after testing and working with it. The way you code this makes me feel a bit like a fool.. But i am very happy this will save a bunch of useless shift clicking through stupid autocad menus.
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 16, 2016, 01:49:16 PM
See reply #3 for the updated version. ;D
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 17, 2016, 12:41:38 PM
General question..
i keephaving the issue that the toolbar is shrinking every time i close and re-open it?
Tried to prevent it by setting min width and working with a frame around the buttons. No effect :(
Is this only in AutoCAD happening?
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 18, 2016, 09:58:59 AM
@Hans:
Although the code does contain a portion to hide the GCE button and reduce the width of the dialog, your last post surprises me for two reasons:
1.
The code should only hide the GCE button if it is visible and therefore should execute only once per CAD-session.
2.
The code should not run on AC 2016 and 2017.

To find the cause of the problem change line 48-61 to:
Code (autolisp) Select
  (if
    (and
      (print Osnaps/Main)
      (print Osnaps/Main/btnGce)
      Osnaps/Main/btnGce ; To be absolutely safe.
      (print (dcl-Control-GetVisible Osnaps/Main/btnGce))
      (if (= "BRICSCAD" (strcase (getvar 'product)))
        (> 16 (atoi (getvar '_vernum)))
        (> 2016 (atoi (substr (print (ver)) 13))) ; https://www.theswamp.org/index.php?topic=36606.msg416136#msg416136
      )
    )
    (progn
      (dcl-Control-SetVisible Osnaps/Main/btnGce nil)
      (dcl-Control-SetWidth Osnaps/Main (- (dcl-Control-GetWidth Osnaps/Main) 32)) ; 32 is the button distance.
    )
  )

And report what you see in the Command Bar when the dialog is first displayed and then closed and reopened.
Title: Re: Possibilities for menu, dynamic buttons
Post by: Peter2 on November 20, 2016, 03:11:49 AM
Can you provide a screencast to show what is happening?
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 20, 2016, 12:54:12 PM
Turns out i did something to the that did it.  :-\
I have one thing that would be benificial, a Z/Z button for OSNAPZ like ON/OFF for osnap.

;;  (setq osmz (getvar 'osnapz))  ;; etc... etc..
inspiration: https://apps.autodesk.com/ACD/en/Detail/Index?id=9014648650809523218&appLang=en&os=Win32_64
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 21, 2016, 07:58:59 AM
@Hans:
For me the main goal of this little project was managing a modeless form across drawings, including drawings where the Lisp code is not loaded (two of the three reactors are there for this purpose). It was never my intention to create the 'perfect' Osnap toolbar. You are right: OSNAPZ plays a role, but so do OSOPTIONS and 3DOSMODE. Feel free to add buttons for any or all of these variables. I won't. ;D
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on November 22, 2016, 02:25:23 PM
Ok. respect that, really like to thank you for your time & effort. I like it allready as it is,  but there is allways something to wish for ;-)
While i'm using it i noticed i keep using the F3 key a Z osnap would therfore be more welcome, ..to me..
Title: Re: Possibilities for menu, dynamic buttons
Post by: scott_cd on November 25, 2016, 05:33:50 AM
Thanks for sharing this - What a fabulous function.

I have taken the liberty of adding a couple of buttons and changing the colours of the buttons.

I have added the following buttons: m2p .xy and OsnapZ

I am afraid that I wasn't able to update the reactors as it is beyond my skill level.

Thanks again

Scott CD

Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on November 26, 2016, 04:33:57 AM
Since, apparently, the code is hard to understand for the average Lisper, I have changed my mind and have added an OZ (OSNAPZ) button. By using three separate update functions I hope that others will find the code easier to modify and extend.
See reply #3 (http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212) for the updated version.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on December 01, 2016, 02:03:02 PM
Fantastic you made osnapz running so good Roy_043!!
What i did to it, is turning line 258 into this .. little tweak that i find usefull as graphical feedback by showing grid indicating Z is locked.
Will work great in 3D i know! Looks like the Revit 'show plane' & 'pick plane' option. However, with AutoCAD you still have a lot more freedom in 3D imo..

(defun c:Osnaps/Main/btnOsnapz#OnClicked () (progn ((setvar 'osnapz (boole 6 (getvar 'osnapz) 1)) (setvar 'gridmode (boole 6 (getvar 'gridmode) 1)) (princ))))
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on December 02, 2016, 02:00:48 AM
Showing the grid if OSNAPZ is On can be useful. But your code simply toggles the GRIDMODE independently from the OSNAPZ. So if the user has OSNAPZ=0 and GRIDMODE=1, clicking the OZ button will result in OSNAPZ=1 and GRIDMODE=0.
A better solution would be:
Code (autolisp) Select
(defun c:Osnaps/Main/btnOsnapz#OnClicked () (setvar 'gridmode (setvar 'osnapz (boole 6 (getvar 'osnapz) 1))) (princ))
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on December 02, 2016, 05:22:03 AM
Even better! Hold that thought for updating the code ( #3 ) :)
I set GRIDDISPLAY = 15 (adoptive and beyond limits) by default

(dcl-Form-Show Osnaps/Main 750 0)
To start at top bottom
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on January 17, 2017, 10:18:39 AM
See reply #3 (http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212) for the 20170117 version.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on January 17, 2017, 01:12:02 PM
Allright..!  like it Roy !)



Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on January 18, 2017, 04:23:33 AM
See reply #3 (http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212) for the 20170118 version.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on January 18, 2017, 03:02:58 PM
I decided to use it as F3. But you can set it F4 as well as this is by default the 3D objectsnap function..
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on January 24, 2017, 11:32:40 PM
Hi Roy
It needs a .._reset function for its location.
I noticed that it can stay on the disconected monitor..
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on January 25, 2017, 08:02:42 AM
Quote from: hanslammerts on January 24, 2017, 11:32:40 PM
Hi Roy
It needs a .._reset function for its location.
I noticed that it can stay on the disconected monitor..
New version in the usual place (http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212).
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on January 27, 2017, 01:40:38 AM
   ok!  :D
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on January 29, 2017, 11:23:41 AM
... Minor tweak ;) see here (http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212).
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on March 18, 2017, 03:36:58 PM
Hi there

I'm wondering what keeps routines like beneith in combination with this OpenDCL toolbar from acting transparent.
Check this screenshot. I think it has somthing to do with the OpenDCL code how it works. Would be great if it can be overcome..

Thanks anyway
Hans

https://youtu.be/zAb26bR-emU



Code (autolisp) Select


(defun ent-xline (pt vec lyr /)
  (entmake (list '(0 . "XLINE")
'(100 . "AcDbEntity")
(cons 8 lyr)
'(100 . "AcDbXline")
(cons 10 (trans pt 1 0))
(cons 11 vec))))
   
(defun C:xv (/ pt)
  (while (setq pt (getpoint "\nSpecify Vertical XLINE position: "))
    (ent-xline pt (getvar "ucsydir") "X_hulplijn_")))


(defun C:xh (/ pt)
  (while (setq pt (getpoint "\nSpecify Horizontal XLINE position: "))
    (ent-xline pt (getvar "ucsxdir") "X_hulplijn_")))
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on March 19, 2017, 03:52:42 AM
Quote from: hanslammerts on March 18, 2017, 03:36:58 PM
I think it has something to do with the OpenDCL code how it works.
The problem is caused by a limitation of the AutoCAD getpoint Lisp function:
Quote from: http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-69fb.htmThe user cannot enter another AutoLISP expression in response to a getpoint request.

In BricsCAD this limitation does not exist and the toolbar can be used transparently in your C:xv and C:xh functions without any issues.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on March 19, 2017, 05:41:08 AM
Would there be any other way to retieve positions other then getpoint, to make that work?
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on March 19, 2017, 12:38:22 PM
Maybe:
Code (autolisp) Select
(command "_.id" "\\")
(setq pt (getvar 'lastpoint))
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on April 14, 2018, 02:45:07 AM
Dear Roy, if these some kind of 'opendcl installed check' function suitable for this one. That would be great.
Title: Re: Possibilities for menu, dynamic buttons
Post by: roy_043 on April 17, 2018, 03:28:37 AM
I have added two simple checks to the code. See here (http://opendcl.com/forum/index.php?topic=2446.msg12212#msg12212) for the new version.
(setvar 'cmdecho 0)
(vl-cmdf "_Opendcl")
(setvar 'cmdecho 1)

; 20180417
; ODCL check.
(if (not dcl-Project-Load)
  (progn
    (princ "\nError: OpenDCL runtime not available ")
    (exit)
  )
)

; 20180417
; Dialog check.
(if (not (findfile "Osnaps.odcl"))
  (progn
    (princ "\nError: \"Osnaps.odcl\" file not found ")
    (exit)
  )
)
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on April 19, 2018, 03:38:52 AM
Splendid work!
Title: Re: Possibilities for menu, dynamic buttons
Post by: kruuger78 on December 11, 2018, 10:24:09 AM
Quote from: roy_043 on November 12, 2016, 12:47:37 PM
Edit:
Version 20180417:
Two checks have been added to the code.
WOW!!! Fantastic stuff ?? Thanks Mr. Roy :)
Title: Re: Possibilities for menu, dynamic buttons
Post by: kruuger78 on December 16, 2018, 10:49:20 PM
more eye friendly colors variant :)
also colors are saved to registery so can be different for each users.
kruuger
Title: Re: Possibilities for menu, dynamic buttons
Post by: Jim Short on January 13, 2019, 07:30:42 AM
Another Idea.
Title: Re: Possibilities for menu, dynamic buttons
Post by: hanslammerts on May 27, 2019, 01:27:26 PM
Very nice Kruuger78!
I'm gonna use your more ellegant colors too