CREATING A FEATURESCRIPT FEATURE IN 90 SECONDS
By Cody Armstrong / June 6, 2016 at 11:00 AM
Creating a new custom feature using FeatureScript is easy. There are no software development kits to download, and no IDEs to install. To get started, simply click “Create Feature Studio” in the Create tab menu.
Your FeatureScript code resides in a tab in your Onshape Document called a “Feature Studio.” This is FeatureScript’s integrated development environment and it means you can write code inside your Document and use the same share and version control tools to manage revisions and collaborate
After creating your Feature Studio, you can begin to write code. The Feature Studio toolbar has a number of useful snippets. To get started, click the “New Feature” icon and it will add the code snippet to build your feature.
There are two main pieces to a FeatureScript feature:
- The user interface, where preconditions and parameters of your feature are defined; and
- The functions action, which defines the formula for how your feature regenerates.
For this example, we’ll add a length parameter snippet to the user interface and a cylinder snippet for the functions action. Then, we’ll set the depth of the cylinder equal to the length parameter and we are ready to use our feature!
To use your custom feature, click the “Custom features in this workspace” icon in the far right of the toolbar. Then select your feature.
Congratulations, you have built your first custom CAD feature!
For a more detailed walkthrough of this example, watch the video above. To learn more about FeatureScript, check out the documentation and tutorials.