Author Topic: Simulate click on toolbar  (Read 3005 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 329
Simulate click on toolbar
« on: November 16, 2015, 03:44:23 PM »
Is there a way to simulate clicking a toolbar button using lisp?

I'm running Bricscad and I have a parent toolbar that has a flyout for different scale factors on one of the parent's buttons.  I have the parent set up to show the last-clicked icon from the flyout, but I can't find a way to "pre-load" the button icon when I load a new drawing so it shows the appropriate scale based on the data in the drawing.  I can manually change the icon on the parent using vla-setbitmaps but that resets the "own icon" setting for the parent button so it is locked to whatever icon is assigned through vla-setbitmaps and the parent button no longer changes based on clicks on the fly-out.  I'm thinking that if there is a way to set the "active" button on the fly-out the associated button on the parent toolbar should follow.

Thanks.
"Science is the belief in the ignorance of experts." - Richard Feynman

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #1 on: November 17, 2015, 04:21:10 AM »
I don't think a toolbar click can be simulated using Lisp. But it should be possible to use (vla-setbitmaps) to change the parent icon every time one of the flyout buttons is activated.

hmspe

  • Bull Frog
  • Posts: 329
Re: Simulate click on toolbar
« Reply #2 on: November 17, 2015, 08:06:41 AM »
Roy,

Thanks.  That's what I've been doing, but it is not particularly pleasant.  There are 17 buttons on the toolbar, with the flyout being the last.  It takes almost 2 seconds for the toolbar to update most of the time since the whole parent toolbar has to be updated and repainted.  Sometimes it takes much longer, although I haven't been able to figure out why.  It might be because the bitmaps are on the server, similar to the issue with MTEXT with reading fonts from a network drive.  I wouldn't mind having the delay once on startup if I could find a way to reset "own bitmap" on the parent toolbar to no, but I don't see a way to do that, either. 
"Science is the belief in the ignorance of experts." - Richard Feynman

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #3 on: November 17, 2015, 09:00:51 AM »
Maybe the image type is important. With local 16x16 .bmp files the speed is acceptable I think. Certainly less than half a second.

I am attaching a .zip file that I have used to report a bug to the Bricsys team.

Place all files in the same folder and open a dwg in that folder.
The (c:Test) function will change the first bitmap in the 'Draw' toolbar.

hmspe

  • Bull Frog
  • Posts: 329
Re: Simulate click on toolbar
« Reply #4 on: November 17, 2015, 09:56:03 AM »
Roy,

Thanks for the reply and the testing.  You are seeing what I see.  It is not a "show stopper", but it is irritating to have to wait for the toolbar to redraw, especially since sometimes the delay is closer to 10 seconds.  I haven't been able to track down why the time varies.  There are only 3 Cad stations here and the LAN is gigabit.

Using local bitmaps does appear to be faster than using bitmaps on the server, but changing to local files for bitmaps, blocks, fonts, etc., is not practical because of the work that would be required to keep all the local copies synchronized on all the computers. 

I have filed a report asking if setting "own icon" to 'on' when vla-setbipmaps is run is intended or not and asking if there is a way to reset "own icon".  I'll post here when I hear from Bricsys.
"Science is the belief in the ignorance of experts." - Richard Feynman

GDF

  • Water Moccasin
  • Posts: 1953
Re: Simulate click on toolbar
« Reply #5 on: November 17, 2015, 12:36:59 PM »
This is what I do for both dialog boxes and toolbars:


Code: [Select]
(defun ARCH:Anno$  ()
  (ARCH:ChangeBitmap "ARCH" "Arch Program©" "ANNO" "ARCH_ANNOx")
  (start_image "arch_anno")
  (mapcar 'vector_image ; Color 1
          (list 14 14 14 14 14 13 9 9 9 9 8 8 8 8 8 9 9 9 9 10 6 6 6 7 7 7 8 8 8 12 12 16 16
                16 16 16 16 17 17 17 17 18 13 13 13 14 14 10 11 10)
          (list 18 17 17 16 16 14 14 14 16 17 17 17 17 18 18 18 18 19 19 19 19 19 19 18 18 18
                16 16 16 4 4 16 16 17 17 18 18 18 18 19 19 19 19 19 19 19 18 13 8 13)
          (list 14 14 14 14 14 14 13 9 9 9 9 8 8 8 9 9 9 9 10 10 10 6 7 7 7 8 8 8 12 12 16 16
                16 16 16 16 17 17 17 17 18 18 18 13 14 14 14 13 13 11)
          (list 18 18 17 17 16 16 14 16 17 17 17 17 18 18 18 18 19 19 19 19 19 19 19 19 18 17
                17 16 4 4 16 16 17 17 18 18 18 18 19 19 19 19 19 19 19 19 19 13 13 8)
          (list 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                1 1 1 1 1 1 1 1 1 1 1)) ;mapcar
  (mapcar 'vector_image ; Color 250
          (list 0 1 1 0 0 0 0 1 1)
          (list 0 1 1 0 0 0 0 1 1)
          (list 1 1 22 24 0 23 0 1 23)
          (list 1 22 1 0 24 0 23 23 1)
          (list 250 250 250 250 250 250 250 250 250)) ;mapcar
  (mapcar 'vector_image ; Color 7
          (list 23 0 1 22 22 0 22 1 0 23 24)
          (list 0 23 22 1 22 24 1 23 24 1 0)
          (list 23 23 22 22 24 1 24 23 24 23 24)
          (list 23 23 22 22 24 22 0 23 24 23 24)
          (list 7 7 7 7 7 7 7 7 7 7 7)) ;mapcar
  (end_image)) ;defun
(defun ARCH:Annox$  ()
  (ARCH:ChangeBitmap "ARCH" "Arch Program©" "ANNO" "ARCH_ANNO")
  (start_image "arch_anno")
  (mapcar 'vector_image ; Color 250
          (list 14 14 14 14 14 13 9 9 9 9 8 8 8 8 8 9 9 9 9 10 6 6 6 7 7 7 8 8 8 12 12 16 16
                16 16 16 16 17 17 17 17 18 13 13 13 14 14 10 11 10 23 0 1 22 22 1 0 23 24)
          (list 18 17 17 16 16 14 14 14 16 17 17 17 17 18 18 18 18 19 19 19 19 19 19 18 18 18
                16 16 16 4 4 16 16 17 17 18 18 18 18 19 19 19 19 19 19 19 18 13 8 13 0 23 22 1
                22 23 24 1 0)
          (list 14 14 14 14 14 14 13 9 9 9 9 8 8 8 9 9 9 9 10 10 10 6 7 7 7 8 8 8 12 12 16 16
                16 16 16 16 17 17 17 17 18 18 18 13 14 14 14 13 13 11 23 23 22 22 24 23 24 23
                24)
          (list 18 18 17 17 16 16 14 16 17 17 17 17 18 18 18 18 19 19 19 19 19 19 19 19 18 17
                17 16 4 4 16 16 17 17 18 18 18 18 19 19 19 19 19 19 19 19 19 13 13 8 23 23 22
                22 24 23 24 23 24)
          (list 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250
                250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250
                250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250 250
                250 250)) ;mapcar
  (mapcar 'vector_image ; Color 7
          (list 0 1 1 0 0 0 0 0 1 1 22)
          (list 0 1 1 0 0 0 0 24 1 1 1)
          (list 1 1 22 24 0 23 0 1 1 23 24)
          (list 1 22 1 0 24 0 23 22 23 1 0)
          (list 7 7 7 7 7 7 7 7 7 7 7)) ;mapcar
  (end_image)) ;defun
;;;




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Change Bitmap Button Function ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;from acadx.com
(defun ARCH:ChangeBitmap  (mnuGroup tbrName btnName bitmap)
  (vl-load-com)
  (vla-setbitmaps
    (vla-item
      (vla-item
        (vla-get-toolbars
          (vla-item (vla-get-menugroups (vlax-get-acad-object)) mnuGroup))
        tbrName)
      btnName)
    bitmap
    bitmap)
  (princ))
 ;|
Purpose
Changes the button top for the specified toolbar button
Arguments
The name of the menu group, the name of the toolbar, the name of the toolbar button and the bitmap to use
Example
(ARCH:ChangeBitmap "acad" "dimension" "linear dimension" "arch.bmp")
Notes
If the bitmap is not in the AutoCAD search path, you must specify the full path to file
(ARCH:ChangeBitmap "acad" "dimension" "linear dimension" "arch.bmp")
(ARCH:ChangeBitmap "ARCH" "Arch Program©" "SYMS" (strcat ARCH#IMAF "ARCH_SYMSX.bmp"))
|;
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2018x64 Windows 10x64

ymg

  • Swamp Rat
  • Posts: 725
Re: Simulate click on toolbar
« Reply #6 on: November 17, 2015, 01:22:09 PM »
hmspe,

It probably would be possible by shelling to an autohotkey script.

However, it is a bit of a tortuous way.

ymg


MSTG007

  • Water Moccasin
  • Posts: 2315
  • I can't remeber what I already asked! I need help!
Re: Simulate click on toolbar
« Reply #7 on: November 18, 2015, 07:34:42 AM »
I would be curious if you could hard code it (script it). I have been working a lot with them lately.
Autodesk Infrastructure Design Suite 2018

ymg

  • Swamp Rat
  • Posts: 725
Re: Simulate click on toolbar
« Reply #8 on: November 18, 2015, 11:43:17 AM »
MSTG007,

Quote
I would be curious if you could hard code it (script it). I have been working a lot with them lately.

Quite busy at the moment, and it's been a while that I've toyed with AHK
but I'll take a look when I have a chance.

ymg

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #9 on: November 08, 2016, 04:42:38 PM »
Hi ymg,

I know you are a busy man .. this quit some old tread,
and i wasn't going though all posts on 'toolbar' to find any clue, but..

do you or anyone have a solid sollution for some kind of dynamics toolbar / ribbon / onscreen approach to this question?
I was dusting off my old 'running osnap' function i used to work with. It is quit handy, except the *feedback* part is weak.
According to the physiotherapist i visited the other day it's good to change keyboard / mouse movement more ;-)
So, any idea to follow doktors description and make this code more transparent / better is welcome..

Thanks

*EDIT .. testing Bricscad V17 .. found there just what it should look like.. !! *



Code: [Select]
(Defun set_os_end ()
  (setq getosend (getvar "osmode"))
  (setq getosend_fix (fix (/ getosend 1)))
  (setq getosend_bep (rem getosend_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosend_bep 1)
    (setq os_mode_new (- os_mode_old 1))
    (setq os_mode_new (+ os_mode_old 1))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosend (getvar "osmode"))
  (setq lineosend_fix (fix (/ lineosend 1)))
  (setq lineosend_bep (rem lineosend_fix 2))
  (if (= lineosend_bep 1)
    (prompt "\nEND ON        ")
    (prompt "\nEND OFF       ")
  )
  (princ)
)

(defun set_os_mid ()
  (setq getosmid (getvar "osmode"))
  (setq getosmid_fix (fix (/ getosmid 2)))
  (setq getosmid_bep (rem getosmid_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosmid_bep 1)
    (setq os_mode_new (- os_mode_old 2))
    (setq os_mode_new (+ os_mode_old 2))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosmid (getvar "osmode"))
  (setq lineosmid_fix (fix (/ lineosmid 2)))
  (setq lineosmid_bep (rem lineosmid_fix 2))
  (if (= lineosmid_bep 1)
    (prompt "\nMID ON        ")
    (prompt "\nMID OFF       ")
  )
  (princ)
)

(defun set_os_cen ()
  (setq getoscen (getvar "osmode"))
  (setq getoscen_fix (fix (/ getoscen 4)))
  (setq getoscen_bep (rem getoscen_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getoscen_bep 1)
    (setq os_mode_new (- os_mode_old 4))
    (setq os_mode_new (+ os_mode_old 4))
  )
  (setvar "osmode" os_mode_new)
  (setq lineoscen (getvar "osmode"))
  (setq lineoscen_fix (fix (/ lineoscen 4)))
  (setq lineoscen_bep (rem lineoscen_fix 2))
  (if (= lineoscen_bep 1)
    (prompt "\nCEN ON        ")
    (prompt "\nCEN OFF       ")
  )
  (princ)
)

(defun set_os_nod ()
  (setq getosnod (getvar "osmode"))
  (setq getosnod_fix (fix (/ getosnod 8)))
  (setq getosnod_bep (rem getosnod_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosnod_bep 1)
    (setq os_mode_new (- os_mode_old 8))
    (setq os_mode_new (+ os_mode_old 8))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosnod (getvar "osmode"))
  (setq lineosnod_fix (fix (/ lineosnod 8)))
  (setq lineosnod_bep (rem lineosnod_fix 2))
  (if (= lineosnod_bep 1)
    (prompt "\nNOD ON        ")
    (prompt "\nNOD OFF       ")
  )
  (princ)
)

(defun set_os_qua ()
  (setq getosqua (getvar "osmode"))
  (setq getosqua_fix (fix (/ getosqua 16)))
  (setq getosqua_bep (rem getosqua_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosqua_bep 1)
    (setq os_mode_new (- os_mode_old 16))
    (setq os_mode_new (+ os_mode_old 16))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosqua (getvar "osmode"))
  (setq lineosqua_fix (fix (/ lineosqua 16)))
  (setq lineosqua_bep (rem lineosqua_fix 2))
  (if (= lineosqua_bep 1)
    (prompt "\nQUA ON        ")
    (prompt "\nQUA OFF       ")
  )
  (princ)
)

(defun set_os_int ()
  (setq getosint (getvar "osmode"))
  (setq getosint_fix (fix (/ getosint 32)))
  (setq getosint_bep (rem getosint_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosint_bep 1)
    (setq os_mode_new (- os_mode_old 32))
    (setq os_mode_new (+ os_mode_old 32))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosint (getvar "osmode"))
  (setq lineosint_fix (fix (/ lineosint 32)))
  (setq lineosint_bep (rem lineosint_fix 2))
  (if (= lineosint_bep 1)
    (prompt "\nINT ON        ")
    (prompt "\nINT OFF       ")
  )
  (princ)
)

(defun set_os_ins ()
  (setq getosins (getvar "osmode"))
  (setq getosins_fix (fix (/ getosins 64)))
  (setq getosins_bep (rem getosins_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosins_bep 1)
    (setq os_mode_new (- os_mode_old 64))
    (setq os_mode_new (+ os_mode_old 64))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosins (getvar "osmode"))
  (setq lineosins_fix (fix (/ lineosins 64)))
  (setq lineosins_bep (rem lineosins_fix 2))
  (if (= lineosins_bep 1)
    (prompt "\nINS ON        ")
    (prompt "\nINS OFF       ")
  )
  (princ)
)

(defun set_os_per ()
  (setq getosper (getvar "osmode"))
  (setq getosper_fix (fix (/ getosper 128)))
  (setq getosper_bep (rem getosper_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosper_bep 1)
    (setq os_mode_new (- os_mode_old 128))
    (setq os_mode_new (+ os_mode_old 128))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosper (getvar "osmode"))
  (setq lineosper_fix (fix (/ lineosper 128)))
  (setq lineosper_bep (rem lineosper_fix 2))
  (if (= lineosper_bep 1)
    (prompt "\nPER ON        ")
    (prompt "\nPER OFF       ")
  )
  (princ)
)

(defun set_os_tan ()
  (setq getostan (getvar "osmode"))
  (setq getostan_fix (fix (/ getostan 256)))
  (setq getostan_bep (rem getostan_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getostan_bep 1)
    (setq os_mode_new (- os_mode_old 256))
    (setq os_mode_new (+ os_mode_old 256))
  )
  (setvar "osmode" os_mode_new)
  (setq lineostan (getvar "osmode"))
  (setq lineostan_fix (fix (/ lineostan 256)))
  (setq lineostan_bep (rem lineostan_fix 2))
  (if (= lineostan_bep 1)
    (prompt "\nTAN ON        ")
    (prompt "\nTAN OFF       ")
  )
  (princ)
)

(defun set_os_nea ()
  (setq getosnea (getvar "osmode"))
  (setq getosnea_fix (fix (/ getosnea 512)))
  (setq getosnea_bep (rem getosnea_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosnea_bep 1)
    (setq os_mode_new (- os_mode_old 512))
    (setq os_mode_new (+ os_mode_old 512))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosnea (getvar "osmode"))
  (setq lineosnea_fix (fix (/ lineosnea 512)))
  (setq lineosnea_bep (rem lineosnea_fix 2))
  (if (= lineosnea_bep 1)
    (prompt "\nNEA ON        ")
    (prompt "\nNEA OFF       ")
  )
  (princ)
)

(Defun set_os_gcen ()
  (setq getosgcen (getvar "osmode"))
  (setq getosgcen_fix (fix (/ getosgcen 1024)))
  (setq getosgcen_bep (rem getosgcen_fix 2))
  (setq os_mode_old (getvar "osmode"))
  (if (= getosgcen_bep 1)
    (setq os_mode_new (- os_mode_old 1024))
    (setq os_mode_new (+ os_mode_old 1024))
  )
  (setvar "osmode" os_mode_new)
  (setq lineosgcen (getvar "osmode"))
  (setq lineosgcen_fix (fix (/ lineosgcen 1024)))
  (setq lineosgcen_bep (rem lineosgcen_fix 2))
  (if (= lineosgcen_bep 1)
    (prompt "\nGCEN ON        ")
    (prompt "\nGCEN OFF       ")
  )
  (princ)
)

  (defun set_os_app ()
    (setq getosapp (getvar "osmode"))
    (setq getosapp_fix (fix (/ getosapp 2048)))
    (setq getosapp_bep (rem getosapp_fix 2))
    (setq os_mode_old (getvar "osmode"))
    (if (= getosapp_bep 1)
      (setq os_mode_new (- os_mode_old 2048))
      (setq os_mode_new (+ os_mode_old 2048))
    )
    (setvar "osmode" os_mode_new)
    (setq lineosapp (getvar "osmode"))
    (setq lineosapp_fix (fix (/ lineosapp 2048)))
    (setq lineosapp_bep (rem lineosapp_fix 2))
    (if (= lineosapp_bep 1)
      (prompt "\nAPP ON        ")
      (prompt "\nAPP OFF       ")
    )
    (princ)
  )

  (defun set_os_ext ()
    (setq getosext (getvar "osmode"))
    (setq getosext_fix (fix (/ getosext 4096)))
    (setq getosext_bep (rem getosext_fix 2))
    (setq os_mode_old (getvar "osmode"))
    (if (= getosext_bep 1)
      (setq os_mode_new (- os_mode_old 4096))
      (setq os_mode_new (+ os_mode_old 4096))
    )
    (setvar "osmode" os_mode_new)
    (setq lineosext (getvar "osmode"))
    (setq lineosext_fix (fix (/ lineosext 4096)))
    (setq lineosext_bep (rem lineosext_fix 2))
    (if (= lineosext_bep 1)
      (prompt "\nEXT ON        ")
      (prompt "\nEXT OFF       ")
    )
    (princ)
  )

  (defun set_os_par ()
    (setq getospar (getvar "osmode"))
    (setq getospar_fix (fix (/ getospar 8192)))
    (setq getospar_bep (rem getospar_fix 2))
    (setq os_mode_old (getvar "osmode"))
    (if (= getospar_bep 1)
      (setq os_mode_new (- os_mode_old 8192))
      (setq os_mode_new (+ os_mode_old 8192))
    )
    (setvar "osmode" os_mode_new)
    (setq lineospar (getvar "osmode"))
    (setq lineospar_fix (fix (/ lineospar 8192)))
    (setq lineospar_bep (rem lineospar_fix 2))
    (if (= lineospar_bep 1)
      (prompt "\nPAR ON        ")
      (prompt "\nPAR OFF       ")
    )
    (princ)
  )


(defun set_os_clear ()
 (setvar "osmode" 0)
)





« Last Edit: November 08, 2016, 05:44:49 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #10 on: November 09, 2016, 02:45:52 PM »
Hans, your code is indeed somewhat cumbersome and strange, and you probably do not even need Lisp to achieve what you want.

1.
But if you want to use Lisp, something like this will do the trick:
Code: [Select]
(setvar 'osmode (boole 6 (getvar 'osmode) 1))This will toggle the Endpoint osnap.
2.
It is however easier to change the command in the CUI.
If the command is "_endpoint" and the macro is used while a command is active, the Endpoint snap will be set as a temporary override (this is the default in BricsCAD).
If the command is "'_endpoint" (with an apostrophe) the Endpoint snap will be toggled even if a command is active (and this seems to be the behavior you want).
3.
The depressed state of the buttons is controlled by the CUI. See the 'State' line in the code below. I assume that AutoCAD also supports this.
Code: [Select]
<ToolbarButton>
  <Name>Snap to Endpoint</Name>
  <MenuItem>
    <MacroRef MenuMacroID="osnap_endpoint"/>
  </MenuItem>
  <State>$(if,$(=,$(and,$(getvar,OSMODE),0x0001),0),,!.)</State>
</ToolbarButton>

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #11 on: November 09, 2016, 03:08:03 PM »
Thanks for your replay Roy,
Will explore your boole and the suggested code for transparancy..
But i think AutoCAD doesn't have a <state> for <toolbar button>.
In stead Autocad users haven '.. The Ribbon'  :thinking: (title for a movie.. :)
Design is something you should do with both hands. My 2d hand , my 3d hand ..

hmspe

  • Bull Frog
  • Posts: 329
Re: Simulate click on toolbar
« Reply #12 on: November 09, 2016, 03:57:58 PM »
The last time I checked Autocad does not support having toolbar buttons appear to be pressed or toggled. 

It is relatively easy to use AUTOHOTKEY to simulate toolbar button presses, although I would probably create a dialog using OpenDCL to replace the toolbar if I was still using Autocad.
"Science is the belief in the ignorance of experts." - Richard Feynman

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #13 on: November 10, 2016, 05:23:25 AM »
Maybe this can be done in AutoCAD with a SysVar reactor (:vlr-sysVarChanged) and the vla-setbitmaps function.

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #14 on: November 10, 2016, 08:29:36 AM »
Wow..  :rip:
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #15 on: November 11, 2016, 05:59:45 AM »
@lamarn:
Not exactly what you want but here is a MODEMACRO solution that will display the osnaps in the status bar:
Code: [Select]
(setvar "MODEMACRO"
  (strcat
    "$(if,$(=,$(getvar,OSMODE),0),** OSNAPS OFF ** ,)"
    "$(if,$(=,$(and,$(getvar,OSMODE),    1),0),,END )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    2),0),,MID )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    4),0),,CEN )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    8),0),,NOD )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   16),0),,QUA )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   32),0),,INT )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   64),0),,INS )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  128),0),,PER )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  256),0),,TAN )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  512),0),,NEA )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 1024),0),,GCE )" ; Geometric center (BricsCAD).
    "$(if,$(=,$(and,$(getvar,OSMODE), 2048),0),,APP )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 4096),0),,EXT )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 8192),0),,PAR )"
    "$(if,$(=,$(and,$(getvar,OSMODE),16384),0),,** OSNAPS OFF ** )"
  )
)

Lee Mac

  • Seagull
  • Posts: 12109
  • London, England
Re: Simulate click on toolbar
« Reply #16 on: November 11, 2016, 08:24:02 AM »
Assuming I've understood the request, this thread may be of interest.

MSTG007

  • Water Moccasin
  • Posts: 2315
  • I can't remeber what I already asked! I need help!
Re: Simulate click on toolbar
« Reply #17 on: November 11, 2016, 08:37:11 AM »
I am still trying to understand this. Is the object for the user to hoover there mouse over the icon and the command in the icon activates?
Autodesk Infrastructure Design Suite 2018

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Re: Simulate click on toolbar
« Reply #18 on: November 11, 2016, 08:58:59 AM »
@lamarn:
Not exactly what you want but here is a MODEMACRO solution that will display the osnaps in the status bar:
Code: [Select]
(setvar "MODEMACRO"
  (strcat
    "$(if,$(=,$(getvar,OSMODE),0),** OSNAPS OFF ** ,)"
    "$(if,$(=,$(and,$(getvar,OSMODE),    1),0),,END )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    2),0),,MID )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    4),0),,CEN )"
    "$(if,$(=,$(and,$(getvar,OSMODE),    8),0),,NOD )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   16),0),,QUA )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   32),0),,INT )"
    "$(if,$(=,$(and,$(getvar,OSMODE),   64),0),,INS )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  128),0),,PER )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  256),0),,TAN )"
    "$(if,$(=,$(and,$(getvar,OSMODE),  512),0),,NEA )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 1024),0),,GCE )" ; Geometric center (BricsCAD).
    "$(if,$(=,$(and,$(getvar,OSMODE), 2048),0),,APP )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 4096),0),,EXT )"
    "$(if,$(=,$(and,$(getvar,OSMODE), 8192),0),,PAR )"
    "$(if,$(=,$(and,$(getvar,OSMODE),16384),0),,** OSNAPS OFF ** )"
  )
)
Maybe this is simple:
Code: [Select]
(defun sample ( / CurStr)
  (setq CurStr "")
  (mapcar
           '(lambda (x s)
              (if (= (logand x (getvar "OSMODE")) x) (setq CurStr (strcat CurStr s)))
            )
           '(1 2 4 8 16 32 64 128 256 512 2048)
           '("_Endpoint," "_Midpoint," "_Center," "_Node," "_Quadrant," "_Intersec," "_Insert,"
             "_Perpend,"  "_Tangent,"  "_Nearest,""_Appint,"
  ) )
  (setvar "USERS5" (strcat " " (substr CurStr 2 (- (strlen CurStr) 2)) "."))
  (setvar "MODEMACRO" "[$(getvar,users5)]")
)

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #19 on: November 11, 2016, 09:59:57 AM »
Maybe this is simple:
Your suggestion only displays the current settings in the statusbar. My suggestion will update automatically whenever the osmode changes.

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #20 on: November 11, 2016, 10:32:03 AM »
I was thinking more about a OpenDCL approach. Found a a modeless form has what i am looking for..
http://www.opendcl.com/forum/index.php?topic=2446.msg12208#msg12208
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 937
  • Marco
Re: Simulate click on toolbar
« Reply #21 on: November 11, 2016, 11:04:53 AM »
Maybe this is simple:
Your suggestion only displays the current settings in the statusbar. My suggestion will update automatically whenever the osmode changes.
You're right, I apologize. I change the osnaps only with a specific function...

hmspe

  • Bull Frog
  • Posts: 329
Re: Simulate click on toolbar
« Reply #22 on: November 11, 2016, 11:28:43 AM »
AcadStatButton available from manusoft.com in the Freebies/Miscellaneous tab will let you add buttons to the status bar which will toggle.  I have attached the lisp file I used with AcadStatButton before I switched to Bricscad. 
"Science is the belief in the ignorance of experts." - Richard Feynman

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #23 on: November 11, 2016, 12:37:10 PM »
Thanks so much Richard and all of you guys!
This is looking promising.. To me the great value of the forum community to share and combine ideas is a real fact!!
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #24 on: November 12, 2016, 03:49:54 PM »
FWIW: I have posted an ODCL-based solution here.

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #25 on: November 13, 2016, 05:14:55 PM »
Lets discuss this Opendcl sollution furhter on there.
But here is a screenshot i am happy to share ..! nice job, all credits to you mr. Roy_043
I am very thankful for your help getting this on track..!  :-D

*EDIT* updated a gif
« Last Edit: November 16, 2016, 04:13:50 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #26 on: November 16, 2016, 04:14:51 PM »
Credits to mr. Roy_04 for making this fine piece of machine buttons .. :wideeyed2:
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #27 on: January 16, 2017, 05:01:11 PM »
Hi

I'm trying to come up with a toggle (refresh) button..
The main .lsp is OpenDcl and this if functions calls a subroutine, this seem to work

Any experience idea to make this more elegant or how this can work better much appriciated.
Even better would be is the toolbar was to come just by pressing F3, but that would need some kind of reactor..

** EDIT
By Using  (progn (load "Osnaps") (dcl-Form-Close Osnaps/Main) ())) it supresses the OpenDCL warning
**

; "Osnaps" by Roy_043
http://www.opendcl.com/forum/index.php?topic=2446.msg12212#msg12212


Code: [Select]

(defun c:Tbar_osnap ()
    (setvar "userr1"
        (abs   
            (1-
                (getvar "userr1")
            )
        )
    )

  (setq tbmode (rtos (getvar "userr1") 2 0))

  (if (= tbmode "1")
    (load "Osnaps") ())

  (if (= tbmode "0")
     (progn (load "Osnaps") (dcl-Form-Close Osnaps/Main) ())) ; ** EDIT **

    (princ)
)

« Last Edit: January 17, 2017, 02:45:52 AM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #28 on: January 17, 2017, 01:41:36 PM »
I have updated the code. See here.
A keyboard shortcut (e.g. F3) can be created for the new c:Osnap-FormToggle function.


lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #29 on: January 17, 2017, 04:23:17 PM »
Super, thank Roy!!  :yay!:
Sorry for asking but how could c:Osnap-FormToggle than best be added to F3, ..knowing OpenDCL is running

acad says F3 does this
^P'_.osmode $M=$(if,$(and,$(getvar,osmode),16384),$(-,$(getvar,osmode),16384),$(+,$(getvar,osmode),16384))

tried these two mods but it doesn't work out.. :

^P'_.osmode $M=$(if,$(and,$(getvar,osmode),16384),$(-,$(getvar,osmode),16384),$(+,$(getvar,osmode),16384)),c:Osnap-FormToggle
^P'Osnap-FormToggle;_.osmode $M=$(if,$(and,$(getvar,osmode),16384),$(-,$(getvar,osmode),16384),$(+,$(getvar,osmode),16384))
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #30 on: January 18, 2017, 07:31:43 AM »
I have updated the code again. See here.

The function c:Osnap-FormToggle has been renamed to c:Osnaps-FormToggle.
This function only toggles the display of the form.

There is a new function c:Osnaps-Toggle.
This function toggles the osnaps (the 16384 bit) and changes the display of the form to match.

A keyboard shortcut should work with this as the command:
Code: [Select]
^P'Osnaps-Toggle^P
« Last Edit: January 18, 2017, 07:41:01 AM by roy_043 »

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #31 on: January 18, 2017, 05:34:19 PM »
Nice work Roy.. Great further improvement! Will make it more efficient en user friendly.
I decided to leave the F3 button unchanged because this these OpenDCL function don't fully work transparent.
So, i was thinking, this F4 button can be a great target since i never use with 3Dsnaps.
Here is how F-button can be adressed... follwing..

http://forums.autodesk.com/t5/autocad-2010-2011-2012/function-keys-customization/td-p/3045206

attached also the idea of pressing F3, F4
I Like it!



« Last Edit: January 18, 2017, 05:55:42 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #32 on: January 19, 2017, 03:36:11 AM »
... because this these OpenDCL function don't fully work transparent...
For the functions to work transparently you have to prefix the macro command with a single quote. It seems you have forgotten to do so. See the suggestion in my previous post. In BricsCAD c:Osnaps-Toggle and c:Osnaps-FormToggle can be used transparently.

Edit:
Mind you there is an issue (in BricsCAD 16 at least) when trying to use keyboard shortcuts if DYNMODE is on.
« Last Edit: January 19, 2017, 06:49:18 AM by roy_043 »

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #33 on: January 19, 2017, 03:41:03 PM »
Prolongated it to F3.
Design is something you should do with both hands. My 2d hand , my 3d hand ..

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #34 on: January 19, 2017, 04:22:18 PM »
@Hans:
Do you also experience a problem with the transparent use of the command if you type:
Code: [Select]
'Osnaps-Toggle?

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #35 on: January 19, 2017, 06:00:42 PM »
No. I do some more testing
Will report if i've had any strange behaviour..

https://youtu.be/g5v36dmHStY

« Last Edit: January 19, 2017, 06:05:04 PM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Hugo

  • Bull Frog
  • Posts: 305
Re: Simulate click on toolbar
« Reply #36 on: January 20, 2017, 12:19:18 AM »
Wanted this also testing runs unfortunately OpenDCL on Autocad 2017 not.   :-( :-(


Wollte das auch Testen leider läuft OpenDCL auf Autocad 2017 nicht.

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #37 on: January 20, 2017, 03:07:53 AM »
Hi Hugo
What version did you install? Check their website /forum for 2017..
It runs on my laptop.

« Last Edit: January 20, 2017, 03:16:02 AM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

Hugo

  • Bull Frog
  • Posts: 305
Re: Simulate click on toolbar
« Reply #38 on: January 20, 2017, 04:36:47 AM »
Autocad 2017 21.0s

How is the OpenDCL loaded with you?


Autocad 2017 21.0s

Wie wird bei dir das OpenDCL geladen ?

roy_043

  • Water Moccasin
  • Posts: 1643
  • BricsCAD 18
Re: Simulate click on toolbar
« Reply #39 on: January 20, 2017, 06:05:28 AM »
Autocad 2017 21.0s

How is the OpenDCL loaded with you?


Autocad 2017 21.0s

Wie wird bei dir das OpenDCL geladen ?
The program will load ODCL, but you have to have the correct ODCL version installed. And ODCL must be installed after AutoCAD.

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #40 on: January 20, 2017, 06:12:04 PM »
Autocad 2017 21.0s

How is the OpenDCL loaded with you?


Autocad 2017 21.0s

Wie wird bei dir das OpenDCL geladen ?

Like .dcl the .odcl files needs to be in the support path. The rest is the same, load the lisp (on activation)
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #41 on: December 06, 2018, 09:56:17 AM »
I'm picking up this old story about the osnap function.
What i really would like is to isolate the osnapz toggle function, written without opendcl code.
Meaning a reactor controls the grid in conjuction with the osnapz setting.
That would be a great function for wider use.

I isolates some code to start.  But i am not experienced enough to get this to work propertly.  :crazy2:
Maybe someone can help me with this.

Thanks!

Code: [Select]

(defun Osnapz-OnLoad () ; based on the work of Roy
    ;; Remove existing reactors:
    (mapcar '(lambda (rea)
                 (if (= "OSNAPZ" (vlr-data rea))
                     (vlr-remove rea)
                 )
             )
            (apply 'append (mapcar 'cdr (vlr-reactors)))
    )
    ;; Create new reactors:
    (vlr-sysvar-reactor
        "OSNAPZ"
        '((:vlr-sysvarchanged . Osnaps-CallBackSysvarChanged)
          (:vlr-sysvarwillchange . Osnaps-CallBackSysvarWillChange)
         )
    )
    (vlr-docmanager-reactor
        "OSNAPZ"
        '((:vlr-documentbecamecurrent . Osnaps-CallBackDocumentBecameCurrent)
          (:vlr-documenttobedeactivated . Osnaps-CallBackDocumentToBeDeactivated)
         )
    )
    (vlr-command-reactor
        "OSNAPZ"
        '((:vlr-commandcancelled . Osnaps-CallBackCommandCancelled)
          (:vlr-commandfailed . Osnaps-CallBackCommandCancelled)
          (:vlr-commandwillstart . Osnaps-CallBackCommandWillStart)
         )
    )
    (princ)
)


(defun Osnaps-CallBackSysvarChanged (rea lst)
    (cond ((= "OSNAPZ" (car lst)) (Osnaps-UpdateOsnapz nil)))
)
(defun Osnaps-CallBackDocumentBecameCurrent (rea lst)
  (Osnaps-UpdateOsnapz nil)
)
(defun Osnaps-CallBackDocumentToBeDeactivated (rea lst)
  (Osnaps-UpdateOsnapz  T)
)

(defun Osnaps-UpdateOsnapz (disableP / btn)
  (if (setq btn Osnaps/Main/btnOsnapz)
    (cond
      (disableP
        (dcl-Control-SetBackColor btn -16) ; here .., no opendcl codes ..
        (dcl-Control-SetForeColor btn -19) ; here .., no opendcl codes ..
      )
      ((zerop (getvar 'osnapz))
        (dcl-Control-SetBackColor btn 0) ; here .., no opendcl codes ..
        (dcl-Control-SetForeColor btn 7) ; here .., no opendcl codes ..
      )
      (T
        (dcl-Control-SetBackColor btn 7) ; here .., no opendcl codes ..
        (dcl-Control-SetForeColor btn 0) ; here .., no opendcl codes ..
      )
    )
  )
)

; not working yet though

« Last Edit: December 06, 2018, 09:59:56 AM by lamarn »
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 582
Re: Simulate click on toolbar
« Reply #42 on: December 10, 2018, 02:35:00 AM »
Aha. Just this one.

(defun c:Oz () (setvar 'gridmode (setvar 'osnapz (boole 6 (getvar 'osnapz) 1))) (princ))
Design is something you should do with both hands. My 2d hand , my 3d hand ..