Jump to content


Photo
- - - - -

[Discuss] Scripting Sandbox (RCF Plugin)


  • Please log in to reply
14 replies to this topic

#1 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 06 December 2010 - 01:42 PM

*
POPULAR

Posted Image


Name: Scripting Sandbox (RCF Plugin)
Submitter: vugie
Submitted: 06 Dec 2010
File Updated: 03 Jan 2011
Category: VI Scripting
LabVIEW Version: 8.2
License Type: BSD (Most common)

Scripting Sandbox RCF Plugin
Copyright © 20010, Wojciech Golebiowski (vugie)
All rights reserved.

Author: Wojciech Golebiowski (w_golebiowski (at) tlen [dot] pl)
Name: Scripting Sandbox
Type: Right Click Framework Plugin
LabVIEW version: 8.2

Description
Scripting Sandbox is a simple Right-Click-Framework plugin for quick creating and using of flexible scripting VI's without implementing additional RCF plugin. In other words it's a plugin for making plugins which you don't want to distribute, but rather to use internally for work automation in quick and dirty way without any error handling etc. You simply define a directory for storing so called SandScript VIs. RCF menu is being updated according to the content of this directory. SandScript VI has to follow provided template. When you invoke certain script, RCF simply passes whole current "Active VI" cluster to it (VI state, panel and diagram references, array with selected objects and mouse position)

Installation
Preferably use VIP package and VI Package Manager. Alternatively download ZIP, extract to \resource\JKI\RCF\Plugins\ and restart RCF

Examples
Few example SandScript VIs are included in Scripts subdirectory. To see them working, copy them to your scripts directory (defined within RCF plugin options)

Support
If you have any problems with this code or want to suggest features:
please go to lavag.org and Navigate to LAVA > Resources > Code Repository (Certified) and
search for the "Scripting Sandbox" support page.

Version History
1.0.0:
Initial release of the code.
1.0.0.3: Not savable SandScript VI bug fixed
1.0.0.4: Some docs updated

License (BSD)
Copyright © 2010 Wojciech Golebiowski
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Click here to download this file
  • GregSands, Antoine Châlons, jcarmody and 1 other like this

#2 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 06 December 2010 - 02:53 PM

I wonder who clicked green "+" without even downloading the code... (download counter is still 0).
Anyway, whoever did it, thank you :)

#3 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 856 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2013
  • Since:2007

Posted 06 December 2010 - 04:31 PM

Wasn't me, but I've seen descriptions that were cool enough in themselves to warrant a rep point.

You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

 


#4 Antoine Châlons

Antoine Châlons

    The 500 club

  • Members
  • PipPipPipPipPip
  • 608 posts
  • Version:LabVIEW 2012
  • Since:1999

Posted 07 December 2010 - 10:17 AM

I wonder who clicked green "+" without even downloading the code... (download counter is still 0).
Anyway, whoever did it, thank you :)


It maybe because the person first downloaded it from NI community and then rated it here on LAVA... just a wild guess ;)

The RCF Plugin is really cool vugie!
One thing that bugs me a little though is that when I create a new plugin by using the context menu option "New Sandbox VI" the VI generated is in the JKI.LV.Extentions context and therefore not savable... wouldn't it be easier to place the new plugin in the main application context?

I guess it is possible to choose the context in which you create a VI, but I was wandering how do you create your own context programmatically?

TiTou.png


#5 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 07 December 2010 - 10:45 AM

One thing that bugs me a little though is that when I create a new plugin by using the context menu option "New Sandbox VI" the VI generated is in the JKI.LV.Extentions context and therefore not savable... wouldn't it be easier to place the new plugin in the main application context?

I guess it is possible to choose the context in which you create a VI, but I was wandering how do you create your own context programmatically?


Strange, I have no problems with saving VIs created that way. I have never dive deep into context related issues. I remember that there were some problems with RCF's context.
Any suggestions what should I wire to Application input of "New VI" block? Now there is a This Application constant.

#6 Antoine Châlons

Antoine Châlons

    The 500 club

  • Members
  • PipPipPipPipPip
  • 608 posts
  • Version:LabVIEW 2012
  • Since:1999

Posted 07 December 2010 - 11:09 AM

Strange, I have no problems with saving VIs created that way. I have never dive deep into context related issues. I remember that there were some problems with RCF's context.
Any suggestions what should I wire to Application input of "New VI" block? Now there is a This Application constant.


Hmmm... this is weird indeed, I have only tried in LV 8.6 and I can't save the new sandbox VI...

I think the best way is to use the "main application context" because my experience is that working into other "hidden" context creates problems (like the VI is not runable but you can't have the error list, etc...) I'm not sure what's the best way to get this context's ref though...

Here's my first sandbox plugin "Horizontal align and distribute nodes" (saved in LV 8.6) it's quick and dirty but I'm happy with it and it took me about 10 minutes to make it... If I had tried to make a proper RCF for that I would have given up before the end.
And this is why the scripting sandbox is really cool! great job :thumbup1:

Attached Files


TiTou.png


#7 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 07 December 2010 - 03:58 PM

I'm not sure what's the best way to get this context's ref though...

Will the default app instance work?

You can pull an app instance from a VI ref, but from inside the RCF I expect it would return the JKI.LV.Extensions context.

Attached Thumbnails

  • default-app-instance.png


#8 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 07 December 2010 - 04:30 PM

Will the default app instance work?

You can pull an app instance from a VI ref, but from inside the RCF I expect it would return the JKI.LV.Extensions context.


Thanks, asbo.

Antoine, try to replace following VI: [fix is now integrated in latest build]
However in my environment plugin VIs report to work in Main Application Instance...

#9 Antoine Châlons

Antoine Châlons

    The 500 club

  • Members
  • PipPipPipPipPip
  • 608 posts
  • Version:LabVIEW 2012
  • Since:1999

Posted 08 December 2010 - 08:10 AM

Thanks, asbo.

Antoine, try to replace following VI: LINK (what &^%$ is with uploading?!)
However in my environment plugin VIs report to work in Main Application Instance...


cool, works great !

TiTou.png


#10 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 08 December 2010 - 08:48 AM

cool, works great !


Good. I integrated the fix in new build.

#11 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 27 December 2010 - 12:58 PM

I added documentation for script template (as BD comments).

Does anyone know how to set default directory for save dialog? Just for convenience when creating new script - dialog would automatically point to scripts directory.

#12 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,604 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 27 December 2010 - 01:36 PM

I added documentation for script template (as BD comments).

Does anyone know how to set default directory for save dialog? Just for convenience when creating new script - dialog would automatically point to scripts directory.


The Dialog Express VI has a start path.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.lvs-tools.co.uk.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!


#13 vugie

vugie

    Extremely Active

  • Premium Member
  • 381 posts
  • Location:Warsaw, Poland
  • Version:LabVIEW 2009
  • Since:2006

Posted 27 December 2010 - 01:58 PM

The Dialog Express VI has a start path.


I didn't explain it well...
From the start. Sandbox has defined "scripts" directory which is scanned to find installed scripts (by script I mean a VI where Active VI data is passed to). There is "New Sandbox VI" option which automatically creates new script from the template. It is a new unsaved VI, just like after clicking vit file. After creating the script you want to save it, but by default save dialog starts at directory of previously saved VI (or sth like this). So you have to remember where your scripts directory is and search for it. It may be a pain when it is located somewhere deep, so it is in conflict with "quick&dirty" paradigm of Scripting Sandbox.
Summarizing, I'm programatically creating new VI for edit and I want to have specified directory in save dialog when user presses Ctrl-S

#14 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,604 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 27 December 2010 - 02:20 PM

I didn't explain it well...
From the start. Sandbox has defined "scripts" directory which is scanned to find installed scripts (by script I mean a VI where Active VI data is passed to). There is "New Sandbox VI" option which automatically creates new script from the template. It is a new unsaved VI, just like after clicking vit file. After creating the script you want to save it, but by default save dialog starts at directory of previously saved VI (or sth like this). So you have to remember where your scripts directory is and search for it. It may be a pain when it is located somewhere deep, so it is in conflict with "quick&dirty" paradigm of Scripting Sandbox.
Summarizing, I'm programatically creating new VI for edit and I want to have specified directory in save dialog when user presses Ctrl-S

IC (I think Posted Image)

If you don't mind being platform dependent then you can use the windows SetCurrentDirectory function (LV example here). But your scripting thingy would still have to be running after they decided to save it. Other than that, I only think if saving a dummy VI after they have saved theirs (again your thingy needs to be running to monitor the memory list).
But if your going the platform specific route I would suggest adding it to the places bar so they can always find it easily.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.lvs-tools.co.uk.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!


#15 Mark Balla

Mark Balla

    The 500 club

  • Premium Member
  • 506 posts
  • Location:Gurnee Illinois
  • Version:LabVIEW 2013
  • Since:1997

Posted 15 September 2011 - 02:43 PM

Certified 9-15-2011 Placed in VI Scripting