Onshape Tackles Repetitive Tasks with FeatureScript


With the Hex Fill FeatureScript, you can populate the inside of a solid part of hex patterns. Shown here is the first step -- projecting the hex pattern onto the designated surface. With OnShape’s Hex Fill FeatureScript, you can populate the inside of a solid part with hex patterns. Shown here is the first step—projecting the 2D hex pattern onto the designated surface.

Onshape FeatureScript for hex fill results A hex-filled hallow part, created using Onshape’s Hex Fill FeatureScript. The top part has been deliberately removed to reveal the inside.

Onshape FeatureScript for screw bosses The FeatureScript for placing screw bosses also lets you customize the look and character of the standard feature through a dialog box.

CAD modeling is where product designers express their creativity using splines, surfaces, and solid geometry. But the process also involves lots of repetitive tasks. Standard mechanical features like rounded corners, chamfered edges, aligned holes, screw bosses, and snap hooks are not difficult to model, but incredibly time-consuming. Most CAD software let you add rounded corners and chamfered edges with one or two clicks. But gears, bosses, and hooks have too many different configurations and cannot always be created with a few clicks.

Onshape, the browser-based parametric CAD program, recently introduced a series of FeatureScripts, which let you create and place common mechanical features using templates and macros. Users can select and load the desired scripts from a catalog, available from within the Onshape modeling environment. The current lineup includes scripts developed by Onshape and those submitted by users. Scripts to build Spur Gear, Lap Joint, Wave Spring, and Snap Hook come from the Onshape staff; scripts to create Laser Joint, End Flange, Pocket Holes, and Parametric Curve come from the Onshape community.

Onshape writes, “FeatureScript is a new programming language that lets you create new features that look, feel and behave just like Onshape’s built-in features. It’s the same language used by Onshape’s development team, that’s now available to you.”

With the Spur Gear script, you create a generic gear as your starting point, then configure it to your specific needs by specifying its diameter, number of teeth, plate thickness, and other characteristics. This template-driven approach is much more efficient then the conventional way to sketching a 2D profile and extruding, especially since you’ll most likely need to create a fair number of them in different styles for your assembly.

With Screw Boss and Snap Hook scripts, you use the Sketch tools to define the spots where you’d like to place these features. Then you activate the script to populate the designated surface with the features. Variables like height, diameter, and number of ribs can be adjusted through a dialog box.

The Hex Fill script is designed to turn a solid into a hallowed part, then fill the inside with rows of hexagons. This approach could help you create lighter parts by replacing solid pieces with hex-filled parts with sufficient structural strength, especially in 3D printing projects. (The Hex Fill script took me a few tries and some help from the Onshape forum to master. I learned that making a mistake with the input for wall thickness or forgetting to uncheck the hex pattern preview could prevent this script from running smoothly.)

Some commonly used mechanical elements cannot be reduced to a button on a menu. But they follow well-defined construction formulas, and could be distilled in macros and templates. FeatureScript is an example of this strategy. You can easily load the FeatureScripts when needed, put them use, then remove them from the software’s menu; therefore, you can keep the modeling space uncluttered.

Opening FeatureScript to the user community is prudent. Overtime, the library is expected grow, driven by submissions from Onshape users with a knack for building macros or programming knowhow. This enriches Onshape’s feature set in ways that its internal staff alone cannot do.

For more, check out video report below:

Share This Article

Subscribe to our FREE magazine, FREE email newsletters or both!

Join over 90,000 engineering professionals who get fresh engineering news as soon as it is published.




About the Author

Kenneth Wong's avatar
Kenneth Wong

Kenneth Wong is Digital Engineering’s resident blogger and senior editor. Email him at kennethwong@digitaleng.news or share your thoughts on this article at digitaleng.news/facebook.

      Follow DE
#20182