Author Topic: Custom scripts plugin  (Read 22491 times)

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Custom scripts plugin
« on: January 14, 2015, 15:51:37 pm »
I developed a new plugin which adds a new submenu with the name "Custom scripts" on the script menu. This plugin help you to open, run and auto startup scripts. With this plugin you can create interactive scripts. Please view the script example.



The plugin gets the configuration from the xml file CustomScripts.xml in the plugin folder of CamBam. You can edit the xml file and add your scripts.

With this configuration the plugin adds 3 new items on submenu "Custom scripts" with name Elipse VBS, Elipse PY and Elipse JS. And auto startup the script with name "Elipse VBS".
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<CustomScripts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <AutoHideScriptWindow>true</AutoHideScriptWindow>
  <List>
    <CustomScript>
      <Name>Elipse VBS</Name>
      <Path>C:\ProgramData\CamBam plus 0.9.8\scripts\elipse2.vbs</Path>
      <Autostartup>true</Autostartup>
    </CustomScript>
    <CustomScript>
      <Name>Elipse PY</Name>
      <Path>C:\ProgramData\CamBam plus 0.9.8\scripts\elipse2.py</Path>
      <Autostartup>false</Autostartup>
    </CustomScript>
    <CustomScript>
      <Name>Elipse JS</Name>
      <Path>C:\ProgramData\CamBam plus 0.9.8\scripts\elipse2.js</Path>
      <Autostartup>false</Autostartup>
    </CustomScript>
  </List>
</CustomScripts>

For example, if you have a script for add a circle, you can ask to the user what is the value of x, y, z and diameter of the script, like this:
Code: [Select]
'STARTCONST
const x as single = 0 'DESC:Position x of the circle
const y as single = 0 'DESC:Position y of the circle
const z as single = 0 'DESC:Position z of the circle
const diameter as single = 20 'DESC:Diameter of the circle
'ENDCONST

sub main
dim c as Circle = new Circle()
dim p as Point3F = new Point3F(x, y, z)

c.center = p
c.diameter = diameter

doc.add(c)
end sub

The result is this:
Get value for variable x:


Get value for variable y:


Get value for variable z:


Get value for variable diameter:


Final result:


Please find in attach the new version of the script elipse in vb, python and js language.

Installation guide
===================
  • extract the file CustomScripts.zip
  • copy the CustomScripts.dll and CustomScripts.xml for the plugin folder of CamBam
  • edit CustomScripts.xml file and add your scripts
  • if you what, extract elipse2.zip and copy the example scripts for the script folder of CamBam

I hope it helps someone.

Change log
===================
v1.0
  • Initial version

v1.1
  • Resolved problem with load xml when open CamBam from project file;
  • Owner inputbox has changed to the inputbox of the CamBam.

v1.2
  • Resolved problem with load xml when open CamBam from project file;
  • Resolved problem with path of the dll output;
  • Show an alert if the script file doesn't exit.

v1.3
  • Resolved problem with load xml when open CamBam with a startup script;
  • New features:
    • Added code for localization the plugin. List of string messages:
      • Custom scripts
        • Menu entry.
      • Cannot load the configuration file!
        • Alert message when script is loaded and cannot open the xml configuration file.
      • Close script window?
        • Confirmation box if the parameter AutoHideScriptWindow is set to false.
      • Information
        • Caption for the confirmation box "Close script window?"
      • Cannot load the {0} script!
        • Alert message when the plugin cannot find the script file.
      • Value for {0}
        • Caption on input box for get new value of a script parameter.
    • New parameter on CustomScripts.xml file, <AutoHideScriptWindow>true</AutoHideScriptWindow>. If set true, the script hide the script window when opens the script.

v1.3.1
  • Resolved problem with open first or other scripts if you have two or more script define on xml file
« Last Edit: January 23, 2015, 15:23:08 pm by BaNoBi »

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #1 on: January 14, 2015, 16:16:29 pm »
That's great but looks like I need Visual Studio Express 2010 something or other ?
« Last Edit: January 14, 2015, 16:21:38 pm by EddyCurrent »
Made in England

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Re: Custom scripts plugin
« Reply #2 on: January 14, 2015, 16:22:31 pm »
That's great but looks like I need Visual Studio Express 2010 something or other ?
Are you extract the file CustomScripts.zip and copy the CustomScripts.dll and CustomScripts.xml for plugin folder of CamBam?

Please show me the errors, for I help you.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #3 on: January 14, 2015, 16:27:19 pm »
Yes that's okay but I want to get it working with Visual Studio Express 2010 c#. I can't get any projects for CamBam to build.

I've just started to look at this VSE 2010 today so let me have a search on the forum first for a solution, thanks for your time.
« Last Edit: January 14, 2015, 16:33:45 pm by EddyCurrent »
Made in England

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Re: Custom scripts plugin
« Reply #4 on: January 14, 2015, 16:33:41 pm »
Yes that's okay but I want to get it working with Visual Studio Express 2010 c#. I can't get any projects for CamBam to build.

For me it works like this:
  • delete all references of CamBam in project
  • copy CamBam.CAD.dll to the project folder
  • copy CamBam.Geom.dll to the project folder
  • Add new reference to the CamBam.exe
  • Add new reference to the copied CamBam.CAD.dll
  • Add new reference to the copied CamBam.Geom.dll

I use Microsoft Visual Studio 2012.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #5 on: January 14, 2015, 16:35:17 pm »
Thanks, I'll give that a go. I think most people use the 2012 version, is there an option to save as 2010 version ? that would be very helpful. I found how to edit the solution file to make the 2012 load into 2010.
Made in England

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #6 on: January 14, 2015, 16:40:43 pm »
Which version of CamBam.exe are you using ? I'm getting an error about "Needs a later version of .NET framework than the one specified in the project"
Made in England

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Re: Custom scripts plugin
« Reply #7 on: January 14, 2015, 16:49:05 pm »
I use the version 0.9.8N.

I can open the solution project without editing on VS 2010 and not get any error.

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #8 on: January 14, 2015, 16:53:27 pm »
Yes I can open the file without any errors, it's when I go to 'Build' that the problems start.

Im using version P so I'll get version N.
Also I'm using a 64 bit win7 version of studio 2010 does that make a difference ?
« Last Edit: January 14, 2015, 16:56:10 pm by EddyCurrent »
Made in England

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 4743
    • View Profile
Re: Custom scripts plugin
« Reply #9 on: January 14, 2015, 17:00:59 pm »
Hooray, I changed to 'Expert Setting' and it worked, excellent, now to have a play, thanks for your assistance much appreciated.
Made in England

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6494
    • View Profile
    • Cambam V1.0 French Doc
Re: Custom scripts plugin
« Reply #10 on: January 14, 2015, 17:55:10 pm »
Hello,

Fine, I like this plugin  :D

Thanks

++
David

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 8452
    • View Profile
Re: Custom scripts plugin
« Reply #11 on: January 14, 2015, 19:26:12 pm »
I had to set up the references and change the .NET Framework version.

Then I had a successful build. 

However, even after confirming that I put the correct .dll in the plugins folder, it does not "register" with CamBam (the custom scripts tab does not show up in the scripts menu).

I'm using VS2010 Express, and I get no errors or warnings when building the project.

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

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6494
    • View Profile
    • Cambam V1.0 French Doc
Re: Custom scripts plugin
« Reply #12 on: January 14, 2015, 19:40:59 pm »
Hello,

I get a little error, that appears ONLY if a CB file is launched with it's icon (project icon).

I get the following Warning: "Il existe une erreur dans le fichier .XML (0, 0)." (there is an error in the XML file (0,0)"

If I remove the plugin, the error disappear
 
++
David

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Re: Custom scripts plugin
« Reply #13 on: January 14, 2015, 20:17:19 pm »
Hello,

I get a little error, that appears ONLY if a CB file is launched with it's icon (project icon).

I get the following Warning: "Il existe une erreur dans le fichier .XML (0, 0)." (there is an error in the XML file (0,0)"

If I remove the plugin, the error disappear
 
++
David

Sorry, but I didn't tested that.

I will test.

Thanks,
Vasco

Offline BaNoBi

  • Droid
  • **
  • Posts: 51
    • View Profile
Re: Custom scripts plugin
« Reply #14 on: January 14, 2015, 21:32:50 pm »
Change log
===================
v1.0
 - Initial version

v1.1
 - Resolved problem with load xml when open CamBam from project file;
 - Owner inputbox has changed to the inputbox of the CamBam.

Plugin and source code on first post.