Author Topic: [script] Numerical XY Move + [plugin] NumMove  (Read 76168 times)

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4333
    • View Profile
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #195 on: April 03, 2020, 22:24:01 pm »
Lloyd,

Been on the Guinness Foreign Extra ?   ;D I thank you for your comments but as you say I'm just ONE of the helpers here, I do it because it's what I've always done.
I also extend my appreciation to others on the forum.
« Last Edit: April 04, 2020, 11:08:59 am by EddyCurrent »
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 5960
    • View Profile
    • Cambam French Doc
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #196 on: April 03, 2020, 22:27:32 pm »
Hello

Yes V 1.2.0.62 of nummove plugin is working on 64 bits version too ... it's the first plugin I tested after I install CB 64 bits  ;D

Currently, all my plugins except 2 seems to works with CB 64, only ExportSelectionToDXF and RadiusPlugin (fillet/chamfer) needs to be replaced by the very last version to be able to works with 64 bits

http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/exportDXF.html

http://www.atelier-des-fougeres.fr/Cambam/Aide/Plugins/fillet-chamfer.html

Have a look here to see what plugins has been updated since Andy publish CB 64 bits

http://www.cambam.co.uk/forum/index.php?topic=4886.msg67387#msg67387

++
David

Offline Dragonfly

  • CNC Jedi
  • *****
  • Posts: 2298
    • View Profile
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #197 on: May 22, 2020, 15:23:51 pm »
Hi David,
It's me again :)
I'd really appreciate if you can make NumMove for Linux remeber the last used values like it does under Windows. If possible.
I read recently in the forum that Windows registry method can be applied under Mono. I suppose you use the registry for keeping the plugin state.

Also, under Windows if there is another program running together with CB after closing the plugin window focus moves to that program and not back to CamBam. But this is a minor problem.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 5960
    • View Profile
    • Cambam French Doc
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #198 on: May 22, 2020, 15:48:52 pm »
Hello

Quote
I read recently in the forum that Windows registry method can be applied under Mono. I suppose you use the registry for keeping the plugin state.

Yep registry works under mono but only with C#, with VB .net the plugin crash if I use registry.

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4333
    • View Profile
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #199 on: May 22, 2020, 19:03:55 pm »
David,

(These examples are from my Profile2Helix plugin)

public static double steps = 0.0;

// these DO NOT work with Linux
// Save Registry values
       
Interaction.SaveSetting("CBPlug_Poly2Helix", "Settings", "steps", Params.steps.ToString());

// Load Registry values

Params.steps = double.Parse(Interaction.GetSetting("CBPlug_Poly2Helix", "Settings", "steps", Params.steps.ToString()));

These DO work with Linux

Params.steps = double.Parse(GetRegSetting("CBPlug_Poly2Helix", "Settings", "steps", Params.steps.ToString()));
SaveRegSetting("CBPlug_Poly2Helix", "Settings", "steps", Params.steps.ToString());


private string GetRegSetting(string AppName, string Section, string Key, string Default)
        {
            // attempt to open the subkey
            RegistryKey regKey = Registry.CurrentUser.OpenSubKey("Software\\" + AppName + "\\" + Section, false);

            // if it fails then return Default value
            if (regKey == null)
            {
                return Default;
            }

            else
            {
                try
                {
                    object setting = regKey.GetValue(Key);
                    if (setting == null) return Default;
                    return setting.ToString();
                }
                catch (Exception e)
                {
                    CamBam.ThisApplication.AddLogMessage("Registry Read Error " + e);
                    return null;
                }
            }
        }


        private bool SaveRegSetting(string AppName, string Section, string Key, string Setting)
        {
            try
            {
                // Use CreateSubKey (create or open it if already exits)
                // located in, HKEY_CURRENT_USER\Software   
                RegistryKey rootKey = Registry.CurrentUser.CreateSubKey("Software");
                RegistryKey appKey = rootKey.CreateSubKey(AppName);
                RegistryKey sectionKey = appKey.CreateSubKey(Section);

                sectionKey.SetValue(Key, Setting);
                return true;
            }
            catch (Exception e)
            {
                CamBam.ThisApplication.AddLogMessage("Registry Write Error " + e);
                return false;
            }
        }





« Last Edit: May 22, 2020, 19:27:43 pm by EddyCurrent »
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 5960
    • View Profile
    • Cambam French Doc
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #200 on: May 22, 2020, 20:55:04 pm »
Hello

Thanks Eddy ; when time permit I'll have a look to translate this to VB ... and hope this works ..

If it will not work, another workaround is to use global variables so, at least, the value will persist for a CamBam cession and will not be lost each time the plugin is closed.

And the last chance is a separate config file, but I'm not aware of the file convention on Linux, I just know that a Windows file path definition do not works on Linux.

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4333
    • View Profile
Re: [script] Numerical XY Move + [plugin] NumMove
« Reply #201 on: May 22, 2020, 21:07:43 pm »
David,

Path.Combine

This works,

 // use Path Combine for Linux compatibility
 // use our autosave path
            CamBamUI.MainUI.ActiveView.CADFile.Filename = Path.Combine(Params.SavePath, Params.FileName) +"_AutoSave.cb";
Made in England