Difference between revisions of "Scripting"
Wirecadadmin (Talk | contribs) |
Wirecadadmin (Talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
|desc=Scripting allows an easy way to access the WireCAD SDK object model to perform custom actions}} | |desc=Scripting allows an easy way to access the WireCAD SDK object model to perform custom actions}} | ||
− | + | {{warning|This function is still under development and as such is subject to change without notice.}} | |
− | + | ||
− | == Usage == | + | === What you Need to Know === |
+ | You will need a little knowledge of the c# programming language but the editor will provide hints. | ||
+ | |||
+ | === Usage === | ||
Currently there are no menu commands for the scripting engine. You must type the commandline shortcut script in order to launch the tool. | Currently there are no menu commands for the scripting engine. You must type the commandline shortcut script in order to launch the tool. | ||
[[File:Scripts1.png|thumb|Scripts Form]] | [[File:Scripts1.png|thumb|Scripts Form]] | ||
Line 16: | Line 18: | ||
The editor provides hints as you to type you don't necessarily have to know the object model. You can explore by typing ws. and follow the hints. | The editor provides hints as you to type you don't necessarily have to know the object model. You can explore by typing ws. and follow the hints. | ||
− | == Example Scripts == | + | === Example Scripts === |
Example scripts can be found in the shared WireCAD6\Scripts folder. The location of this folder is different depending on OS. See this [[Knowledge_Base#Q:_Where_Does_WireCAD_Put_Files.3F|page]] for more info. | Example scripts can be found in the shared WireCAD6\Scripts folder. The location of this folder is different depending on OS. See this [[Knowledge_Base#Q:_Where_Does_WireCAD_Put_Files.3F|page]] for more info. | ||
− | == Opening Scripts == | + | === Opening Scripts === |
To open an existing script click File>Open and browse to the *.cs file of your choice. | To open an existing script click File>Open and browse to the *.cs file of your choice. | ||
{{note|WireCAD scripting follows a very specific form. Only scripts that contain a public static void Run(Workspace ws) method signature will run.}} | {{note|WireCAD scripting follows a very specific form. Only scripts that contain a public static void Run(Workspace ws) method signature will run.}} | ||
− | == Saving Scripts == | + | === Saving Scripts === |
To save a script click File>Save. | To save a script click File>Save. | ||
− | == Running Scripts == | + | === Running Scripts === |
Click the Run icon on the Run toolbar. | Click the Run icon on the Run toolbar. | ||
− | == What to Expect in the Messages Window == | + | === What to Expect in the Messages Window === |
When you click Run your script is first compiled. If there are any errors during this process these will be displayed here. | When you click Run your script is first compiled. If there are any errors during this process these will be displayed here. | ||
If your script compiles with no errors the script is then executed.[[File:Scripts2.png|thumb|Script Execution Example]] | If your script compiles with no errors the script is then executed.[[File:Scripts2.png|thumb|Script Execution Example]] | ||
+ | |||
+ | |||
+ | ==FAQ== | ||
+ | ===Q: What can I do with scripts?=== | ||
+ | A: Scripts are good for automating repetitive tasks. Take a look at some of the examples (see above) for some ideas. We will be adding more examples as we go. | ||
+ | |||
+ | ===Q: I don't understand the cryptic compiler errors. Where can I find more info?=== | ||
+ | A: Google the error. There is tons of stuff out there on c#. | ||
+ | |||
+ | ===Q: I just ran a script that blew up my data. What do I do now?=== | ||
+ | A: You are on your own here. With great power comes great responsibility. | ||
+ | |||
+ | ===Q: I need help automating my drawing creation. Is there an example script for this?=== | ||
+ | A: Yes we have added a script just for this in the 6.1.0.1622 build. |
Latest revision as of 17:30, 11 October 2011
Command Line Shortcut: script User Permissions Level: various |
Warning: This function is still under development and as such is subject to change without notice. |
Contents
What you Need to Know
You will need a little knowledge of the c# programming language but the editor will provide hints.
Usage
Currently there are no menu commands for the scripting engine. You must type the commandline shortcut script in order to launch the tool.
Once launched scripting provides one method Run for you. Through this you have access to the WireCAD Workspace object. The Workspace object provides access to most of the WireCAD object model. From Workspace you can access the ActiveDrawing, DataAccess, MainForm and many other objects.
The editor provides hints as you to type you don't necessarily have to know the object model. You can explore by typing ws. and follow the hints.
Example Scripts
Example scripts can be found in the shared WireCAD6\Scripts folder. The location of this folder is different depending on OS. See this page for more info.
Opening Scripts
To open an existing script click File>Open and browse to the *.cs file of your choice.
Note: WireCAD scripting follows a very specific form. Only scripts that contain a public static void Run(Workspace ws) method signature will run. |
Saving Scripts
To save a script click File>Save.
Running Scripts
Click the Run icon on the Run toolbar.
What to Expect in the Messages Window
When you click Run your script is first compiled. If there are any errors during this process these will be displayed here.
If your script compiles with no errors the script is then executed.
FAQ
Q: What can I do with scripts?
A: Scripts are good for automating repetitive tasks. Take a look at some of the examples (see above) for some ideas. We will be adding more examples as we go.
Q: I don't understand the cryptic compiler errors. Where can I find more info?
A: Google the error. There is tons of stuff out there on c#.
Q: I just ran a script that blew up my data. What do I do now?
A: You are on your own here. With great power comes great responsibility.
Q: I need help automating my drawing creation. Is there an example script for this?
A: Yes we have added a script just for this in the 6.1.0.1622 build.