This shows you the differences between two versions of the page.
|
developer:scriptsamples:rhinoscriptplugin [2012/04/25] dale |
developer:scriptsamples:rhinoscriptplugin [2012/05/14] (current) dale |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Create a RhinoScript Plug-in ====== | ||
| + | > **Developer:** //[[developer:rhinoscript|RhinoScript]]// | ||
| + | > **Summary:** //Demonstrates how create a RhinoScript plug-in for Rhino 5.0.// | ||
| + | ===== Prerequisites ===== | ||
| + | Before beginning, download and install the following applications, extensions, and plug-ins in this order: | ||
| + | |||
| + | 1.) [[http://download.rhino3d.com/Rhino/5.0/beta/download/|Rhino 5.0]] - Either 32-bit or 64-bit (or both) for testing. | ||
| + | |||
| + | 2a.) [[http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express|Microsoft Visual C# 2010 Express]] - Free tools to create .NET applications on Windows using Visual C#, or\\ | ||
| + | 2b.) [[http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express|Microsoft Visual Basic 2010 Express]] - Free tools to create .NET applications on Windows using Visual Basic. | ||
| + | |||
| + | 3.) [[http://visualstudiogallery.msdn.microsoft.com/16053049-7db2-4c9f-961a-53274ac92ace|RhinoCommon templates for Rhino 5.0]] - Visual C# and Visual Basic extensions that provides Rhino plug-in and command wizards for [[:developer:rhinocommon|RhinoCommon]] projects. | ||
| + | |||
| + | 4.) {{:developer:scriptsamples:rhinoscriptencrypter.zip|RhinoScript Encrypter}} - Rhino 5.0 plug-in that encrypts RhinoScript script files (.RVB) for use in RhinoScript plug-ins. | ||
| + | |||
| + | 5a.) {{:developer:scriptsamples:rhinoscriptcommandcs.zip|RhinoScript C# Command}} - Note, this file contains C# source code required by your Visual C# plug-in project, or\\ | ||
| + | 5b.) {{:developer:scriptsamples:rhinoscriptcommandvb.zip|RhinoScript VB.NET Command}} - Note, this file contains VB.NET source code required by your Visual Basic plug-in project. | ||
| + | |||
| + | ===== Preparing Scripts ===== | ||
| + | Before your RhinoScript files can be used in a RhinoScript plug-in, make sure that your script does not "run" when the script file is loaded. More specifically, when your script file is loaded with the **LoadScript** command, your script should not run - you should have to use the **RunScript** file to run your script. | ||
| + | |||
| + | For example, consider a script file that contains the following: | ||
| + | |||
| + | <code vb> | ||
| + | Option Explicit | ||
| + | |||
| + | Call HelloWorld | ||
| + | |||
| + | Sub HelloWorld | ||
| + | MsgBox "Hello World!" | ||
| + | End Sub | ||
| + | </code> | ||
| + | |||
| + | If you were to use the **LoadScript** command to load this file, the script would loaded into VBScript, defining the //HelloWorld// procedure. But because of the "Call HelloWorld" statement, the procedure would then be executed immediately after loading. | ||
| + | |||
| + | A script file that is compatible with a RhinoScript plug-in should look like this: | ||
| + | |||
| + | <code vb> | ||
| + | Option Explicit | ||
| + | |||
| + | Sub HelloWorld | ||
| + | MsgBox "Hello World!" | ||
| + | End Sub | ||
| + | </code> | ||
| + | |||
| + | If you were to use the **LoadScript** command to load this file, the script file would loaded into VBScript, defining the //HelloWorld// procedure. But in order to run the //HelloWorld// procedure, you would need to run the **RunScript** command. | ||
| + | |||
| + | For more information on loading and running scripts, see the [[http://www.rhino3d.com/5/rhinoscript/index.html|Introduction]] section of the RhinoScript help file, or [[:developer:scriptsamples:scriptloading|Efficient Loading of Scripts]]. | ||
| + | |||
| + | ===== Watch the Video ===== | ||
| + | [[http://vimeo.com/41879788|How to Create a RhinoScript Plug-In in C# for Rhino 5.0]] | ||
| + | |||
| + | \\ | ||
| + | |||
| + | {{tag>Developer RhinoScript}} | ||