Author Topic: Script Shortcut Buttons  (Read 5047 times)

Online csirocnc

  • Storm Trooper
  • ***
  • Posts: 146
  • Howell V4
    • View Profile
Script Shortcut Buttons
« on: February 08, 2014, 09:21:46 am »
Hi All
Has anyone seen or made (hint hint)  "user buttons" that can be on the tool bar and defined to open selected scripts.

Cheers
Paul
1st CamBam Licence sale
in Australia

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8314
    • View Profile
Re: Script Shortcut Buttons
« Reply #1 on: February 08, 2014, 16:54:58 pm »
Um.... many plugins plant buttons on the toolbar!

A plugin is just a script wearing a tuxedo.

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 3964
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: Script Shortcut Buttons
« Reply #2 on: February 09, 2014, 18:27:12 pm »
Kinda like politicians and pigs. 
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 155
  • Jam it !
    • View Profile
Re: Script Shortcut Buttons
« Reply #3 on: November 19, 2018, 09:37:48 am »
The question old, but I want to ask again.
Is it possible to start a python script just by clicking a simple button
instead of script-open script-select the script-F5 ?

Best regards

Bernhard
best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4409
    • View Profile
Re: Script Shortcut Buttons
« Reply #4 on: November 19, 2018, 09:53:15 am »
Made in England

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 155
  • Jam it !
    • View Profile
Re: Script Shortcut Buttons
« Reply #5 on: November 19, 2018, 10:04:41 am »
Eddy, I guess you´re never sleeping...  ;D

THX for your extreme answer.

I´d rather had just a nice button to quick-start my magic script.
No SIMPLE way ?




best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4409
    • View Profile
Re: Script Shortcut Buttons
« Reply #6 on: November 19, 2018, 10:29:20 am »
Make it a plugin then you can do that
Made in England

Offline onekk

  • CNC Jedi
  • *****
  • Posts: 512
    • View Profile
Re: Script Shortcut Buttons
« Reply #7 on: November 19, 2018, 11:02:47 am »
Code: [Select]
namespace YourNamespace
{
    public class YourMainClass
    {
        public YourMainClass()
        {
        }

        public static void InitPlugin(CamBamUI ui)
        {

            // Create a new menu item in the top Plugins menu
            ToolStripMenuItem mi = new ToolStripMenuItem();
            mi.Text = "Your_MenuText";

            mi.Click += new EventHandler(plugin_clicked);
            mi.ShortcutKeys = Keys.Control | Keys.Shift | Keys.M;
   mi.ShortcutKeyDisplayString = "Ctrl + Shift + M";
            ui.Menus.mnuPlugins.DropDownItems.Add(mi);
          
        }

        public static void plugin_clicked(object sender, EventArgs e)
        {
          
            YourMainForm iface = new YourMainForm();
            iface.Owner = CamBam.ThisApplication.TopWindow;
            iface.Show();

        }

        

    }

}

This is the base for a plugin, the part that put the plugin name in the plugins menu.
I assembled some code (the shortcut parts is from another plugin)

To create a button you have to populate the InitPlugin(CamBamUI ui) with the proper code to create a button,

At the moment I don't rember the proper code, as i haven't had the nedd to crete one  but generally it involves:

1) adding some icon that became the button
2) creating and adding a button to the ToolBar
3) adding an action that is executed when the button is pressed

The  usual thing is to write a plugin that do what you want, but it has to be written in C# or maybe in VB# (some other guys have writtens some plugins in VB# notably dh42 if i'm remeber well)

I doubt there is no way to make a button in a script, as the scripts are not auto-loadable if I remember well, for this someone have developed the launcher plugin, as noted in this thread.

Regards

Carlo D.
« Last Edit: November 19, 2018, 11:09:19 am by onekk »
Carlo D. (onekk)

eShapeoko #343 750x1000 mm + GRBL + bCNC + CamBam

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 155
  • Jam it !
    • View Profile
Re: Script Shortcut Buttons
« Reply #8 on: November 19, 2018, 11:08:00 am »
Thank you very much, but this is too complicated for me.
Just to save a few mouse-clicks I don´t want to
- Install Visual Studio
- Learning some C#

I prefer the KIS-principle : Keep it simple !  ;D

best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4409
    • View Profile
Re: Script Shortcut Buttons
« Reply #9 on: November 19, 2018, 13:48:49 pm »
The problem here is that a button has to exist BEFORE the script is started, that implies something else has to run first to make the button available.
With that in mind I think the "Script Launcher" plugin is your best option.
« Last Edit: November 19, 2018, 13:51:02 pm by EddyCurrent »
Made in England

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2341
    • View Profile
Re: Script Shortcut Buttons
« Reply #10 on: November 19, 2018, 14:56:46 pm »
While we are at it there is a missing keyboard shortcut, not speak about a button for one of the most frequently used CB functions - Transform -> Align.

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 155
  • Jam it !
    • View Profile
Re: Script Shortcut Buttons
« Reply #11 on: November 20, 2018, 14:56:51 pm »
Try this plugin; http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/Script_launcher.html

At first I want to apologize. I meant "extreme fast answer" instead of "extreme answer".

The Script launcher works like a charm, it´s only 1 mouse-click more than a launch button.

THX !

Bernhard

« Last Edit: November 21, 2018, 21:04:12 pm by gmoo »
best regards

Bernhard