Compost4 Scripting: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
==Accessing Documents== | ==Accessing Documents== | ||
Compost currently supports 4 types of documents, POST, GCODE, PYTHON, and TXT. Each of these document types has a common set of text editing functions as well as a number of document specific attributes. | Compost currently supports 4 types of documents, POST, GCODE, PYTHON, and TXT. Each of these document types has a common set of text editing functions as well as a number of document specific attributes. | ||
| Line 73: | Line 15: | ||
While Compost4 is a good editor for it's own Python scripts it can be somewhat tricky to know all the things that can be done with the various objects in Scripting. We are working on a feature that will let Compost4 show the user what script commands,functions, and objects are available using online help and auto-complete but that feature will take some time. | While Compost4 is a good editor for it's own Python scripts it can be somewhat tricky to know all the things that can be done with the various objects in Scripting. We are working on a feature that will let Compost4 show the user what script commands,functions, and objects are available using online help and auto-complete but that feature will take some time. | ||
Until we finish this feature it is possible to use the free version of Visual C# to inspect the ScriptAPI object in order to know what functions can | Until we finish this feature it is possible to use the free version of Visual C# to inspect the ScriptAPI object in order to know what functions can be accessed. | ||
The free version of Visual C# can be found here. | |||
http://www.visualstudio.com/downloads/download-visual-studio-vs | |||
Once you have it installed get and open the sample plugin file from the Post SVN | |||
https://svn.gibbscam.com/svn/post_dev/compost4/Samples/Plugins/SampleCompostPlugin/ | |||
While you do not need to do anything specific with the plug-in, it is a simple way to access the object browser and view the contents of the Compost4 Assembly file. | |||
Open the "references" section in the Solution list. Double click the "Compost4" item to open the Object Browser. Then simply scroll down to the "ComPost4.Scripting" Namespace and find the "ScriptAPI" object. | |||
This object will show you all of the functions and methods that are available for use. Some functions will return references to other objects and you can use the object browser to locate information on them as well. | |||
[[Category:Articles]] | [[Category:Articles]] | ||
Revision as of 02:02, 8 March 2014
Accessing Documents
Compost currently supports 4 types of documents, POST, GCODE, PYTHON, and TXT. Each of these document types has a common set of text editing functions as well as a number of document specific attributes.
The API class allows scripts to access any open document and make modifications to it. Some utility functions are provided for some of the more complicated document types (POST)
- ScriptAPI.API.CurrentDocument contains a class that represents the current document, this can be any of the document types that Compost Supports
- ScriptAPI.API.OpenDocuments contains a the list of document classes that are currently open
- ScriptAPI.API.CurrentDocTextArea() will return the text editor class for the current document, this includes things such as the current text selection
- ScriptAPI.API.CurrentForm() will return the form data for the current document if it is a POST
- ScriptAPI.API.CurrentMachDef() will return the MDD data for the current document if it is a POST
- ScriptAPI.API.GetCurrentProgWindow().GetProgText() will return the Prog data for the current document if it is a POST
Using Visual Studio for online help
While Compost4 is a good editor for it's own Python scripts it can be somewhat tricky to know all the things that can be done with the various objects in Scripting. We are working on a feature that will let Compost4 show the user what script commands,functions, and objects are available using online help and auto-complete but that feature will take some time.
Until we finish this feature it is possible to use the free version of Visual C# to inspect the ScriptAPI object in order to know what functions can be accessed.
The free version of Visual C# can be found here. http://www.visualstudio.com/downloads/download-visual-studio-vs
Once you have it installed get and open the sample plugin file from the Post SVN https://svn.gibbscam.com/svn/post_dev/compost4/Samples/Plugins/SampleCompostPlugin/
While you do not need to do anything specific with the plug-in, it is a simple way to access the object browser and view the contents of the Compost4 Assembly file.
Open the "references" section in the Solution list. Double click the "Compost4" item to open the Object Browser. Then simply scroll down to the "ComPost4.Scripting" Namespace and find the "ScriptAPI" object.
This object will show you all of the functions and methods that are available for use. Some functions will return references to other objects and you can use the object browser to locate information on them as well.