<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel><title>SmartBench Software Blog</title><link>https://www.smartbenchsoftware.com/blog/</link><description>Experts in Onshape Automation</description><language>en</language>
<atom:link href="https://www.smartbenchsoftware.com/blog-feed.xml" rel="self" type="application/rss+xml"/>
<item><title>A Guide to FeatureScript Inputs</title><link>https://www.smartbenchsoftware.com/post/a-guide-to-featurescript-inputs/</link><guid>https://www.smartbenchsoftware.com/post/a-guide-to-featurescript-inputs/</guid><pubDate>Tue, 26 May 2026 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Developing a custom feature in Onshape starts by answering 2 basic questions: what is the input, and what&#x27;s the output? The output is usually pretty easy to answer, the feature…</description><content:encoded><![CDATA[<p>Developing a custom feature in Onshape starts by answering 2 basic questions: what is the input, and what's the output? The output is usually pretty easy to answer, the feature needs to make some geometry. Designing the inputs for a custom feature takes a lot of experience and experimentation. A balance between holding the hand of the user and giving them flexibility.</p>
<p>Knowing what FeatureScript supports can help designers discuss with developers their requirements to make super useful features. This is a guide of all the possible inputs for Onshape Custom Features. </p>
<h2>Dimensions</h2>
<p>The most common inputs - dimensions. </p>
<h3>Length</h3>
<p>Length inputs are one of the most common. They accept inputs of any linear units or equations. On the back end you can set a minimum, default, and maximum value. Defaults can set dependent on the user's units.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_673047b27f3c4deab3ccb9ddeede9181.png" alt="" loading="lazy"></figure>
<h3>Angle</h3>
<p>Same as a length input, but for angular inputs.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_afab53d59eb9439680131aacf9c17629.png" alt="" loading="lazy"></figure>
<h3>Count</h3>
<p>The count input accepts only integer number inputs. Same as the length input, it also has a minimum, maximum, and default value.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_17d75c7713ca4766b71f6030492a25da.png" alt="" loading="lazy"></figure>
<h3>Real Numbers</h3>
<p>Similar to the Count parameter, with the exception that it accepts real value inputs. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3a9075cb089a41f598bc7345570a70c8.png" alt="" loading="lazy"></figure>
<h3>Queries</h3>
<p>Queries (or selections) are the input method for geometry input. Queries support vertices, edges, faces, or bodies. Queries can be limited by the number or types of selections. Selections can be limited to geometry types, such as only planar faces, only circular edges, or solid bodies. Query selection restriction is important to ensure that users not only select only valid geometry, but also to make the selections easier to make.</p>
<p>Selected items are highlighted in Orange.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_062697fe3243417eb80b9ed04dd136ba.png" alt="" loading="lazy"></figure>
<p>Mate connector creation can be supported if the required option is included.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f1af0335cb8c4d0087e34bd2b37d1f84.png" alt="" loading="lazy"></figure>
<h3>Boolean</h3>
<p>Booleans generally show up as checkboxes with a true or false state. With some UI Hints, they can be made to look like flip arrows.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_41785bcdbf21411c846fa9f6b6cb76e7.png" alt="" loading="lazy"></figure>
<h3>String</h3>
<p>Free text input. Useful for text features, metadata setting (such as names), or some weird work around.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_e82ddd6391884b2e8cab6e59db13568c.png" alt="" loading="lazy"></figure>
<h3>Enums</h3>
<p>Enums are a list of predefined options. Enums cannot be created at runtime and must be a predefined list. Typically appearing as a drop down menu, but they can also be made into a horizontal tab style item like in the extrude feature. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_a0596fc3e2624943878ad9db5f5227f5.png" alt="" loading="lazy"></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_35cd5ae506054a9ba1c7df04b76d7470.png" alt="" loading="lazy"></figure>
<h3>Lookup Tables</h3>
<p>Look up tables are a combination of options where the previous selects modify the next possible options. Visible in the standard hole feature, selecting hole type will change what sizes and options become available. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3e237adac2904d75a2b598d0b0de125d.png" alt="" loading="lazy"></figure>
<h3>Anything</h3>
<p>The "Anything" type is a grab bag parameter that allows any data type for input. Typically used as a hidden parameter for solving other automation challenges such as passing data from editing logic to the main feature body.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_8a9cfe2c03b34df3ae13e5e61e8b2bcc.png" alt="" loading="lazy"></figure>
<h3>Parameter Arrays</h3>
<p>Arrays of parameters act as repeatable groups of inputs. Useful when a feature makes multiple unique operations. Array parameters can be a trap for feature complexity, its always important to consider if the functionality should exist in a single feature as an array input, or as individual features in the feature tree.</p>
<p>Parameter arrays cannot be nested, and the length of the list can be fixed (removing the "add Widget" button).</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_7950d51405c947878d02a31f5d9c1de1.png" alt="" loading="lazy"></figure>
<h3>Selection Driven Arrays</h3>
<p>Similar to a parameter array, a query is used to drive the items of the array. Each selection becomes a new item in the array.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_71d1e7e3bff442bda203bd5a9a17d911.png" alt="" loading="lazy"></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9e1bc246a1eb4ac5b64d5dc7598ffdfa.png" alt="" loading="lazy"></figure>
<h3>Feature Lists</h3>
<p>The feature list allows selection of features from earlier in the feature tree. Pretty much only useful to either pattern or evaluate geometry created/modified by those features. The definitions of those features cannot be read.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_849e962111f944538cc3fab611e33575.png" alt="" loading="lazy"></figure>
<h3>Reference Parameters (Part studio, image, CSV, JSON)</h3>
<p>Reference parameters allow the selection of outside part studios or imported files. Selected files need to be already imported into Onshape and cannot be directly imported in a feature input.</p>
<p>Referenced part studios do have limited use. The part studio can be derived into the current part studio, useful for "templating" or standardizing design elements. The referenced part studio can't be modified from this feature, effectively read only with the only options to modify being the configuration input.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_cc6c328f5b234f22b852017f1a788e81.png" alt="" loading="lazy"></figure>
<h3>Parameter groups</h3>
<p>Parameter groups are used to compact sections of a FeatureScript UI. As features grow in complexity, one challenge is simply organizing the inputs. A combination of editing logic and enums can also achieve similar results, but parameter groups are the simplest. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_cff95864570e4237a663c9bf6a51c139.gif" alt="" loading="lazy"></figure>
<h3>Buttons</h3>
<p>Buttons can be seen in the routing curve feature. While buttons have no parametric value, they are used with editing logic to create unique input workflows. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f1c29ee998c742d386c0b1b392c46d2f.png" alt="" loading="lazy"></figure>
<h2>UIHints</h2>
<p>Each individual parameter in a FeatureScript can have additional options to modify their behaviour or appearance.</p>
<p>For example, the flip direction input seen in the extrude feature is just a boolean with the Opposite Direction option enabled. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_4aec1602c4014548b8842f343326fad4.png" alt="" loading="lazy"></figure>
<p>There are currently 38 different UIHints:</p>
<p>OPPOSITE_DIRECTION, ALWAYS_HIDDEN, SHOW_CREATE_SELECTION, CONTROL_VISIBILITY, NO_PREVIEW_PROVIDED, REMEMBER_PREVIOUS_VALUE, DISPLAY_SHORT, ALLOW_FEATURE_SELECTION, MATE_CONNECTOR_AXIS_TYPE, PRIMARY_AXIS, SHOW_EXPRESSION, OPPOSITE_DIRECTION_CIRCULAR, SHOW_LABEL, HORIZONTAL_ENUM, UNCONFIGURABLE, MATCH_LAST_ARRAY_ITEM, COLLAPSE_ARRAY_ITEMS, INITIAL_FOCUS_ON_EDIT, INITIAL_FOCUS, DISPLAY_CURRENT_VALUE_ONLY, READ_ONLY, PREVENT_CREATING_NEW_MATE_CONNECTORS, FIRST_IN_ROW, ALLOW_QUERY_ORDER, PREVENT_ARRAY_REORDER, VARIABLE_NAME, FOCUS_INNER_QUERY, SHOW_TOLERANCE, ALLOW_ARRAY_FOCUS, SHOW_INLINE_CONFIG_INPUTS, FOCUS_ON_VISIBLE, CAN_BE_TOLERANT, CAN_BE_TOLERANT_DIAMETER, PLUS_MINUS, ALWAYS_USE_DEPENDENCIES, NO_QUERY_VARIABLE, ALLOW_FLAT_SKETCH_SELECTION, QUERY_VARIABLE_NAME, HIDE_LABEL</p>
<p>I most commonly use the Always Hidden, Opposite Direction, and Read Only options.</p>
<h3>Dynamic Feature Names</h3>
<p>Feature names can be set in the body of the feature to allow for intelligently named features. No more "My Feature 6"adding confusion to the design process.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_b9cdc22a2cdf40a48716e0d2d47b5c89.png" alt="" loading="lazy"></figure>
<h2>Feature Errors</h2>
<p>Errors in the feature can be reported to the user in a few different ways:</p>
<p><strong>Warning messages</strong></p>
<p>These messages show as a popup when the feature is opened, and colour the feature red in the feature tree.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_17ec87d65f2042b488d6418d31954f08.png" alt="" loading="lazy"></figure>
<p>They also come in an information level that appears without the feature tree colouring.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_79602e5e506f4dff8ec739272666bcb1.png" alt="" loading="lazy"></figure>
<p>Its also possible to highligh which entities and parameters are causing specific problems.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_5e3492e6e2e342b7b3824b61dd70980f.png" alt="" loading="lazy"></figure>
<h2>Editing Logic</h2>
<p>The main body of a feature is the code that runs after selections are made. There is no "stopping" a feature for further user inputs. A user's inputs are all set at the start of the feature's logic. Editing logic is a special function used to create "intelligent" inputs for a feature. Editing logic cannot create any geometry, it can only set a feature's input.</p>
<p>In the example below, I've created a dynamically visible parameter by using editing logic to check if the length is over 30mm, and setting a hidden boolean parameter.</p>
<p>Editing logic is only triggered when a user modifies one of the inputs in the feature. Its important to note that things like configurations and the API do not trigger editing logic. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_a79da9ac6c97414487317f31ca5e17c6.gif" alt="" loading="lazy"></figure>
<h2>Manipulators</h2>
<p>Manipulators are often overlooked in the toolbox of user inputs. Most features don't require them; but they can be quality of life improvements. In some cases, manipulators can be the savior of a confusing, difficult, or just clunky feature. I really like how creative you can be with manipulators. They are a tool box of options to solve problems.</p>
<h3>Point</h3>
<p>The point manipulator returns the index of the point (from a list of points) the user selected. These are useful when the user needs to make a choice from a specific set of options. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_0118a19e2f8240a190d5316fddd13925.gif" alt="" loading="lazy"></figure>
<h3>Toggle Points</h3>
<p>Toggle points work very similarly to the point manipulator, except that the result is a list of selected points instead of a specific index.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_23ac3c9fe5fe400ea4c012232c6cb906.gif" alt="" loading="lazy"></figure>
<h3>Flip</h3>
<p>Flip manipulators are useful for allowing a user to pick a side. Automatically picking a correct side can be difficult in FeatureScript but easy for a user.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_b323ed8db7c242dbb41a5186dc5d78dc.gif" alt="" loading="lazy"></figure>
<h3>Linear</h3>
<p>One of the most commonly seen manipulators. Almost impossible to miss in features like extrude. The interesting thing about linear manipulators is that it specifies a direction and an offset. You aren't locked to the axis, it can change dynamically, so it is possible to have a linear manipulator follow along a line.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_596915fbe5784fc8bf4b8be3f72c0517.gif" alt="" loading="lazy"></figure>
<h3>Angle</h3>
<p>Specify an axis of rotation and a radius to set the manipulator arrow to.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f63d1538952c488fb5ff5eff90f03586.gif" alt="" loading="lazy"></figure>
<h3>Triad</h3>
<p>Triad manipulators are useful for allowing a user to select a specific point, or alter dimensions in a coordinate system.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9cf246c1f08d4b169159bae92f4e7044.gif" alt="" loading="lazy"></figure>
<h3>Full Triad</h3>
<p>Used to specify locations and orientation. Commonly used in spline generation or part placement.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_42bd797fa7ec4e8990532bb2ba6be3fa.gif" alt="" loading="lazy"></figure>
<p>Is this all a bit overwhelming? SmartBench Software is here to help. As experts in Onshape automation, FeatureScript, and integrated applications, we can help navigate the difficulties of automating Onshape. Reach out for more info.</p>]]></content:encoded></item><item><title>Data Driven Features</title><link>https://www.smartbenchsoftware.com/post/data-driven-features/</link><guid>https://www.smartbenchsoftware.com/post/data-driven-features/</guid><pubDate>Mon, 02 Mar 2026 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>FeatureScript is one of the defining features of Onshape that make it stand out from the rest of the CAD industry. Unlike macros, Onshape custom features are fully parametric.…</description><content:encoded><![CDATA[<p>FeatureScript is one of the defining features of Onshape that make it stand out from the rest of the CAD industry. Unlike macros, Onshape custom features are fully parametric. Updating upstream features in the tree ripple down through the rest of the design. This ensures that custom features seamlessly integrate into design workflows.</p>
<p>An opportunity this opens up is for data-driven features. Features driven by calculations rather than human input. In traditional desktop CAD, driving a design through data using something like a macro was possible - but potentially laborious. The real struggle comes from changes to the data. If something changes in a macro based process, typically it requires starting again from the beginning. FeatureScript doesn't have this issue. </p>
<p>I recently came across <a href="https://youtube.com/shorts/S62SClw70h4?si=jov--4nFqjpMqHqA">this video from youtuber Engineezy</a>, who was trying to create a mechanism that could write letters. The mechanism uses two cams to drive a linkage that draws a specific path. The shape of the path defines the profile of the two cams. Not something easy to design. His solution was to painstakingly measure sample points, and use a spread sheet to calculate the cam profile. It might be an acceptable process once, but any changes or expansion of scope can quickly add up. </p>
<p>But there's a better way! A FeatureScript can do all of the path sampling, calculations, and cam profile generation in a single step. Being fully parametric, the feature can also be configured, or have the target sketch swapped out in an instant. The simplicity in generation gives us the power to tweak and make changes to the design without causing hours of work to vanish. We could easily change the mechanism sizing or shape, positions of cams, or modify our target path.</p>
<p>In the image below, I am showing how the feature can map the "E" shape to the endpoint of the arms. That endpoint then maps to a polar coordinate around the cam shaft to generate the cam profile.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_2dbd82d498b44098a6c4f3e0e4a76bf8.png" alt="" loading="lazy"></figure>
<p>The below video isn't even sped up. Changing out the shape, recalculating the sample points, configuring the model, or changing any other driving parameter - results in instantaneous output.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_635fc0e64e8d4d9b9e5db1b4ac5885bd.gif" alt="" loading="lazy"></figure>
<p>You must be asking, is there a catch? Was this weeks of effort to automate a few hours of tedium? The opposite, this sample feature took less than 2 hours. I wouldn't consider it production ready in that time frame, but it was enough for a proof of concept. I'd expect the manual workflow to take almost the same amount of time for the first case, but every subsequent case digs a deeper hole into loss productivity. Code is great at repetitive calculation, humans are not.</p>
<p>When I hear "We're too busy to automate" - my response is that a lack of automation is why you're busy.</p>]]></content:encoded></item><item><title>Smart Part Numbers are a Trap</title><link>https://www.smartbenchsoftware.com/post/smart-part-numbers-are-a-trap/</link><guid>https://www.smartbenchsoftware.com/post/smart-part-numbers-are-a-trap/</guid><pubDate>Sun, 15 Feb 2026 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>The question that comes up time an time again is: what is the best part numbering schema? The answer is - depends on the company. But more specifically, I get asked &quot;Sequential or…</description><content:encoded><![CDATA[<p>The question that comes up time an time again is: what is the best part numbering schema? The answer is - depends on the company. But more specifically, I get asked "Sequential or Intelligent Part Numbers"</p>
<p><strong><em>In simple terms</em></strong></p>
<p>A sequential scheme is a fixed number of digits - maintained by a central database (such as Onshape, Arena, or an ERP). When a new number is required, it is assigned in the database and the "next number" is incremented.\
Example:\
1000052</p>
<p>1000053</p>
<p>1000054</p>
<p>A "Smart" part numbering system uses logic to generate part numbers. Typically by using a combination of other data. </p>
<p>Examples:\
{Project Number} - {Type} - {Subassembly} - {sequential number}\
would produce a part number like: 100-L-01-055</p>
<p>Where project numbers are sequential, but the sub assembly/sequential number are specific to the project.</p>
<p>So what's wrong with "Smart" Numbers?</p>
<h3>What is the Purpose of a Part Number?</h3>
<p>To uniquely identify parts/assemblies.</p>
<p>That's it. That is the purpose. Do <em>smart</em> numbers do that? Well, not always. Depending on the schema, by trying to do more, they cause some problems.</p>
<p><strong>Not unique</strong> - Smart schemas that use things like project IDs can end up with part numbers where a specific part that gets shared across projects ends up with many redundant numbers. The scheme works for a single project, but once a company has hundreds of projects, how do you manage it? Your CAD data will become a mess very quickly.</p>
<p><strong>CAD Data is not just for CAD</strong>  - Eventually a design needs to be manufactured. Parts need to be ordered, machined, printed, or assembled. On the previous point, if the same part is shared across projects, and has a different number in each project...how do you stock and order these common parts? A Smart part numbering scheme is usually the tip of the iceberg to bad PDM practices, and unnecessary work</p>
<p><strong>Changing Metadata changes the Part Number</strong>  - By using metadata in the part numbering, changing characteristics of a part results in a new part number, even if the actual part hasn't changed. In my above example, restructuring your design and moving a part to a different subassembly would cause the number to change.</p>
<p><strong>Support By your Stack</strong> - Some software has limits on things like Part Number length, or even character types (some system only support numeric numbers). Is your schema even compatible with your ERP/PLM, etc? What about in a future where you switch to a different one?</p>
<p>Introducing each of these challenges into your design environment have downstream effects where the problem becomes more challenging to solve. Over the years I have had a few "impossible" automation requests that trace back to weird and wacky part numbering schemes. </p>
<h3>What problems do Sequential numbers have?</h3>
<p>If companies are trying to reinvent the wheel with Smart numbers, there must be challenges they are trying to overcome.</p>
<p><strong>Friction in Generation</strong> - If you are use to managing numbers from an ERP, it can feel like a lot of friction to have to leave your CAD - open the ERP - generate a part number - go back into CAD - copy at the data back and forth. \
<strong>Solution:</strong> Onshape has part numbering built in that is a breeze to use - or you can <a href="https://www.linkedin.com/posts/caden-armstrong-39b531123_part-of-every-onshape-erp-integration-we-activity-7393656266558132224-lN2R?utm_source=share&amp;utm_medium=member_desktop&amp;rcm=ACoAAB6DJ-cBHj-Fb7o2M_Ormpr0BHb3eXYY0b0">integrate your part numbering functionality from your ERP directly into Onshape</a></p>
<p><strong>Running Out -</strong> A sequential list of numbers will eventually run out. A 4 digit part number only has 9999 possible options.</p>
<p><strong>Solution</strong>: Start with more digits. If you pick a sequential schema, start with a number of digits that is future proof. You shouldn't have to worry about typing in a few extra digits, because you shouldn't be doing manual data entry! If you're trying to pick a number, 4 digits is too few, and 14 is too many. Do some napkin math and find a number in-between.</p>
<h3>Exceptions to the Rule</h3>
<p>While I generally think that sequential part numbering is typically the less problematic, there are always exceptions. The one that comes up most often - is the lighting industry. Lighting products come in an astronomical number of configurations. Temperature, voltage, length, finish, etc. Its possible to have a single product with 20,000+ variants. Generating and maintaining part numbers for each and every combination is sometimes just not feasible. Its typical to have a top level assembly with a structure such as {Base product}-{Length}-{Temp} (etc). But the components of that assembly have a typical sequential part numbers.</p>
<p>In conclusion - there isn't one specific way of doing part numbers that is "the best". You need to pick a scheme that makes sense for your company, the technology you use, and the challenges you are trying to solve. Understand the downstream effects of those choices, and work through the various corner cases. Its extremely difficult to change once you've picked a path.</p>
<h3>Bonus - Bad Part Numbering Ideas</h3>
<p>In writing this article, I've brainstormed a few not so great alternatives to sequential and smart part numbers:</p>
<ol>
<li><a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">GUID</a> - Just generate them as needed. No need to go into a database, they are mathematically guaranteed to be unique. You think sequential part numbers are hard to read? What if they were longer and contained letters?</li>
<li>UNIX timestamp - yep, just take the current milliseconds since 1970 and set that as your part number. Benefit - you know exactly how old a part is! Its very unlikely two parts will be generated at the exact same microsecond. Its a bit like a sequential numbering system, except with 16 digits and is constantly burning part numbers.</li>
<li>STEP file in base 64 - Why not use the part geometry itself? Converting the file to a base64 string means that when you share the part number, you're also sharing the CAD data! Probably not supported by most systems, but change has to start somewhere.</li>
<li><a href="https://what3words.com/apostrophe.mandate.gushed">What3Words</a> - The concept take a list of words, and by combining 3 of them, you can make 57 trillion unique combinations. For example - ///apostrophe.mandate.gushed is the corner of "This st" and "The other st". This system applied to part numbers would make part numbers a lot easier to remember, or potentially more confusing. Definitely funnier. <em>Update -</em> <a href="https://cad.onshape.com/documents/a0e627b210f40b3429e97f9f/w/8396d6be1955ad08f9567a16/e/043f204d8ca76147c63db56e"><em>I made a demo of what this would look like</em></a></li>
</ol>]]></content:encoded></item><item><title>A Few More Undocumented FeatureScript Functions</title><link>https://www.smartbenchsoftware.com/post/a-few-more-undocumented-featurescript-functions/</link><guid>https://www.smartbenchsoftware.com/post/a-few-more-undocumented-featurescript-functions/</guid><pubDate>Tue, 06 Jan 2026 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>In my previous post Hidden FeatureScript Functions , I talk about a few hidden functions within FeatureScript and show how they can be used. I&#x27;m back with a few more examples. All…</description><content:encoded><![CDATA[<p>In my previous post <a href="https://www.smartbenchsoftware.com/post/hidden-featurescript-functions">Hidden FeatureScript Functions</a>, I talk about a few hidden functions within FeatureScript and show how they can be used. I'm back with a few more examples. All the example code can be seen <a href="https://cad.onshape.com/documents/89af99f8f0ed4e48424f59cf/w/5a6f0cafb4802384fcc79cda/e/a09c4e0da1ed1d3686adf526">here</a></p>
<p><em>Want to get the most out of Onshape? SmartBench Software can help.</em> </p>
<p><em>Visit</em> <a href="https://www.smartbenchsoftware.com/"><em>www.smartbenchsoftware.com</em></a> <em>to learn about our custom feature and integration development services.</em></p>
<h3>Construct Paths</h3>
<p>Construct Path is very useful, but what if it was even more useful?</p>
<p><strong>constructPaths</strong>(context is Context, edgesQuery is Query, options is map) returns array</p>
<table>
<thead>
<tr>
<th>edgesQuery</th>
<th>query</th>
<th>A query of edges to form into a Path</th>
</tr>
</thead>
<tbody>
<tr>
<td>options</td>
<td>map</td>
<td>a map containing the options for the construct paths</td>
</tr>
<tr>
<td>options.adjacentSeedFaces</td>
<td>(optional) query</td>
<td>If adjacent faces to the path are provided, each Path returned will include an 'adjacentFaces' property that has all faces on the same side of the path as the seed faces. If there are seed faces on both sides, constructPaths will error</td>
</tr>
</tbody>
</table>
<p>The first step to using construct paths is to import path.fs like so:</p>
<pre><code>import(path : &quot;onshape/std/path.fs&quot;, version : &quot;2837.0&quot;);
</code></pre>
<p>The difference between constructPath and constructPaths is that constructPath is expecting all of the edges to join into a single continuous path. The undocumented variant can handle multiple groups of edges that resolve into multiple paths. This can be helpful if you have a query of edges and need to separate them into multiple groups. Note that this function still does not allow for branching paths.</p>
<h3>Cosmetic Threads</h3>
<p>Cosmetic threads are something that the hole feature in Onshape can do, but you can actually add them to any cylindrical surface with the right attribute.</p>
<p>Start by importing the std utilities</p>
<pre><code>import(path : &quot;onshape/std/cosmeticThreadUtils.fs&quot;, version : &quot;2837.0&quot;);
</code></pre>
<p>Start with the function createCosmeticThreadDataFromEntitiy to generate the object.</p>
<pre><code>function createCosmeticThreadDataFromEntity(threadCoordSys is CoordSystem, tappedDepth is number, threadPitch is number)
</code></pre>
<p>Where threadCoordSys is a coordsystem starting where the thread should start, centered on the axis of the cylindrical face, with the Z direction in the direction of the threads.</p>
<p>Then use addCosmeticThreadAttribute to insert the data onto the face</p>
<pre><code>function addCosmeticThreadAttribute(context is Context,entities is Query,cosmeticThreadData is CosmeticThreadData)
</code></pre>
<p>Bringing it all together:</p>
<pre><code>
var coord = evSurfaceDefinition(context, {
                &quot;face&quot; : definition.face
        }).coordSystem;
var threadData = createCosmeticThreadDataFromEntity(coord, 10*millimeter/meter, 1*millimeter/meter);
addCosmeticThreadAttribute(context, definition.face, threadData);

</code></pre>
<p>Why am I doing millimeter/meter? Well, for some reason the cosmetic thread data is unitless and the value is forced to be in meters. Taking your value with units and dividing by meters will produce the correct result. And with that I can add cosmetic threads to any cylindrical surface. This can be useful for things like custom hydraulic port features or lids. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_6dbce22467a94f65ab7115732fdcfee1.png" alt="" loading="lazy"></figure>]]></content:encoded></item><item><title>Navigating Onshape API Limits</title><link>https://www.smartbenchsoftware.com/post/navigating-onshape-api-limits/</link><guid>https://www.smartbenchsoftware.com/post/navigating-onshape-api-limits/</guid><pubDate>Wed, 10 Dec 2025 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>This past year Onshape introduced new API limits. Previously Onshape always had some kind of limits, although the exact details weren&#x27;t published. API limits exist in every web…</description><content:encoded><![CDATA[<p>This past year Onshape introduced new API limits. Previously Onshape always had some kind of limits, although the exact details weren't published. API limits exist in every web platform to ensure the quality and stability of the service. But for Onshape, the total number of calls made was never capped, and there wasn't a cost for those calls. Due to a variety of reasons, this policy has now changed.</p>
<p>For the most up to date information - check out the <a href="https://onshape-public.github.io/docs/auth/limits/">official Onshape documentation</a></p>
<p>Onshape limits the total number of API calls a company or user can make in a year. The number is based on the seat count and type of licenses your company has. All API calls are pooled together for a company. If you require additional capacity, Onshape does offer additional paid API calls, but pricing is not made public. Publicly available Onshape apps listed in the app store (such as Renaissance) are currently not subject to this API limits.</p>
<p>Your API usage can be tracked in the developer section of your company settings.</p>
<p>So what counts as an API call? In the most basic sense, any action that you take with the API is an API call. Creating, Updating, Reading, or Deleting information. Getting the list of parts, getting a BOM, adding a feature, updating the metadata of a part. Each of these actions require an API call. Some actions - such as exporting a file - can be more than one API call. </p>
<p>Part of any Onshape integration planning should include estimations of API calls. Talk with your developer to understand what the usage on a single process can be, and then estimate how often that process is being run in a year. If multiple tools are in use at a company, they all pull from the same available pool of API calls, so communication across departments is important. </p>
<h3>How to reduce usage</h3>
<p>Whether you expect to exceed Onshape's API limits or not, its still good practice to be efficient with your API usage. API calls not only have a monetary cost, but unnecessary calls can harm application performance.</p>
<p>Here are some tips to reduce your API usage:</p>
<p>1. If you are purchasing an Onshape integrated service or Product that is not publicly listed in the Onshape app store (anything private to your own company), make sure to ask about API usage as part of the discovery process.</p>
<p>2. Only request the data you need. It can be tempting to load all of the possible data "just in case", but its best to only request what is necessary.</p>
<p>3. Request data once, and let user refresh. Many modern web apps will continually update to always have the most up to date information. What if the user loads my app - and then makes changes in their part studio? Its tempting to to refresh data in a loop in order to capture those updates, but that can be wasteful. Its better to give the user a refresh button to let them update the data in your app.</p>
<p>4. Rethink your process. Is it more efficient to export all the files in an assembly and sort them out later, or to only export certain categories of parts? A few extra clicks in a menu could save your company a lot of API usage.</p>
<p>5. Learn how your API endpoints work. There can be multiple ways to achieve the same result, but not each method is the most efficient. Endpoints can have extra options that might just save you some usage. For example, the bill of materials endpoint includes an option for "multiLevel" that will pull the entire multilevel bom in one api call - much more efficient than pulling eaching sub assembly separately. Theres even an option to include the top level assembly, which could save an extra metadata call.</p>
<p>Checks and balances. A few simple checks for a long process could save you from a big mistake. For example, an app that checks every configuration? First check how many configurations you're about to run against, and if the number is unexpectedly high - abort!</p>
<p>Navigating the Onshape API can be a bit daunting - especially if mistakes could lead to unexpected costs. Here at SmartBench Software, we are are experts in Onshape Automation. We can help you navigate your Onshape integration, without any surprises.</p>]]></content:encoded></item><item><title>Making use of Hidden Parameters in FeatureScript</title><link>https://www.smartbenchsoftware.com/post/making-use-of-hidden-parameters-in-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/making-use-of-hidden-parameters-in-featurescript/</guid><pubDate>Mon, 06 Oct 2025 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>A parameter in an Onshape Custom Feature can be made hidden from the user by using a UIHint</description><content:encoded><![CDATA[<p>A parameter in an Onshape Custom Feature can be made hidden from the user by using a UIHint</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_b3a7d5b9a8894955a0457dbeee8a26a7.png" alt="" loading="lazy"></figure>
<p>And this can lead to some interesting uses! But first we need an <a href="https://cad.onshape.com/FsDoc/uispec.html#editing-logic-function-arguments">editing logic function</a>. The editing logic function triggers when a feature is first created and whenever a user modifies an input. The function allows you to edit the definition of the feature before the main body of the feature runs, but it also updates the definition for the user. The intention is to allow for "intelligent default values". But we can also use it for some more advanced functionality.</p>
<h2>Array item labels</h2>
<p>The label for an array item can be set to the value of one of the parameters with the pattern shown in the default code:</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3c004cdd4d4548bb8aeb7cee29741ad5.png" alt="" loading="lazy"></figure>
<p>The item label template sets the label of the array item to the values mapped with #parameterName. But the parameter doesn't need to be visible! By adding a hidden string parameter, and setting the Item Label Template to its value, we can create custom labels for each item. We can use editing logic to dynamically generate intelligent item labels.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_aee77b5d20eb4965a6c9b758afbc70bd.png" alt="" loading="lazy"></figure>
<h2>Example</h2>
<p>A simple example - automatic indices. In the editing logic, we can set the hidden value to the index in the array. Every time the array changes, editing logic updates automatically - keeping the indices accurate and up to date.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9340da5b41b54d71b1262d4d9c11df4b.gif" alt="" loading="lazy"></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_1a7cad2c76274bf180e6fdb9da9dd115.png" alt="" loading="lazy"></figure>
<p><em>SmartBench Software is the industry leader in FeatureScript and Onshape automation.</em></p>]]></content:encoded></item><item><title>The Mechanical Engineering Stack and Onshape Strategy</title><link>https://www.smartbenchsoftware.com/post/the-mechanical-engineering-stack-and-onshape-strategy/</link><guid>https://www.smartbenchsoftware.com/post/the-mechanical-engineering-stack-and-onshape-strategy/</guid><pubDate>Mon, 05 May 2025 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>&quot;What data should we migrate?&quot;\ &quot;Should we be using the API or FeatureScript?&quot;</description><content:encoded><![CDATA[<p>"What pieces are missing from our stack?"</p>
<p>"What data should we migrate?"\
"Should we be using the API or FeatureScript?"</p>
<p>These three questions were asked to me recently during a few consulting calls with Onshape customers. On their own, the solutions are an integration, a migration tool, and Onshape automation (by FeatureScript or API app). But taking a moment to zoom out and evaluate the bigger question has made me rethink each of these questions. The real answer and the line between each of these questions is <strong>strategy.</strong> I get introduced to companies who have already found a weakness in their Onshape strategy, but I wanted to take a look at how my experience solving these smaller problems might help others identify the missing pieces. But what I really want to do is convince you, the reader, to evaluate your <strong>Onshape Strategy</strong>.</p>
<h2>The Stack</h2>
<p>A "Stack" is a term commonly used in software engineering. Its a term to describe the collection of technology used in a project. Programming language, frameworks, hosting, deployment, logging - all of these are decisions that need to be made when architecting a solution. Understanding how they all fit together can define the success of the project. </p>
<p>While on a recent call with a customer, they showed me this massive flow chart of every technology the company was using. CAD, ERP, PLM, MRP, CRM, and a bunch of other acronyms. I had never seen someone visualize a mechanical engineering workflow this way. But it makes sense. None of these technologies exist in a vacuum. Asking the question "But how do these all fit together" is the first step in a bigger vision - and eliminating pain points.</p>
<p>Here is a useful exercise - make a map of every platform your company uses and the basic purpose. When data originating in one system is used in another, draw an arrow for that data flow. Some systems automatically work together. Tools like Slack, Box, Clickup, have out of the box integrations. But how many arrows are "manual data entry"? In this new Cloud era of software, manual data entry should be eliminated. Software should work together. Highlight each of those arrows - because that is an opportunity for improvement.</p>
<h2>Breaking down Silos</h2>
<p>Last year I attended a talk with the subject "Breaking down Silos". At the time I felt like it was typical corporate mumbo jumbo, like <em>synergy</em>. But I've come to realize the real message behind the slogan. Typically talking about breaking down silos is about removing barriers between teams within a company. But those silos are put up by the technologies that each team uses. When only the design team uses Onshape, the downstream teams that need that data become reliant on them and the technology they hold the keys to.</p>
<p>The best way to break down a silo is...integration. Ensuring easy (and accurate) data flow between teams is what I think the real take away is. Breaking down silos isn't about getting people to be friendly to each other - most people are just fine working with others. Friction comes from <em>what</em> is being requested. If data flow is a pain point, the relationship representing that flow will suffer. If I had a criticism of Onshape, it is that data doesn't flow out of Onshape very easily - at least not out of the box. The only standard integrations are dropbox, google drive, and one drive.</p>
<p>Onshape's API on the other hand gives incredible opportunity for breaking down silos. Here at SmartBench Software, we regularly connect Onshape with all sorts of technologies. Onshape to ERP being the most common, followed closely by file repositories such as Box. Connecting Onshape with other systems allows designers to easily grab new part numbers without leaving Onshape, Sync BOMs for accurate data (maintaining a single source of truth!), saving time and reducing errors.</p>
<h2>Migration</h2>
<p>"What do we do with our 200,000 files?"</p>
<p>Many Onshape customers are not new companies. Companies are dropping their out-of-date, desktop burdened CAD systems to make use of everything Onshape has to offer. Making that decision can be tough because it requires a rethink of the entire stack, but the biggest hang up is legacy data. Years of CAD data can't just be thrown away. So what can be done with it?</p>
<p>Migration between any CAD systems is made additionally difficult by the fact that parametric CAD files are almost always in proprietary formats. Migrating can mean a loss of design intent, configurations, and other platform specific features. Add to that the time and effort to actually move the files. CAD migration isn't something that can happen in a day. Making a migration plan is imperative to prevent project delays, data loss, and frustrations in the team. </p>
<p>As someone who was development lead on two different (now defunct ☹️) Onshape Migration products - I've learned the challenges in this area. The start to any migration strategy is to ask the following questions:</p>
<ul>
<li>Which files should be migrated, and which should be made natively in Onshape</li>
<li>How to handle configured files?</li>
<li>Import just parts or parts and assemblies?</li>
<li>What metadata is critical?</li>
<li>Is our metadata consistent? Is there missing data? Should the metadata be updated to a new standard?</li>
<li>How should data be structured in Onshape? Do we keep folder structure?</li>
<li>Do we migrate drawings? Do we export PDFs, DXFs, or other formats?</li>
<li>During long migrations - how do you maintain a source of truth between the legacy system and the new Onshape implementation?</li>
<li>Do we import everything at once or just files as we need them?</li>
<li>How much time do we have? How long will it take? How many files do we have to move?</li>
<li>Is there an opportunity to fix old mistakes?</li>
</ul>
<p>Migrations require a lot of prep work and decision making up front because you only do it once. Its possible to take your time and start slow, but files are going to be imported once, and never again. Its not something that can be iterated and improved upon. There is some element of risk getting it right the first time, because having to redo a large migration could mean a loss of weeks or months of time.</p>
<p>Here are a few tips for tackling migration</p>
<ul>
<li><strong>Remodel the highly configured, highly used models</strong>. Parts such as fasteners should absolutely be modeled natively in Onshape. Start off on the right foot by leveraging Onshape's powerful configuration system.</li>
<li><strong>Use a migration tool</strong>. Manually uploading files will make a mess, create duplicates, and waste a ton of time. SmartBench Software offers customized migration tools to fit your needs. Moving to Onshape is a clearing of the slate for many companies, don't bring past mistakes with you!</li>
<li><strong>Import as you go</strong>. It is tempting to just import everything at once, but unless you have a small file count, that could be difficult. Onshape has limits to its API and uploading all 500,000 files could take a very long time. As part of your strategy, decide what to prioritize in migration to ensure that designers aren't waiting for what is actually being used.</li>
</ul>
<h2>Automation</h2>
<p>Seems obvious, but if you have automated processes in your legacy system, you'll need to move them into Onshape. But a Macro and a FeatureScript aren't one to one. The technology is quite different, and the solutions can be too. It can take some knowledge of <a href="https://www.youtube.com/watch?v=h5S_7H7GXwI">FeatureScript and the API</a> to know what the correct solution is, but if you need help - SmartBench has you covered. </p>
<p>Part of an Onshape strategy for customers moving to Onshape is not just to look at what is currently being automated, but also what <em>could</em> be automated. FeatureScript and Onshape's API opens up new opportunities for both what is possible to automate and what is economical to automate. Geometry automation in desktop CAD can be a challenge, where as FeatureScript can make it trivial.</p>
<p>Like the exercise with evaluating your "Stack" - what tasks exist within your Onshape process? Which tasks lead into other? Which get repeated the most? Where do the most errors exist? Evaluating what <a href="https://www.smartbenchsoftware.com/post/practical-applications-of-featurescript">can and should be automated</a> is an entire rabbits hole on its own. What I am going to leave the reader with is - take some time to zoom out and evaluate the greater picture of how your company is using Onshape and ask the simple question - <strong>how can we do this better?</strong></p>
<h2>Migrations, Integrations, Automation</h2>
<p>These three pillars are what I built SmartBench Software on. Onshape is a great platform and I believe is the future of CAD. But one size is never going to fit everyone. Take a moment and evaluate how Onshape fits into your companies bigger picture, what silos can be broken down. New technology like Onshape sometimes requires a rethinking of the entire engineering and design process, but that just means your Onshape journey has an upward trajectory.</p>
<p>Interested in how you can make the most of Onshape, or break down silos with an integration? Reach out to <a href="mailto:caden.armstrong@smartbenchsoftware.com">caden.armstrong@smartbenchsoftware.com</a>.</p>]]></content:encoded></item><item><title>Attributes in FeatureScript</title><link>https://www.smartbenchsoftware.com/post/attributes-in-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/attributes-in-featurescript/</guid><pubDate>Mon, 03 Mar 2025 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Attributes are a feature of Onshape&#x27;s FeatureScript that seem simple at face value, but are incredibly powerful. In the simplest terms, attributes are data attached to entities in…</description><content:encoded><![CDATA[<p>Attributes are a feature of Onshape's FeatureScript that seem simple at face value, but are incredibly powerful. In the simplest terms, attributes are data attached to entities in Onshape. An attribute requires an entity (Any type of geometry from bodies to faces, edges, etc), a name, and data.</p>
<p>To add an attribute, simply:</p>
<pre><code>setAttribute(context, {
  &quot;entities&quot;: entities,
  &quot;name&quot;: &quot;myName&quot;,
  &quot;attribute&quot;: &quot;myValue&quot;
});
</code></pre>
<p>To retrieve an attribute:</p>
<pre><code>getAttribute(context, {
    &quot;entity&quot;: entity,
    &quot;name&quot;: name
});
</code></pre>
<p>But that's not the only option. For multiple entities, getAttributes(). To get all the attributes: getAllAttributes(). </p>
<p>Attributes can also be used to generate queries. qHasAttribute(name) will look for entities that have the named attribute, allowing you to essentially tag entities and filter for them in a way that no other query supports. That functionality can get even more specific with qHasAttributeWithValue(name, value). Can't match all of the data (because its a map), use qHasAttributeWithValueMatching, which will match all of the key-value pairs provided. </p>
<p>Attributes remain on an entity until that entity is destroyed by another operation (or the feature creating them is suppressed). Attributes can even be set on entities like the origin or default planes (ensuring they don't get deleted by mistake!). </p>
<p>What type of data can I store in an attribute? Pretty much anything that can be made into a variable in FeatureScript can be stored as an attribute. There is a string size limit in Onshape, but in their words "640k ought to be enough".</p>
<h4>Why are they so useful?</h4>
<p>Attributes solve a few common problems that new FeatureScript developers face when trying to solve a workflow.</p>
<h2>Passing Information Between Features</h2>
<p>FeatureScript is setup in such a way that it can't look at feature definition of other features in the tree. FeatureScript can't see what the model looked like at other points in time. A FeatureScript is its own black box that it cannot see out of. So how do you make multi step features work together? Store data as attributes! In one feature, you can store the entire definition as an attribute, or maybe results of a process, or label entities without having to find them again. In another feature, those results, inputs, queries, etc, can then be retrieved and used again. </p>
<p>This is useful for:</p>
<ul>
<li>Features that allow a user to "edit" in the middle of a feature. Think a feature that generates a tool body, and then does stuff with it</li>
<li>Features that have a long and difficult first step. Features that do a lot of calculation can be split up to make the long regen time happen in one feature - store the result - and then the process which requires more user modification can be done in a second step. The overall regen time of the model won't improve, but it will make editing and designing much easier as the entire feature won't be doing a full regen for each edit.</li>
<li>Simplifying feature interfaces. Making a single feature do everything can be powerful, but it can make the UI turn to chaos. Breaking out portions of features into different steps can simplify the process and make it a bit easier to understand. Instead of an array input, try multiple features in the tree connected with named attributes.</li>
<li>Automated naming. Simply store a counter, and retrieve it in each feature.. +1... and then you have sequentially named parts/features/etc.</li>
</ul>
<h2>Integrated Applications</h2>
<p>One thing that Onshape really gets right is that FeatureScript and the Onshape API aren't completely separated. Features can be added to the tree through the API, but arbitrary FeatureScript functions can also be run with the API (making no changes to the model context). The EvaluateFeatureScript endpoint can be used to retrieve attributes from models, connecting a FeatureScript process to an API process. This is especially useful for fully automated solutions where there is no user to make a selection. </p>
<p>The most common use case for me is to label geometry with setAttribute, giving a name and a unique ID, and then in my API application - I use qHasAttributeWithValue to retrieve the specific entity.</p>
<h2>Super charging Custom Tables</h2>
<p>If you have ever made a custom table in Onshape, you've found that the selection of inputs for tables are not nearly the same as those for custom features. Need a more complex set of options? Attributes can be used as a work around for this.\
First we create a custom feature to define any of our input data for our custom table. This can include any kind of input that a custom feature has.\
Next we can build our entire custom table in our custom feature. By storing the entire table as an attribute on the origin, we can then make a custom table that simple retrieves the stored table and displays it. The only note here is that custom tables run after regeneration is complete, where-as with this method the table will be generated where the linked feature in the tree is. So make sure it doesn't get buried at the wrong point in the feature tree!</p>
<h2>How do <em>you</em> use attributes?</h2>
<p>This certainly isn't an exhaustive list of use cases for attributes. Taking a look through the Onshape standard code - you'll find a lot of creative uses for attributes. From Sheet metal, to frames, to holes. Onshape makes extensive use of attributes for their own internal features. Knowing about the power of attributes can help solve problems that you come across in FeatureScript development. Have you used attributes in creative ways?</p>]]></content:encoded></item><item><title>The Hidden Parameter in newSketch</title><link>https://www.smartbenchsoftware.com/post/the-hidden-parameter-in-newsketch/</link><guid>https://www.smartbenchsoftware.com/post/the-hidden-parameter-in-newsketch/</guid><pubDate>Fri, 03 Jan 2025 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>I accumulate a lot of weird and niche knowledge about Onshape and FeatureScript in the course of my work. This is no exception. Honestly, this blog article isn&#x27;t even for you; its…</description><content:encoded><![CDATA[<p>I accumulate a lot of weird and niche knowledge about Onshape and FeatureScript in the course of my work. This is no exception. Honestly, this blog article isn't even for you; its for me. I know that 2 years from now, I will run into this exact same issue and have forgotten the solution. Instead of writing internal docs, I figure, might as well share with the world on the off chance this helps someone else.</p>
<p>Today I figured out that <strong>newSketchOnPlane</strong> has a hidden parameter: "<strong>planeReference</strong>". Used like so:</p>
<pre><code>var sketch = newSketchOnPlane(context, id + &quot;sketch1&quot;, {
    &quot;sketchPlane&quot; : plane(vector(0, 0, 0) * inch, vector(0, 0, 1)),
    &quot;planeReference&quot; : referenceFace
});
</code></pre>
<p>Where <strong>referenceFace</strong> is a query for a face.</p>
<p>But why would you need this? The sketchPlane parameter already fully defines the sketch plane? What good could it do? The answer is: Sheet metal things.</p>
<p>See, sheet metal in Onshape is - weird, especially sheet metal with FeatureScript. A sketch made with newSketchOnPlane cannot then be used with the extrude feature to make tabs or holes in a flat pattern because its "in the 3D space". Onshape throws an error. </p>
<p>But when you, the user, select a flat pattern face as the plane for a sketch feature, the sketch appears in the sheet metal context! But how? I'm not entirely sure, but by providing a face that is in the flat domain, your sketch appears there. This parameter is how you can both have your sketch appear in the flat domain and set the exact origin of it. Useful for making things like tabs that need to be on bends. </p>
<p>Combine with qCorrespondingInFlat and you too can have some sheet metal FeatureScript fun.</p>]]></content:encoded></item><item><title>Reading Previous Feature Inputs</title><link>https://www.smartbenchsoftware.com/post/reading-previous-feature-inputs/</link><guid>https://www.smartbenchsoftware.com/post/reading-previous-feature-inputs/</guid><pubDate>Wed, 20 Nov 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>&quot;Hey Caden, can a feature extract the parameters of a previous feature?&quot;</description><content:encoded><![CDATA[<p>"Hey Caden, can a feature extract the parameters of a previous feature?"</p>
<p>-Simon Gatrall</p>
<p>I got this message in my inbox from a fellow Onshape expert/enthusiast, and my initial answer was... no. Onshape Features don't have access to information beyond the current state of the model, and their own inputs. Its part of what <a href="https://www.smartbenchsoftware.com/post/malicious-featurescripts">makes them secure</a>. You can check out <a href="https://forum.onshape.com/discussion/25629/creating-similar-linked-bridging-curves">Simon's Improvement Request</a> on the topic.</p>
<p>Except, they can if you want them to.\
If the previous feature is a custom feature that you wrote, you could store the inputs of the first feature, and retrieve them in the second feature.</p>
<p>Somewhere in your feature store the definition</p>
<pre><code>setAttribute(context, {
                    &quot;entities&quot; : qOrigin(EntityType.BODY),
                    &quot;name&quot; : &quot;MY_STORED_FUNCTION_NAME&quot;,
                    &quot;attribute&quot; : definition
                });
</code></pre>
<p>And then retrieve it later</p>
<pre><code>var storedDef = getAttribute(context, {
    &quot;entity&quot; : qOrigin(EntityType.BODY),
     &quot;name&quot; : &quot;MY_STORED_FUNCTION_NAME&quot;
            });     
</code></pre>
<p>The specific use case was to have a feature duplicate the previous inputs to make it easier to quickly iterate. So I took the bridging curve feature from the Onshape std (yay open source), and made a copy of the inputs. I store the definition at the end of the function. But the inputs need to be set, so I created an <strong>editing logic function</strong> to set the inputs when the feature starts up (or checks off the "update" option).</p>
<pre><code>export function EditingLogicFunction(context is Context, id is Id, olddefinition is map, definition is map, isCreating is boolean) returns map
{
    if (definition.update)
    {
        var storedDef = getAttribute(context, {
                &quot;entity&quot; : qOrigin(EntityType.BODY),
                &quot;name&quot; : &quot;STORED_BRIDGE&quot;
            });
        if (storedDef != undefined)
        {
            definition = storedDef;
        }
        definition.update = false;
    }
    return definition;
}
</code></pre>
<p>If you try out the feature, you'll see that subsequent iterative bridging curves copy the previous one's inputs, making it quick and easy to make small tweaks.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_820676aca8e846938cb285b38c46ff25.png" alt="" loading="lazy"></figure>
<h2><a href="https://cad.onshape.com/documents/024b280eb5aa5df1cffef6e2/w/d9aaaff5adbc1c9ecbaeaf49/e/ad107a41f5980d888248bad8">Check out the example here</a></h2>
<h2>But how does pattern and mirror work if they can't see the previous features?</h2>
<p>Some of the curtain can be drawn back.\
Functions like lastModifyingOperationId can be used to retrieve the feature Id of previous features. So it is possible to see the result of another feature. But that still doesn't give us the inputs of that feature.</p>
<p>The "FeatureList" input type for a FeatureScript passes function references to previous features in the tree, but FeatureScript doesn't seem to allow us to expose the inputs of that function.</p>
<p><em>Fun thing I found while writing this: you can get the name of a feature with getFeatureName, but only in tables and editing logic functions.</em></p>]]></content:encoded></item><item><title>Malicious FeatureScripts</title><link>https://www.smartbenchsoftware.com/post/malicious-featurescripts/</link><guid>https://www.smartbenchsoftware.com/post/malicious-featurescripts/</guid><pubDate>Thu, 07 Nov 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>As a consulting developer, a common question that I face is one of security, and its a question you should always be asking outside consultants and developers.</description><content:encoded><![CDATA[<p>As a consulting developer, a common question that I face is one of security, and its a question you should always be asking outside consultants and developers. </p>
<p>But that question doesn't come up with FeatureScript...because malicious FeatureScripts aren't really possible.</p>
<p>FeatureScript has an open source code - all of the Onshape standard features can be viewed by anyone. But its still a walled garden. Only Onshape can update the FeatureScript language, and the language is very limited compared to other programming languages. The list of things that FeatureScript can't do is pretty long, and frustrates some newer developers.</p>
<ul>
<li>You can't make web requests</li>
<li>You can't export data</li>
<li>You can't look at any Onshape data beyond the current context of the part studio model</li>
<li>You can't make permanent changes to the document (history and rollback are never affected)</li>
</ul>
<p>And that's why FeatureScript is secure, and a Feature can always be trusted.</p>
<p>If FeatureScript could export files, a Feature could create a malicious payload. If it could make web requests and access your data, your data could be stolen. If data in Onshape could be permanently modified, you could have malicious data loss. Compared to other scripting languages, this is very limiting, but FeatureScript does exactly what it needs to do - and nothing more.</p>
<p>FeatureScript being secure is great because it removes barriers for me to work with companies, it makes the development process simpler, and adds to the overall speedy delivery time that is only possible with Onshape.</p>
<h4>But what's the worst I could do?</h4>
<p>While talking about how secure FeatureScript is, its also helpful to talk about a worst case scenario. How could I be malicious? I enjoy brainstorming novel ideas, putting my white hacker hat on, and digging into what is possible. So here are some ideas I came up with for malicious features.</p>
<p>When I develop custom features for customers, I always give them all of the source code and ownership of it. So these would be found pretty easily. </p>
<h2>Idea 1: Long Regen Time</h2>
<p>An infinitely running FeatureScript is not possible. FeatureScript runtime is capped at 10 minutes. But a feature that takes 10 minutes really sucks. I find they can cause some weird things to happen in a document, and you also lose 10 minutes waiting for it to load so you can remove the feature. So worst case - you waste 10 minutes, maybe 20 if they run it twice.</p>
<h2>Idea 2: A Randomly Misfunctioning Feature <em>The title of my autobiography</em></h2>
<p>Write a really cool feature that people want to use - and then add some random errors. This falls under "time waster" category. Every 1 in 100 feature users will see an error and waste time trying to figure out why. But what are they going to do? Contact the developer and waste my time. </p>
<h2>Idea 3: Caden was here <em>Also the title of my autobiography</em></h2>
<p>Make a feature that modifies the model - but also adds some hidden geometry. For the past decade whenever I visit my parent's house I've been hiding sticky notes with "Caden was here" written on them. They don't use Onshape, but there's no reason my psychological torture can't make the leap. The feature could do what the user is expecting, but also hiding a teeny tiny "Caden was here" at a size that wouldn't easily be found.</p>
<p>Changes to a model aren't permanent, so when the hidden message is found, it can be easily undone. The worst case I can imagine is someone not finding it and sending it to be prototyped on a 3d printer. Brings up a fun question: would your company's design review find this?</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_7db2adf59ea14230afcbd8ad2aec66d3.png" alt="" loading="lazy"></figure>
<h2>Idea 4: Embed a malicious link</h2>
<p>I've seen a few FeatureScript developers include links to their company's website in the UI of a feature. I don't like this, it clogs up the dialog. But, you could include a malicious link through this. Its a bit weak since you can't do a hyper link, and the user can see the entirety of the link. A common trick is to have a similar domain to the expected one. Ex <a href="https://smartbenchsoftware.com">SmartBenchSoftware.com</a> vs SmartBenchSoftvvare.com. Remember, only click links from sources you trust.</p>
<h2>Conclusion</h2>
<p>FeatureScript is really hard to do evil things with, which is great. When you find that perfect custom feature, you can be confident that you aren't compromising your company's data.</p>]]></content:encoded></item><item><title>Hidden FeatureScript Functions</title><link>https://www.smartbenchsoftware.com/post/hidden-featurescript-functions/</link><guid>https://www.smartbenchsoftware.com/post/hidden-featurescript-functions/</guid><pubDate>Mon, 14 Oct 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>One of the big selling points of Onshape FeatureScript that I like to talk about is that Onshape&#x27;s standard features are written in FeatureScript, all of the standard code is…</description><content:encoded><![CDATA[<p>One of the big selling points of Onshape FeatureScript that I like to talk about is that Onshape's standard features are written in FeatureScript, all of the standard code is openly available, and FeatureScript is generally well documented. But sifting through the standard code, you'll come across functions that aren't documented. But why? Well, there are a few reasons; they could be in development, unstable, or subject to change in the future. Undocumented functions can be used, but should be used with caution.</p>
<p>But despite that warning, lets look at what I think are the most useful ones...</p>
<p>To follow along and view the code samples, check out this <a href="https://cad.onshape.com/documents/8dc7e61c257a8774942c2a90/w/7ca257b896f878f386f1ea61/e/8f7bad8a000a473b13e7fe6f">public document</a></p>
<p><strong>opExtractSurface</strong> (context is Context, id is Id, definition is map)</p>
<p>Take a list of faces and generate surface bodies. Source faces and bodies are not affected.</p>
<table>
<thead>
<tr>
<th>definition</th>
<th>map</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>faces</td>
<td>query</td>
<td>List of faces to be converted</td>
</tr>
<tr>
<td>tangentPropagation</td>
<td>boolean</td>
<td>whether additional faces should be added to the selection by tangent propagation</td>
</tr>
<tr>
<td>offset</td>
<td>ValueWithUnits</td>
<td>(Optional) Offset extracted surface faces by this distance along the normal</td>
</tr>
<tr>
<td>useFacesAroundToTrimOffset</td>
<td>boolean</td>
<td>(Optional) Use surrounding faces extensions to trim offset</td>
</tr>
<tr>
<td>redundancyType</td>
<td>ExtractSurfaceRedundancyType</td>
<td>Controls the culling of redundant geometry on the result body.</td>
</tr>
</tbody>
</table>
<p>This is probably my most used function in this list. This is incredibly useful for changing faces into surfaces. Some operations require specific data types (Such as extend surface), and this function allows changing faces belonging to solid bodies into surface bodies. Its also useful when doing intermediate operations that require a body, but only the face is the important geometry to consider. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_543ce01b519a4e02b95689b9c98612c5.gif" alt="" loading="lazy"></figure>
<p>The next two functions are the two halves of move boundary. opEdgeChange and opExtendSheetBody together modify the boundaries of a sheet body in either direction.</p>
<p><strong>opEdgeChange</strong> (context is Context, id is Id, definition is map)</p>
<p>This function moves the boundary of a surface inward. </p>
<table>
<thead>
<tr>
<th>definition</th>
<th>map</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>edgeChangeOptions</td>
<td>array</td>
<td></td>
</tr>
<tr>
<td>edge</td>
<td>query</td>
<td>edges to modify</td>
</tr>
<tr>
<td>face</td>
<td>query</td>
<td>face the edge is adjacent to</td>
</tr>
<tr>
<td>offset</td>
<td>ValueWithUnits</td>
<td>(optional) amount to offset edge</td>
</tr>
<tr>
<td>replaceFace</td>
<td>query</td>
<td>(optional) query of a face to move edge to</td>
</tr>
<tr>
<td>transformList</td>
<td>array of transforms</td>
<td>(optional) transformations applied to the edge</td>
</tr>
</tbody>
</table>
<p><strong>opExtendSheetBody</strong> (context is Context, id is Id, definition is map)</p>
<p>Extend edges of a sheet body outward</p>
<table>
<thead>
<tr>
<th>definition</th>
<th>map</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>endCondition</td>
<td>ExtendEndType</td>
<td></td>
</tr>
<tr>
<td>entities</td>
<td>query</td>
<td>edges to extend</td>
</tr>
<tr>
<td>tangentPropagation</td>
<td>boolean</td>
<td>Whether to add additional edges based on tangent propagation</td>
</tr>
<tr>
<td>extendDistance</td>
<td>ValueWithUnits</td>
<td>Distance to extend if end condition is Blind</td>
</tr>
<tr>
<td>target</td>
<td>query</td>
<td>Required if endCondition is Extend to Target - Part to extend up to</td>
</tr>
<tr>
<td>extensionShape</td>
<td>ExtendSheetShapeType</td>
<td>Shape characteristic of extension.</td>
</tr>
</tbody>
</table>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_589d0c051733422d89ef465322f206a2.gif" alt="" loading="lazy"></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_eaf80c9481d647f58a1112a3c905957f.gif" alt="" loading="lazy"></figure>
<p><strong>opCreateOutline</strong>(context is Context, id is Id, definition is map)</p>
<p>Generate surfaces representing the outlines of parts or surfaces projected onto a surface</p>
<table>
<thead>
<tr>
<th>definition</th>
<th>map</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>tools</td>
<td>query</td>
<td>The tool parts or surfaces</td>
</tr>
<tr>
<td>target</td>
<td>query</td>
<td>The face whose surface will be used to create outline. Current only planes, cylinders, or extruded surfaces are supported.</td>
</tr>
<tr>
<td>offsetFaces</td>
<td>query</td>
<td>(Optional) Faces in tools which are offset of target face. If offsetFaces are prpovided, the operation will fail if target is non-planar and there are not exactly two offset faces per tool</td>
</tr>
</tbody>
</table>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3c64f713d0fe49f6a0b06e6a535e5863.png" alt="" loading="lazy"></figure>
<p>The result of the operation is a surfaces that is a silhouette or projection of the body.</p>
<p>While this function can be extremely helpful, I have found issues with more complex geometry. The regeneration time can be very long, and the function can fail unexpectedly. The downside is that replicating the function without using it is not an easy task.</p>]]></content:encoded></item><item><title>Protecting FeatureScript Code</title><link>https://www.smartbenchsoftware.com/post/protecting-featurescript-code/</link><guid>https://www.smartbenchsoftware.com/post/protecting-featurescript-code/</guid><pubDate>Mon, 23 Sep 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>&quot;Hey Caden, I&#x27;ve written a FeatureScript, and I want to share the feature, but not my source code. Is there any way to do that?&quot; - Anonymous</description><content:encoded><![CDATA[<p><strong><em>"Hey Caden, I've written a FeatureScript, and I want to share the feature, but not my source code. Is there any way to do that?" - Anonymous</em></strong></p>
<p>This is an interesting, but common challenge. Unlike compiled programs, FeatureScript code is usually right there in the open, and easily copied. But never fear, there is a solution.</p>
<p>The answer, is layered features. Follow along with <a href="https://cad.onshape.com/documents/696d0c76ed367a7692944694/w/7a63145321d1fb61a1255597/e/9131aec5c42742262ddb98aa">this sample document.</a></p>
<p>The first step, is to write a feature like normal. The key difference here is that we are going to write the entire feature inside of another function instead of the main body of the feature. Our feature body for testing will just reference this main function.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3aff23c1749447bdb677f0788f049dcb.png" alt="" loading="lazy"></figure>
<p>The predicate is our input (feature UI), and our main function contains the body of our feature. Both of these need to be exported to make them available in the public feature.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_6cb97b63e2974efa98feef8f720f5760.png" alt="" loading="lazy"></figure>
<p>Now, the Enum parameter poses a problem. Enums need to be exported from the public feature, so we have to put the enum declaration in its own feature studio. All of the code in the enum's studio will be exposed and made public, but that is fine, because an enum isn't really secret information.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_8ee03c09b7a94dae8816db62786d5688.png" alt="" loading="lazy"></figure>
<p>Finally, we make a new document, and create a feature that imports our source code. Its important to note here that the source code is imported, but not exported! This prevents the code from being used by other users. The source code can remain a private document, while this public feature can be shared with anyone.</p>
<p>Its important to note that the example document has all three tabs in the same document. The private source and enum code should be in a separate private document, and only the public feature in the public document.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_ec02745b9af44b32adc1ba1223d3e1df.png" alt="" loading="lazy"></figure>
<p><strong><em>But how does this keep someone from stealing my feature? Can they not just import the code?</em></strong></p>
<p>Onshape does not allow someone to copy that import line into their document if they don't have permission to the inner document. Its counterintuitive coming from other programming languages, but Onshape has woven a bit of magic into FeatureScript that lets this happen. </p>
<p><strong><em>Are there other uses for this technique?</em></strong></p>
<p>Yes! For companies doing large feature releases, this can also be used to do "development" and "production" releases. The import statement references a specific version of the source code. You can update the source code of the development feature without affecting the production version. When it comes time to update production, just update the import statement to the stable development version.</p>]]></content:encoded></item><item><title>Exporting Labeled Geometry with FeatureScript</title><link>https://www.smartbenchsoftware.com/post/exporting-labeled-geometry-with-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/exporting-labeled-geometry-with-featurescript/</guid><pubDate>Tue, 03 Sep 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>I&#x27;ve been asked a few times about a variety of challenges that all fall under the same category:</description><content:encoded><![CDATA[<p>I've been asked a few times about a variety of challenges that all fall under the same category:</p>
<ul>
<li>Can I export the attributes set with FeatureScript?</li>
<li>Can I export face IDs from Onshape?</li>
<li>Can I link a model in Onshape and one in another system?</li>
</ul>
<p>Working with metadata within Onshape isn't too difficult. Associating data to a face is a challenge because the internal ID system of a CAD program isn't shared between systems, nor is it predictable. This challenge comes up when working with CFD, FEA, animatronics, and more.</p>
<p>So how do I associate metadata with a face outside of Onshape? The answer: Colour.</p>
<p>FeatureScript lets you set the appearance of a face on a body, and that colour is included in the exported file. To associate the metadata, all we need to do is create a feature that colours each face a unique colour, and then output a table of data from the featurescript.</p>
<p>For example, here is a model with 3 labeled faces, each with a unique colour. In my external program, I want to know three datums, so the labels are simply A,B,C.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3067d1e437564f0cb14a79cf7def5b44.png" alt="" loading="lazy"></figure>
<p>And the output of the FeatureScript reading stored metadata.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_d37de68646f4483c9d690e5a02140670.png" alt="" loading="lazy"></figure>
<p>In the STEP file, looking through you can find the colour of the face being set:</p>
<p><strong>#128\=COLOUR_RGB('',0.1,0.1,0.1);</strong></p>
<p>Looking at our table of data, we know that this face must be Datum A. We can then use this data in our external process. </p>
<p>Does this sound like a solution to a problem you have? SmartBench Software is the leading provider of Onshape Custom Software Solutions, <a href="https://www.smartbenchsoftware.com/contact">reach out today</a> for a free discovery call.</p>]]></content:encoded></item><item><title>FeatureScript and Configurations</title><link>https://www.smartbenchsoftware.com/post/featurescript-and-configurations/</link><guid>https://www.smartbenchsoftware.com/post/featurescript-and-configurations/</guid><pubDate>Tue, 06 Aug 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>I&#x27;ve talked about how great Onshape configurations are in the past. They work great and are super powerful. FeatureScript also works fantastically with Onshape&#x27;s configurations,…</description><content:encoded><![CDATA[<p>I've talked about how great Onshape <a href="https://www.smartbenchsoftware.com/post/making-sense-of-the-onshape-configuration-string">configurations</a> are in the past. They work great and are super powerful. FeatureScript also works fantastically with Onshape's configurations, as your custom feature can be configured in the same ways that the Onshape standard features can be configured. But did you know that a FeatureScript can also utilize information from the current configuration, or Part Studio Data input types?</p>
<p>First, lets talk a quick refresher about FeatureScript IDs for configurations in Onshape. The names of the configuration tables and values are not the same in the background as what they are displayed as in the user interface.</p>
<p>In a Part Studio configuration panel, for any table or variable you can click on the ellipses followed by the "Edit FeatureScript IDs". </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_4ce559435709485fb01312bb7ce62b5f.png" alt="" loading="lazy"></figure>
<p>Bringing up the window showing FeatureScript IDs. This can either be modified to something more expected and consistent, or just noted for use in a custom feature. When working with configurations and FeatureScript, these are the values that matter. The Display values are what the user is expecting, but these are the values that need to be used when specifying configuration data.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3b9dc5d313ad4767946c511eecbbbde9.png" alt="" loading="lazy"></figure>
<h2>Current Part Studio Configuration Variables</h2>
<p>First way of looking at the configuration is through variables. In a part studio, the current configuration is set as variables. For a known configuration variable, we can do:</p>
<pre><code>getVariable(context, name);
</code></pre>
<p>But, if we don't know the name of the configuration variables:</p>
<pre><code>getAllVariables(context);
</code></pre>
<p>And we can look through for what we think are configuration variables. For example, we could look for tables that default to starting with "List_"</p>
<pre><code>var allVariables = getAllVariables(context);
for (var k in keys(allVariables))
{
    if(startsWith(k, &quot;List_&quot;))
    {
        // Do something with this variable
    }
}
</code></pre>
<p>Its not completely fool proof, but if we can use some assumptions in our FeatureScript, it will make things easier. If our feature was the first one in the tree, we could assume that all the variables are configuration variables. There is no one right answer here so you will need to make the appropriate choice for your scenario.</p>
<p>This can also be applied to computed properties. For a configured part, the property will be computed for the specific configuration. All that is required is the context, so if we are only looking at variables that start with "List_" we can have the configuration name as a custom part property.</p>
<pre><code>annotation { &quot;Property Function Name&quot; : &quot;Configuration Name&quot; }
export const configName = defineComputedPartProperty(function(context is Context, part is Query, definition is map) returns string 
{
     var allVariables = getAllVariables(context);
    for (var k in keys(allVariables)){

       if(startsWith(k, &quot;List_&quot;))
       {
           return allVariables[k];   // only selects the first one
       }
    }
}
</code></pre>
<p>Now, this only works for a single configuration table, so you might need to modify for your situation.</p>
<h2>PartStudioData Configuration Data</h2>
<p>When using a partstudiodata input type in a custom Feature (its the input type that lets you select parts from other part studios), the configuration data is also available. This is a requirement for something like instantiating. But there is more than just the current configuration available.</p>
<p>Starting with a part studio data parameter:</p>
<pre><code>annotation { &quot;Name&quot; : &quot;Part studio&quot; }
definition.myPartStudio is PartStudioData;
</code></pre>
<p>We have two properties to look at:</p>
<pre><code>definition.myPartSudio.configuration
or
definition.myPartStduio.configurationData
</code></pre>
<p><strong>configuration</strong> gives us the current configuration selected by the user. This gets used in something like an instantiator function, or can just read what the current configuration is. This is a map where the keys are the variable name, and the value is the selected option.</p>
<p><strong>configurationData</strong> contains information about the configuration variables and tables that are setup in that part studio. Again, this type is a map containing a key with the table/variable name, and the value is dependent on the type of configuration input.</p>
<p>Tables contain - <strong>options</strong>, <strong>defaultValue</strong>. The list of options could be used to generate a matrix of all configurations.</p>
<p>Variables - Such as lengths or boolean contain a <strong>defaultValue.</strong></p>
<p>This information could be used to either generate new configuration with the instantiator, or have context information about both the current configuration and other configurations.</p>
<p>If you still find all of this a bit overwhelming? SmartBench Software is the industry leader in Custom FeatureScript and Onshape integrated application development. Checkout our <a href="https://www.smartbenchsoftware.com/services">services page</a> for more information, or <a href="https://www.smartbenchsoftware.com/contact">contact Caden</a> to schedule a discovery call.</p>]]></content:encoded></item><item><title>Making sense of the Onshape Configuration String</title><link>https://www.smartbenchsoftware.com/post/making-sense-of-the-onshape-configuration-string/</link><guid>https://www.smartbenchsoftware.com/post/making-sense-of-the-onshape-configuration-string/</guid><pubDate>Tue, 02 Jul 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Onshape&#x27;s configurations are one of its best features. Easy to use, well integrated, and very powerful. But when making an Onshape integrated application, they can add a bit of…</description><content:encoded><![CDATA[<p>Onshape's configurations are one of its best features. Easy to use, well integrated, and very powerful. But when making an Onshape integrated application, they can add a bit of complexity, and are a typical blocking point for newer API developers. But never fear, its really not that difficult.</p>
<p>This configuration string is really only visible to the user in one place: the copy link button. Nestled between the branch name and folder name is the button to copy the current document at this tab button. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_6bbb38500dae485c8fc63350d17277e6.png" alt="" loading="lazy"></figure>
<p>If you look at the URL generated by this button, you can see the current configuration. It typically looks something like:</p>
<p>List_AT68kUtZxoHFJ3%3DDefault%3BList_kxFgN7VgGBeRqB%3DDefault%3Blength%3D0.001%2Bmeter</p>
<p>So what does it all means? Well, the first thing to do is unencode the string. Parameters inside a URL cannot have certain characters (such as \=) and need to be replaced with a code. The %3D sequence is an encoded equal sign. Putting this into a URL Decode tool, we get:\
List_AT68kUtZxoHFJ3\=Default;List_kxFgN7VgGBeRqB\=Default;length\=0.001+meter\
The configuration string is really just a semi-colon separated list of configuration property names and their values.</p>
<p>But what configuration value is List_AT68kUtZxoHFJ3? I don't remember naming anything that. Onshape generates random identifiers for each configuration table to uniquely identify them, as a user might change the names of their tables, or even name them all the same thing. You can see these unique IDs by clicking the "..." in the top right of each configuration parameter. If you really want to, you can even change these to something more literal or easier to understand in your code.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_ce1698aeb0c045f2b68b0343438af3d6.png" alt="" loading="lazy"></figure>
<p>So how do I construct a configuration string? Its quite simple, for each configuration parameter, set the name\=value; Ensuring each property is separated by a semi colon. If I wanted to change the above parameter to "small" I have to use the internal value "smal".\
List_AT68kUtZxoHFJ3\=smal; </p>
<p>If parameters are left out of the configuration string, the default value is chosen by Onshape.</p>
<h2>"But why isn't my configuration string working?"</h2>
<p>When it comes to using the configuration string in API calls, the three main mistakes are:\
<strong>1. Not encoding the configuration string in URL parameters</strong></p>
<p>If the configuration is in the URL, it needs to be encoded, just as we saw earlier with the %3D encoded \=</p>
<p><strong>2. Encoding the configuration in the body</strong></p>
<p>If the configuration parameter is in the body of a post request, this does not need to be URL encoded. Just leave it as is with all the semi colons and equal signs.</p>
<p><strong>3. Units</strong></p>
<p>Onshape really cares about units, and that's a good thing. But it does mean that any configuration parameter that is a length needs to have units. My above example has length\=0.001+meter. The units can be changed, but they must be included.</p>]]></content:encoded></item><item><title>Dynamic UI in FeatureScript</title><link>https://www.smartbenchsoftware.com/post/dynamic-ui-in-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/dynamic-ui-in-featurescript/</guid><pubDate>Mon, 03 Jun 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>This weeks FeatureScript tip: creating a dynamic user interface.</description><content:encoded><![CDATA[<p>This weeks FeatureScript tip: creating a dynamic user interface.</p>
<p>One thing that FeatureScript struggles with is creating a user interface that reacts to user inputs and context information. FeatureScript does allow for controlling the visibility of parameters with booleans and enums. In the example below, myLength is only shown if "a" is true.</p>
<pre><code>annotation { &quot;Name&quot; : &quot;A&quot; }
definition.a is boolean;
if(definition.a)
{
    annotation { &quot;Name&quot; : &quot;Hidden if not a&quot; }
    isLength(definition.myLength, LENGTH_BOUNDS);
}
</code></pre>
<p>This is a bit limited without logic operators and support for other parameter types. But never fear, there is a solution! Enter <a href="https://cad.onshape.com/FsDoc/uispec.html#editing-logic-function">editing logic functions</a>. FeatureScript editing logic functions make additional changes to the definition after a user has made changes to the definition of a feature, but before the feature is run. The intent of editing logic is to intelligently set default parameters, but we can use it to make a dynamic UI with the use of hidden parameters.</p>
<p>First step, add an editing logic function:</p>
<pre><code>export function EditingLogicFunction(context is Context, id is Id, olddefinition is map, definition is map, isEditing is boolean) returns map
{
    return definition;   
}
</code></pre>
<p>and adjust the feature annotation to include the editing logic function definition</p>
<pre><code>annotation { &quot;Feature Type Name&quot; : &quot;Dynamic UI Feature&quot;, &quot;Editing Logic Function&quot;:&quot;EditingLogicFunction&quot; }
export const dynamicUI = defineFeature(function(context is Context, id is Id, definition is map)
</code></pre>
<p>Now, whenever the definition is changed, we can update the definition in a way that makes the UI a bit more dynamic.\
We can add a parameter to our definition that is only shown when the hidden property "show C" is true, and use editing logic to set the hidden boolean. Show C is set to "always hidden", ensuring our user does not see it or manipulate it.</p>
<pre><code>annotation { &quot;Name&quot; : &quot;Show Group C&quot;, &quot;UIHint&quot;: UIHint.ALWAYS_HIDDEN }
definition.showC is boolean;
if(definition.showC)
{
    annotation { &quot;Name&quot; : &quot;Parameter C&quot; }
    isLength(definition.C, LENGTH_BOUNDS);
}
</code></pre>
<p>In our editing logic function, we can define what logic will display C:</p>
<pre><code>definition.showC = definition.a &amp;&amp; definition.B &gt; 5*millimeter;
</code></pre>
<p>Resulting in a UI that responds to our input</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_c09ce247f6d149d7b75945a0440adf75.gif" alt="" loading="lazy"></figure>
<p>And thats it! Create a hidden boolean, and use editing logic to set it. The boolean then controls the visibility of each parameter. From here you can use your imagination for how to create a dynamic user interface. Logic could include checking geometry type of queries, query size, lengths compared to other lengths, evaluations of selected queries, etc.</p>]]></content:encoded></item><item><title>How to Add a Custom Feature</title><link>https://www.smartbenchsoftware.com/post/how-to-add-a-custom-feature/</link><guid>https://www.smartbenchsoftware.com/post/how-to-add-a-custom-feature/</guid><pubDate>Mon, 03 Jun 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>You&#x27;ve found to perfect custom feature, and you want to use it in a part studio. How you do get it on your toolbar?</description><content:encoded><![CDATA[<p>You've found to perfect custom feature, and you want to use it in a part studio. How you do get it on your toolbar?</p>
<p>First step: Open the document containing the feature</p>
<p>Next, find the <em>Add Custom Feature</em>s button in the top left of the document, in the pop-up select the feature (if there are multiple in the document).</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f289833e49de40e0a4fae0b311098d14.png" alt="" loading="lazy"></figure>
<h3>How to use my new custom feature?</h3>
<p>Inside of your part studio, Look for the drop down menu left of the <em>Search Tools.</em> Find your new custom feature, and add it to your part studio, just as you would any other feature.</p>
<p>Alternatively, you can also type the name of the feature into the <em>Search Tools</em> bar.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_884faeb7c19c468bb5221bca04e24e75.png" alt="" loading="lazy"></figure>
<h3>How to update a custom feature?</h3>
<p>Features with the little blue circle indicate that there is a new version of the linked document. To update the feature to the new version, right click the feature and select <em>update,</em> and then click <em>update all</em>.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_39a56e624ebc4e9a88e5c52439d1dd2e.png" alt="" loading="lazy"></figure>
<p>Now, it is important to note that updating the feature in the toolbar does not update the feature in the feature tree. In order to update specific instances of a feature, you will need to go through the update process for each feature in the tree.</p>]]></content:encoded></item><item><title>A Quick Guide to Debugging FeatureScript</title><link>https://www.smartbenchsoftware.com/post/a-quick-guide-to-debugging-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/a-quick-guide-to-debugging-featurescript/</guid><pubDate>Sat, 18 May 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>FeatureScript is an integral part of Onshape, and in my eyes is key to what makes Onshape unique (aside from the whole cloud thing). I like to tout how simple it is to get started…</description><content:encoded><![CDATA[<p>FeatureScript is an integral part of Onshape, and in my eyes is key to what makes Onshape unique (aside from the whole cloud thing). I like to tout how simple it is to get started writing FeatureScript, because it really is. There's nothing to install, download, or setup. <em>New Tab &gt; Create Feature Studio</em>, two clicks and you're writing FeatureScript. While it is easy to get started, the documentation for FeatureScript makes one big assumption: you already know how to program. For professional developer like myself, this isn't an issue, I have plenty of transferable programming experience and a university degree. But many people trying FeatureScript are designers who might be programming for the first time ever. Learning FeatureScript requires learning how to program, which entails learning how to debug. The biggest hurdle for a new FeatureScripter is learning how to debug, which can be frustrated without a bit of wisdom and experience. I have heard debugging described as solving a murder mystery where you are both detective and murderer. I've written this guide not as a comprehensive textbook, but rather as a quick start guide for someone who is both new to FeatureScript and programming in general. Hopefully the steps, tips, and tricks and help make FeatureScript even more accessible. </p>
<h2>Syntax Errors</h2>
<p>The first type of error you are likely to encounter is a syntax error. Programming has rules, and those rules need to be followed exactly. When something unexpected appears in your program, the computer cannot fix it, so it complains until you fix it. You'll recognize it quickly by the little red squiggle under your text.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_50993943258e454abc69fc815d449237.png" alt="These two brackets don't match" loading="lazy"><figcaption>These two brackets don't match</figcaption></figure>
<p>The first tip here is for seeking out missing brackets. Its pretty common to type the start bracket, but not the closing bracket. For large loops and if statements, its easy to accidentally delete a bracket, and if you copy paste enough, you're sure to copy a start but not an end. If you are looking for the pair of brackets, but putting your cursor on one bracket, the other one will have a little box placed around it. When I write code, I tend to type both brackets in before typing the code that goes inside the brackets. Prevents me from forgetting to close things up.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_bf5c70eba94f46c997a64841f9914f8a.png" alt="" loading="lazy"></figure>
<p>The second tip is to prevent a FeatureScript from getting messy in the first place. Well formatted code makes it easier to know if you are copying incomplete brackets, or accidentally deleting the wrong one. The FeatureScript editor comes with this magic button (the brush) that formats your code for you. Its magic, use it regularly. It makes everything better.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9f76ad4edcee49099d3aeffabc6d3acd.png" alt="" loading="lazy"></figure>
<h2>FeatureScript Notices</h2>
<p>You've written some code, and you've added your Feature to your Part Studio, but you now have a red feature. Something is wrong, but what? You read the notices! Look for the exclamation mark at the top right of the Part Studio</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_ad0388e8df66467883ecd769126147fc.png" alt="" loading="lazy"></figure>
<p>Clicking this opens up a tab at the bottom of the screen. All of your error messages and text output for your feature will appear here. Opening the tab, I can see two messages: the blue message is an information level message letting me know that I have an unused variable in my Script. While this won't prevent the feature from running, it might indicate that I've made a mistake in my code leaving a variable declared but unused.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_621fa5933e9e49d1902242ecc9df9a2d.png" alt="" loading="lazy"></figure>
<p>Below the information messages, I have the red highlighted error message. This is what is causing my feature to appear red in the Feature tree. This error is preventing my Feature from running. The error consists of a message: "<em>Can not add number and ValueWithUnits (map)",</em> and a stack trace below it. This message is telling us what is wrong: that we are trying to add two things together, one a number, and another a value with units, which cannot be added together. Most of the time, reading the error message explains the error. If it doesn't, read it again.</p>
<p>Below the message is the stack trace. The stack trace helps us understand where in the code the error came from, and how it got there. A stack trace drills down from the bottom up.\
<em>Part Studio 1</em> - This is the tab the error is in</p>
<p><em>Part Studio 1 (My Feature 1)</em> <em>-</em> The feature My Feature 1 is causing the error</p>
<p><em>56:17 onshape/std/feature.fs (defineFeature)</em> - (this line can generally be ignored)</p>
<p>16:17 Feature Studio 1 (const myFeature) - This line is showing us that the error happens in the tab Feature Studio 1, on line 16, at character 17 from the left, which is inside of the function myFeature</p>
<p>Clicking any line in the stack trace will bring us to that line of code, making it easy to find where the error happened. Sometimes the error can happen in the Onshape std library if you give bad inputs into a std library function. Typically, I start looking at the first line of the stack trace that does not start with <em>onshape/std/</em> , as I want to know where my own code is throwing an error. Onshape most likely did not let any bugs slip into std code. </p>
<p>When a feature calls a function, and that function calls a function, all of those layers are shown in the stack trace. If a function is called from multiple places, this can help drill down to which function was the source of the error.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_a48ee3826d4344779a577112f3b521eb.png" alt="" loading="lazy"></figure>
<p>While this shows where the error is ultimately found, it doesn't always show the source of the bug. In my example, the error is adding together incompatible types, but the bug is that one of my values is different than expected. At some point before that error, I have assigned the wrong value to a variable - and that is the bug that needs to be fixed.</p>
<h2>Println</h2>
<p>The println statement is as old as time itself. Some even believe our universe started when someone wrote println("hello world") into the universe console.</p>
<p>In compiled languages like C#, debug tools can run a program line by line, allow you to stop at any point, look at what values are set in memory, and even rewind, in order to help track down bugs. Unfortunately, FeatureScript does not have this power. In order to see what value a variable has at some point in the code, we have to write code to understand our code.</p>
<p>The function <em>println()</em> does a <em>toString()</em> of the input, appends a new line character, and outputs it to the FeatureScript notices tab. This allows us to "see" a value at a point in time. We can check our expectations vs reality by using the <em>println()</em> statement to either print the value of a variable, or even meta data such as just tags to check if a section of code has been run.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_2ee4cd798f6740b8acf4597f73c667fc.png" alt="" loading="lazy"></figure>
<p>Println is a valuable debug tool, even just to keep your sanity. Here are a few tips:</p>
<ul>
<li>
<p>Printing simple and unique strings can help determine if the code in a function even ran, like little checkpoints</p>
<ul>
<li><em>println("My function name")</em></li>
<li>
<p>Instead of just printing the value, printing a label to go with it can help keep things organized in your output</p>
</li>
<li>
<p><em>println("Var a \= "\~toString(a))</em></p>
</li>
<li>Getting unexpected results? Sanity check the inputs of the function or operation by printing all of the inputs</li>
</ul>
</li>
</ul>
<h2>Debugging Geometry and Queries</h2>
<p>Println really only works for data that can be represented with strings and numbers. FeatureScript is unique in that the output is geometry. It becomes a new challenge in validating what a query actually is vs what we expect it to be. But we are given some unique tools to help debug.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_a7e339a4e4384da5be12134b741670f7.png" alt="" loading="lazy"></figure>
<p><em>AddDebugEntities</em> - this function highlights the given query when the Feature Dialog is open. Most importantly, it highlights the entities as they are at that point in the code. This function gives as snap shot of what is contained within a query. This is incredibly useful for validating that a query is pointed at the right entities. Whenever a write a complex query, I will double check my code by running an <em>addDebugEntities</em> and verifying that my query is correct. Catching an incorrect query later on in my code is tricky. Is my boolean failing because of logic or because of the query?</p>
<p>Clean and robust code should validate and filter entities. Lets take for example a opBoolean. We are going to be putting in solid bodies to join into a single body. Using the query <em>qEverything(EntityType.BODY)</em> , we get a failure. But why? That query contains all bodies, but does not check if they are solid bodies. Before we call <em>opBoolean</em> we can improve our query:</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9fb62db9c2764f048731e1c91c086b33.png" alt="" loading="lazy"></figure>
<p>In this section of code, we have filtered our query to just solid bodies, and before running the boolean, we check if the query is empty. If the query is actually empty, it might be good to do an else statement and either display a message or run some alternate code. In a similar fashion, we can also verify single entity queries with a <em>qNthElement(myQuery, 0);</em></p>
<p>Here's a few more tricks to working with queries:</p>
<ul>
<li>
<p>Check the documentation of the operation for what query type it is expecting. </p>
<ul>
<li>opBoolean does work on sheet bodies, but not faces. Mixing up up face queries and sheet body queries is a common mistake.</li>
<li>qOwnerBody and qOwnedByBody can both be used to go between body and face/edge/vertex queries.</li>
</ul>
</li>
</ul>
<h2>Tips and Tricks</h2>
<ul>
<li>
<p>Most bugs are made either from simple mistakes or bad assumptions. Sounds deep, but in reality this is what I look for first. If I had a nickle for each time I used Entity.BODY instead of Entity.FACE. Knowing that you are likely to make a simple mistake, I know to look for things like:</p>
<ul>
<li>copy pasting a line of code, but not switching a variable</li>
<li>using auto complete for a query, but not using the right entity type</li>
<li>did I validate that the query was non empty?</li>
<li><a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging">Get a rubber duck</a></li>
<li>Test early, test often. When designing a model in the feature tree, you have the ability to validate what you are doing each step of the way. Its a good idea to do the same when writing a FeatureScript. Stopping to check your output after each context modifying operation helps development go smoothly.</li>
<li>Adddebugpoint and adddebugarrow are both super helpful for understanding vectors, lines, and planes. Like debugentities, it lets you visualize in Onshape what the value is at a point in time. Its helpful for tracking down opposite direction issues, flipped planes, or bad vector math.</li>
</ul>
</li>
</ul>
<p>If after all that, you feel like giving up, shoot me an email. I have reasonable rates, and can deliver quality custom features quickly: <a href="mailto:caden.armstrong@smartbenchsoftware.com">caden.armstrong@smartbenchsoftware.com</a></p>]]></content:encoded></item><item><title>Practical Applications of FeatureScript</title><link>https://www.smartbenchsoftware.com/post/practical-applications-of-featurescript/</link><guid>https://www.smartbenchsoftware.com/post/practical-applications-of-featurescript/</guid><pubDate>Thu, 25 Apr 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>I recently gave a talk about the practical applications of FeatureScript, but for those unable to see it in person, I decided to write it up as a blog post. FeatureScript gets…</description><content:encoded><![CDATA[<p>I recently gave a talk about the practical applications of FeatureScript, but for those unable to see it in person, I decided to write it up as a blog post. FeatureScript gets talked about a lot in the Onshape space, it what makes Onshape <em>Onshape.</em> Unlike other automation methods, like macros and APIs; its not an afterthought, its the core of Onshape. Onshape uses FeatureScript to create Onshape.</p>
<p>Beyond the publicly available FeatureScripts, most applications of FeatureScript are hidden behind the closed doors of protected IP. Even for my presentation demos, I wasn't able to show customer data. All of the samples shown here have been purpose made for this talk, scrubbing any actual design data. But this also shows how fast a feature can be made; its not a weeks long effort, I was able to spin up some functional demo features in a few hours.</p>
<p>There are many uses of FeatureScript, but I wanted to isolate 3 categories that I see the most often and provide a clear value proposition. Standardization, Process automation, Complex designs.</p>
<h2>Standardization</h2>
<p>In a parametric CAD, "features" tend to be design elements like extrudes, fillets, lofts, etc. As parametric CAD matured, this extended to more complex features like weldments and sheet metal. FeatureScript opens the opportunity to rethink how designs are made, focusing on "feature": common design elements, and designing around them. Like building from lego bricks. Ditching the tedious process of sketches, extrudes, etc, to make repetitive design elements bring in the benefit of faster designs and fewer mistakes. When designs are highly constrained to a standard, encapsulating the design into a feature prevents potential for human error.</p>
<p>When to use?</p>
<ul>
<li>Common design elements</li>
<li>Design must adhere to a specific standard</li>
</ul>
<h3>Examples</h3>
<ul>
<li>Bicycle frame bottom brackets</li>
<li>Hydraulic Manifold design</li>
</ul>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3011f626b69c47419a08be347dedaf00.png" alt="Onshape SAE J1926 Straight thread port feature" loading="lazy"><figcaption>Onshape SAE J1926 Straight thread port feature</figcaption></figure>
<p>In Hydraulic Manifold design, common ports are added to a block to create a hydraulic circuit. Port must meet a specific standard, as off the shelf components must fit and thread into the cavity. These ports are so common that Porting Tools that match the specific standard are used to quickly and accurately cut the holes. Each port is a series of stepped holes, with various chamfers and fillets. Having a designer sketch the port for each and every use is not only incredibly labor intensive, but ripe for costly mistakes. </p>
<h3>Bottom Bracket</h3>
<p>The bottom bracket on a bicycle frame is a standardized design element that needs to work with off the shelf components. A frame designer is not going to redesign the bottom bracket for each frame (at least not without making everyone very mad). The bottom bracket is a design choice: which standard to pick. While the design is fairly simple, it presents opportunity for mistakes, and adds additional time to creating a design.</p>
<p>With the feature demoed below, its as simple as a few clicks, and the bottom bracket is added to the frame. Its so fast, you can blink as miss it. An additional benefit of the feature is in the choice to not allow placement. For this client, the bottom bracket is the origin of the model, and needs to be in a specific plane. By fixing the position of the feature, it adds an additional check to the frame design to ensure mistakes aren't being made.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_35bffd37ae934d2385a6d7ec2cd11c3c.gif" alt="Bottom Bracket feature - on a definitely real bike frame" loading="lazy"><figcaption>Bottom Bracket feature - on a definitely real bike frame</figcaption></figure>
<h2>Process Automation</h2>
<p>Automating a series of click to produce a result of a number of steps is perhaps the most intuitive option for a custom FeatureScript when a user is coming from the desktop CAD world. </p>
<p>Process automation is a big timer saver, and a great use of FeatureScript. For a process that is well described, multiple features can be combined into a single custom feature to ensure process standards are met with minimal design effort.</p>
<p>Lets look at an example: PCB breakaway tabs. These tabs are a common element of manufacturing PCBs, providing fixturing for the boards while they are being cut, with the added benefit of providing a no-tool option to free the board from the larger panel. Changes to the PCB design propagate down this design tree requiring extensive sketch modifications in order to place the breakaway, create routing channels, margins, etc. With the custom feature shown below, that all becomes a single step.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f21d3fdab9034d51b5d5ead4d775700c.gif" alt="" loading="lazy"></figure>
<p>The additional benefit of FeatureScript is that this feature is parametric. Changes to the PCB design don't require re-running an entire process, changes propagate through the feature tree as they would for any other feature. Because Onshape is built on FeatureScript, custom features can even be configured, just like any other feature. This means that designs can be quickly and easily iterated.</p>
<h2>Complexity</h2>
<p>Its not difficult to think of data driven modelling challenges that currently can't be done with the current tool set. FeatureScript opens up new options for generating features that previously couldn't be created. Unlike a macro, FeatureScript has the added benefit of keeping the feature Parametric, configurable, and with design intent as inputs.</p>
<p>Take for example, a variable pitch helix. How would you create a variable pitch helix in a traditional method? The best I could come up with is a fit spline sketch that is then wrapped around a cylinder. But what about a variable pitch helix on a conical surface?</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_0d36bd2ec5164ee1abf1ee165dde0a44.png" alt="" loading="lazy"></figure>
<p>This variable pitch helix is able to create a curve that otherwise wouldn't be possible. And unlike a macro, its fully parametric. The inputs aren't complicated equations, they are simple parameters drive by design intent.</p>
<h2>Experience as a Developer</h2>
<p>To answer the question that nobody was asking: what is the experience like as a FeatureScript developer? This is an important question, because all of the great things about FeatureScript culminate in a very positive experience. Coming from the desktop CAD world, many of the issues I had simply don't exist with FeatureScript development. There is a reason why I have shifted my business to focusing on FeatureScript and Onshape integrated applications. They are just less stressful to deal with, I waste less time on non-development issues. I am better able to focus on new and cutting edge ideas.</p>
<table>
<thead>
<tr>
<th></th>
<th><strong>Desktop CAD</strong></th>
<th><strong>Onshape</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Environment</strong></td>
<td>"But it works on my computer"</td>
<td>Everyone has the same Onshape</td>
</tr>
<tr>
<td><strong>Deployment</strong></td>
<td>Emailing installers, requires IT to help deploy</td>
<td>Instantly available</td>
</tr>
<tr>
<td><strong>Data Security</strong></td>
<td>Emailing files</td>
<td>Restrict with Onshape permissions, code developed inside your own enterprise, models never leave</td>
</tr>
<tr>
<td><strong>Version Control</strong></td>
<td>Up to the developer</td>
<td>built in version control</td>
</tr>
<tr>
<td><strong>Bug fixes</strong></td>
<td>Requires replication and redeployment</td>
<td>Documents with issues can be shared, no need to replicate. Bug fixes are as simple as updating the linked feature.</td>
</tr>
<tr>
<td><strong>Result</strong></td>
<td>Slow, annoying</td>
<td>So fast, so easy</td>
</tr>
</tbody>
</table>
<h3>Inspired?</h3>
<h3>If you are looking to have a custom FeatureScript developed, don't hesitate to reach out!</h3>
<p><a href="mailto:caden.armstrong@smartbenchsoftware.com">caden.armstrong@smartbenchsoftware.com</a></p>]]></content:encoded></item><item><title>FeatureScript Optimization</title><link>https://www.smartbenchsoftware.com/post/featurescript-optimization/</link><guid>https://www.smartbenchsoftware.com/post/featurescript-optimization/</guid><pubDate>Fri, 15 Mar 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Note: Onshape update 1.180 improved performance of the normalize function.</description><content:encoded><![CDATA[<p><em>Note: Onshape update 1.180 improved performance of the normalize function.</em></p>
<p>Inspired by a discussion with fellow FeatureScript expert <a href="https://forum.onshape.com/discussion/23461/normalize-vs-normalize-std-library-speed-difference-you-wont-believe-the-difference">Jacob</a>, and some recent customer requests, I've been surrounded by the topic of FeatureScript optimization. I wanted to give a short primer on optimizing FeatureScript, and some tips and tricks.</p>
<h2>Regen time</h2>
<p>The first thing to know about FeatureScript (and Onshape) is to know what we are looking to optimize. In a parametric CAD model, changing a feature's definition will cause the geometry of the model to update. If a feature in the middle of the tree is updated, all downstream features also need to update. The longer this regeneration takes, the slower updating and iterating a design will be. For most Onshape built in features, the performance is pretty good. But for extremely complex custom Features, that regen time can shoot up to huge numbers in the range of 1-20 minutes. I'm sure you can imagine how annoying it would be to update a model with a 20 minute regeneration time. Which gives motivation for optimizing when regen time starts to grow above an acceptable amount.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_edd5d9989dd14f8c871f51a7310e3648.png" alt="Onshape Regeneration Times" loading="lazy"><figcaption>Onshape Regeneration Times</figcaption></figure>
<h2>Profiling</h2>
<p>The first step to optimizing a custom feature is to profile your feature. In order to profile a feature, you need to first insert the feature into a part studio (and not have any errrors). Next, in your feature studio select the option to profile the part studio. Its important to note that profiling can be quite slow compared to regeneration time, typically up to 10x slower.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_4094f6fe04564975b87c31740ea49857.png" alt="" loading="lazy"></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_f09ba3bda2f741d98533bb8f6b5781db.png" alt="" loading="lazy"></figure>
<p>The result of Profiling is a list of all of the slowest calls in the FeatureStudio. The total time and number of calls is shown, along with a colour indicator in how much time was spent on that call compared to the rest of the feature. This is a great place to start because we know where to focus our efforts to make the largest gains.</p>
<p>In the example on the right, we can see our feature takes 422ms to regenerate, but the evDistance call is 340ms of that time. </p>
<h4>Tips for performance Increases</h4>
<p>In no particular order</p>
<h2>Tip 1 - Minimize resource intensive calls</h2>
<p>When you start to profile your features, something you will notice is that any call starting with ev or op is almost always going to be most resource intensive call in FeatureScript. These evaluations and operations are either modifying geometry or require a lot of intense math to produce a result. The simplest improvement to be made is simply to think about writing your feature in a way that minimizes these calls. Storing the result of an evDistance is going to be faster than calling it every time you need that value. </p>
<h2>Tip 2 - Built in functions</h2>
<p>If you go poking around in the Onshape std code, you'll find an interesting type of function starting with @. These functions seem to have no documentation, and you can't control click into them. Thats because these are the "built in" functions. These functions are the lowest level function accessible in FeatureScript. The call is not interpreted by FeatureScript, it gets sent off to the black box of Onshape's back end. Built in functions offer a trade off, improved speed at the cost of ease of use and stability. Onshape wraps most of these functions so the average FeatureScripter has an easy and consistent experience. But if you are looking for gains, here are a few simple swaps to see big improvements.</p>
<table>
<thead>
<tr>
<th>Regular Function</th>
<th>Built-in</th>
<th>Speed Gain</th>
<th>Caveats</th>
</tr>
</thead>
<tbody>
<tr>
<td>normalize()*<em>Note this data was collected on an older version of Onshape. Improvements have made this irrelevant</em></td>
<td>@normalize()</td>
<td>20-50x</td>
<td>*No longer necessary due to Onshape Updates</td>
</tr>
<tr>
<td>evDistance</td>
<td>@evDistance</td>
<td>2x</td>
<td>The result distance has no units (its in meters), and the queries are not cast to a Query object</td>
</tr>
<tr>
<td>size</td>
<td>@size</td>
<td>3-4x</td>
<td></td>
</tr>
<tr>
<td>evLength</td>
<td>@evLength</td>
<td>2-3x</td>
<td>The result has no units</td>
</tr>
<tr>
<td>evPlane</td>
<td>@evPlane</td>
<td>4-5x</td>
<td>The result has no units. Vectors are arrays. How you cast to a vector can change your performance result</td>
</tr>
<tr>
<td>constructPath</td>
<td>@constructPaths</td>
<td>10-20x</td>
<td>The result query data needs to be manipulated into query objects, losing a bit of speed.</td>
</tr>
</tbody>
</table>
<h2>Tip 3 - Queries</h2>
<p>A common beginner mistake in FeatureScript is to evaluate the query when its not required. Queries are a great part of FeatureScript design. Instead of carrying around the heavy load of entity data, the Query is just a set of instructions on how to find the entities you wish to pass into an evaluation or operation. Might seem weird that the query doesn't contain entity data, but by passing instruction into Onshapes back end, the process is much more efficient. Many scripts do not need to ever call evaluateQuery, unless you need to know the current number of elements that a query resolves to.</p>
<p>Building good queries over using evaluated data is good practice in efficient scripts. Consider qLargest vs evaluating the area/volume/length of each entity in a query. qlargest has minimal regen time compared to the effort of calling evArea or evLength many times.</p>
<h2>Tip 4 - Skip the units</h2>
<p>FeatureScript's 'valueWithUnits' is fantastic. It gets rid of so many headaches in programming for a CAD system, I love it. But it does come with a small performance cost. Any math operation on a valuewithunits takes longer than a primitive value (ie double), as theres always a units translation step. If you are looking to do a bunch of intense math and can keep consistent units, you can see performance gains by not using value with units, and just using primitives. This tip is more relevant if you are also using built ins, as most Onshape operations give back values with units.</p>
<h2>Tip 5 - Use Math</h2>
<p>FeatureScript makes a lot of the math and CAD development pretty easy, and its part of why FeatureScript is so accessible. But the ease of use shouldn't prevent you from remembering highschool math.</p>
<p>Distance between two points? evDistance? No...</p>
<pre><code>var pointDistance = norm(pointa-pointb);
</code></pre>
<h2>Tip 6 - Fit Spline is faster than a sketch</h2>
<p>Just making a straight line? Skip the sketch and use a two point fit spline.</p>
<pre><code>opFitSpline(context, id + &quot;fitSpline1&quot;, {
    &quot;points&quot; : [
        pointA,
        pointB
    ]
});
</code></pre>
<h2>Tip 7 - Rethink your inputs</h2>
<p>Having a magic feature that automatically finds all of the geometry is a nice to have, but sometimes the fastest feature is the one where a human clicks the right edge for you.</p>]]></content:encoded></item><item><title>Use Chrome Extensions to Automate Onshape</title><link>https://www.smartbenchsoftware.com/post/use-chrome-extensions-to-automate-onshape/</link><guid>https://www.smartbenchsoftware.com/post/use-chrome-extensions-to-automate-onshape/</guid><pubDate>Thu, 15 Feb 2024 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Officially, there are two ways to automate with Onshape: The API and FeatureScript. Both the API and FeatureScript work extremely well and allow a good deal of innovative ways to…</description><content:encoded><![CDATA[<p>Officially, there are two ways to automate with Onshape: The API and FeatureScript. Both the API and FeatureScript work extremely well and allow a good deal of innovative ways to achieve automation with Onshape. But despite best efforts, some parts of Onshape just aren't accessible. The FeatureScript notices tab, the measurements window, or even folders in the feature tree. But, I have discovered that a Chrome Extension has the ability to achieve automation never seen before (and very likely not recommend by Onshape)</p>
<p>Chrome extensions are fairly common (especially ones like ad block), but have you ever thought about how they work? Its surprisingly simple. A chrome extension is essentially a web page with access to some browser specific APIs, such as getting information about open tabs, or the current page. The key here is that Chrome gives the option to inject new code into any web page. This is how extensions like the <a href="https://chromewebstore.google.com/detail/xkcd-substitutions/jkgogmboalmaijfgfhfepckdgjeopfhk">XKCD replacement</a> extension work. A script is injected that looks at the page and modifies the content.</p>
<p>So how can we use this to help automate Onshape?</p>
<p>Chrome extensions give two possibilities within Onshape: extracting data from the page, or add new elements to the page.</p>
<p>Extracting data from an Onshape page is both fairly easy, and very hard. Getting visible data is fairly trivial, the challenge comes when the data isn't visible. This was a challenge that I faced when I created my first chrome extension for extracting the <a href="https://cad.onshape.com/documents/10da8e9ce9d1d0a16068480c/w/312601f5264f581803286143/e/a33f6d04308f248640bac682">FeatureScript notices tab</a> data. When the FeatureScript notices tab is open, its easy to grab that data and save it out as a txt file. But what if the user does not have the tab open? If the tab isn't open, Onshape does not load that data anywhere. It only gets loaded when the tab is open. The solution was to first check if the tab was open, and then programmatically click the FeatureScript notices tab to open it, extracting the data, and then clicking it again to close the tab. This all happens so fast that the user has no idea the tab was even opened.</p>
<p>Extracting data is an obvious solution, but what about adding new elements to the Onshape page? Adding new buttons and menus is a fairly common possibility in a desktop CAD, but is a bit more limited in Onshape. Integrated applications have a list of options where new buttons/tabs can be added. In short, its mostly limited to right click context menus, and the right panel in a design studio. This makes sense from a technical standpoint, but limits options forcing all automation into a few contexts. But with a Chrome Extension, we can insert new buttons, text, graphics, anywhere in the Onshape page. This allows us to add automation into a context that makes sense.\
Take for example a button that would export all of the comments on a document. The most logical place to put that button is in the comments area of Onshape. With a Chrome Extension, we could detect the comment tab being opened, and add a new button that would perform that export action. The options for adding to Onshape are only limited by your imagination.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_480750d6bf3a4a7fa7f2a2b8e047ac3b.png" alt="" loading="lazy"></figure>
<p>One last interesting point about using Chrome Extensions with Onshape is about using the API. Typically for an Onshape integrated application, the app needs to go through the Onshape Authentication process in order to access the API. This is good security and expected behaviour. The interesting difference for a Chrome extension is that the code is being injected into the Onshape page. If an API request is done with injected code, it utilizes the existing authentication. This means that a chrome extension skips the need of API keys, or going through OAuth. The extra fun part, is that Onshape is the origin of the requests, which actually gives us access to internal only APIs that are otherwise not publicly accessible. </p>
<p>What are the downsides to using a Chrome Extension? Well, there are plenty. Firstly, it does add some IT overhead and challenges. What's great about Onshape is that there is no installation or deployment. Onboarding new Onshape users is a breeze. Adding a custom Chrome Extension into the mix requires installing on every users computer, and then keeping them up to date when changes are made.</p>
<p>The next downside is stability. Any changes made to Onshape could result in the extension breaking. Typically FeatureScript and the API are backwards compatible, maintained in a way that does not break existing applications. Using a very unofficial method is sure to not be maintained or supported by Onshape, resulting in some headaches long term.</p>
<p>Lastly, complexity. Some automations, such as adding a new button, or reading the FeatureScript notices, is fairly simple. On the other hand a lot of automation ideas turn out to be incredibly complicated. The time required to develop an automation with a Chrome Extension might exceed the value provided by the extension. This is a very new idea, and is extremely experimental. Proceed with caution.</p>]]></content:encoded></item><item><title>Rethinking the Engineering Team</title><link>https://www.smartbenchsoftware.com/post/rethinking-the-engineering-team/</link><guid>https://www.smartbenchsoftware.com/post/rethinking-the-engineering-team/</guid><pubDate>Thu, 03 Sep 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Since the introduction of CAD programs, the usage of computers has taken over the engineering world. Old-timey rooms full of drafters, decked out in white shirts and ties,…</description><content:encoded><![CDATA[<p>Since the introduction of CAD programs, the usage of computers has taken over the engineering world. Old-timey rooms full of drafters, decked out in white shirts and ties, furiously sliding rulers simply don’t exist anymore. Other parts of the engineering world have similarly changed. Document control is taken over by PDM software, project management tools for things like gantt charts are a dime a dozen. A heavy reliance on technology is there, but most engineering teams are not making the most of this digital world. In an engineering team, the individual roles and how they interact have evolved, but the team make-up itself hasn’t. I believe it is time to rethink engineering teams, and the addition of a <strong>developer role</strong>.</p>
<h2>Value of a Developer</h2>
<p>The big question when deciding to add a developer to a team is: what value do they bring. A developer isn’t going to be right for every team, so it is good to understand what ROI they bring. The benefits that developers bring can be split into three categories; reducing engineering work, reducing costs, and solving the previously impossible challenges.</p>
<p>The most obvious benefit is directly saving time on daily engineering tasks. If the time a developer can save an individual engineer is known, the cost analysis is simple. For example, we start by assuming that a developer is paid similarly to an engineer. If a developer is able to save an engineer 10% of their time, it would take a team of 10 engineers for the developer to be valuable. But if you look at it another way, one developer can replace an engineer in a team size of 10. For a team size of 20, that developer gains the same benefit as hiring 2 additional engineers. As the size of an engineering team grows, the potential value that a developer can bring grows to the point where it should be a necessity. A 100+ person engineering team should absolutely have a software developer in the mix.</p>
<p>The time cost analysis is a simplistic view of what a developer brings. It assumes that all work a developer can provide is directly reducing that of an engineer’s. But a developer has the potential to provide value in a way that an engineer can’t. Improvements such as error reduction, reduced lead times, more accurate quotes, and reduced waste, are all common when introducing new software technologies to a company. Look at not just the value of an engineer, but also the money they can cost a business. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_495c6ed91e644d77b1a86ed8dca9ba4a.png" alt="" loading="lazy"></figure>
<p><strong>"</strong><strong><em>Any sufficiently advanced technology is indistinguishable from magic</em></strong><strong>" - Clarke's 3rd Law</strong></p>
<p>Finally, a developer can bring unknown value through their black magic. It might not be real magic, but it can feel that way. When I work on design automation, I can create features that a designer would never be able to. Designs that would otherwise be impossible can add an unknown amount of value to a business. Likewise, work that would have been too time consuming can be done by a program. Engineers saying "<em>Nah that would take too long</em>" isn't an excuse anymore.</p>
<h2>Hiring a developer</h2>
<p>You see the benefit of a developer, now what? If you’re on the fence about hiring a developer, one option is to hire a consultant. The per hour rate of a consultant is going to be much higher than an employee, but the benefit is that 1) they will already be an expert and not require training, 2) there is no longer term commitment. But this does involve finding an expert. Finding a consultant who does not have the experience and expertise in this specific instance is going to give false numbers. The person you got to do your website is going to take 100x longer than the person who has 10 years experience working with CAD integrations. </p>
<p>Hiring a consultant gives an additional benefit, they know what can be automated. Every time I talk to engineers and discuss their challenges, many of their problems end up being easily fixed. Knowing a better solution could exist is half the battle. An engineer spends the whole day problem solving, so finding a workable solution is usually what they do. But they don’t always have the expertise to build a proper solution. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_1d9bfeff506d4dd3934051f5d142ab3f.jpg" alt="" loading="lazy"></figure>
<p>You've decided to hire a developer full time to join your team. How do you find the right one? You probably want one who knows your CAD system, who has engineering knowledge, and 10 years experience. Too bad, that person is happily employed elsewhere. But I'll let you in on a secret: developers can be trained. A developer needs to learn more than just new technologies, but also engineering industry knowledge. Instead of looking for a developer that is already perfect, look for one with good potential. Developers that are keen to solve problems, be creative, and dive deep into a subject. </p>
<p><strong>Stay tuned for a future piece on training developers...</strong></p>
<h2>How to work with a developer</h2>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_21291512d0f14cd8828035338f755207.png" alt="" loading="lazy"></figure>
<p>Now that you’ve hired a developer, the question is, what do you do with them? A developer on the team is going to be a new challenge for an manager. Their tasks, timelines, needs, and knowledge are all going to be different. </p>
<p>Treating a developer as a team member is important. If your company does daily standups, weekly or monthly team updates, include the developer in those meetings! They will be able to spot issues that they can solve. Not every project will be delivered to them by their manager. Treating a developer as a separate department, or external resource puts up unnecessary walls. A developer should always have direct access to the other team members that they are there to benefit. Put them in the same room as the engineers. Having to go through a chain of command for everything is a sure fire way to reduce the usefulness of your developer, and potentially frustrate them.</p>
<p>Remember that there are now two perspectives to every problem: the developer way, and the engineer way. It is crucial to respect that a developer will make the correct decisions within their domain. Should the app be Java or Javascript? If you need to ask, then leave it to the developer. Another challenge to deal with is two sets of projects. The engineers will be working on some cool new bracket, while your developer workers on a optimized shelf tool. These two projects will have different timelines and hurdles. Finally, they'll also require different forms of feedback. Your developer doesn't have a customer, for them to continually improve, you need to give them constructive feedback. Their success won't always be apparent to them.</p>
<h2>Caden’s Musings - Onshape</h2>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_827d7f3d228c443fa143454e0c712287.png" alt="" loading="lazy"></figure>
<p>I’ve been working a lot with Onshape and FeatureScript to do design automation. In a recent project, I had to make a model of a part that would be used in an automation. But modeling the part I ran into some issues. I had problems such as needing a plane offset from the tangent of a line relative to how another line was offset from an axis. An experienced designer might have had a clever way to solve these problems, but I am not an experienced designer. Luckily, I had FeatureScript at my disposal. In less than 5 minutes I had a feature whipped up that could do exactly what I needed. In this case, I was making up for my own shortcomings in CAD design experience, but it got me thinking about how valuable a developer could be on an engineering team. </p>
<p>For large automations, which make up the majority of my work, the ROI is obvious. Saving thousands and thousands of engineering hours is a no brainer, and traditionally that was the minimum to make something worth automating. Doing design automation for most CAD programs, the development time for a feature is huge. But FeatureScript is different, the effort to create a valuable feature is astronomically less, so smaller features can be worth creating. This is my motivation behind the thought that engineering teams should shift to include a developer. FeatureScript is a big change in the industry, and will be a catalyst for changing how engineering teams are created.</p>]]></content:encoded></item><item><title>Onshape, The Future of CAD?</title><link>https://www.smartbenchsoftware.com/post/onshape-the-future-of-cad/</link><guid>https://www.smartbenchsoftware.com/post/onshape-the-future-of-cad/</guid><pubDate>Sat, 08 Aug 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>Recently, I have begun working with the new-ish CAD system: Onshape. Onshape is a cloud based CAD software combining both modeling software and PDM. I’ve worked with more than a…</description><content:encoded><![CDATA[<p>Recently, I have begun working with the new-ish CAD system: Onshape. Onshape is a cloud based CAD software combining both modeling software and PDM. I’ve worked with more than a dozen different CAD softwares creating various types of addins, and Onshape very clearly stands apart. </p>
<p>Creating an addin for most CAD software generally works in the same way. You create your program (usually in C#), place the program in a specific location, and the CAD loads it in and handles the rest. With this process, you have control over deploying your application (and licensing), and to an extent, the libraries and technologies you choose to implement your solution. The difficulty in typical CAD add ins is the implementation process. Debugging and testing can be extremely difficult and time consuming. The available APIs generally give the bare minimum in terms of functionality. There is no help with the math or geometry, which can add to the development time and difficulty.</p>
<p>Working with Onshape has been a different experience. As a software developer, 3 key aspects stand out the most.</p>
<h2>Document Management</h2>
<p>Document management, version control, and sharing are all a challenge for most CAD programs. Entire separate PDM solutions are sold to accommodate these challenges. PDM’s have their own issues. The IT cost of having a server and VPN solution for remote access. Files require being “checked in” or “checked out” limiting file usage to a single designer. </p>
<p>Onshape works a lot like a cloud storage solution, such as Google Drive or DropBox. Users can very easily share documents, and even work on documents concurrently. The surprise feature here is that when another user is in a document. You can “follow” a user, and see the document from their point of view. A nice feature when collaborating with a remote employee.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_47ab52b4b1454ba5af5ec66a42e06f91.png" alt="Onshape's Branch based version control" loading="lazy"><figcaption>Onshape's Branch based version control</figcaption></figure>
<p>The biggest change from other CAD programs is how version control works in Onshape. Most developers have used either a Git or SVN type system. Onshape gives similar features with branching version control. Branches give great flexibility when modifying documents that may become their own separate document, or for a set of changes that need to be implemented alongside another development stream. Your changes do not affect another user’s changes until the branches are merged. Onshape’s version control system is definitely the future of document management. No other solution offers the same collaboration options, and other CAD's would require huge changes to catch up.</p>
<h2>Barrier to Entry: Custom Features</h2>
<p>A custom feature is something that ranges from hard to impossible to implement. It takes a lot of specific technical know-how, and usually years of experience with a specific CAD. As a result, any custom work that needs to be done is unlikely to happen in house, and finding an expert could be challenging. </p>
<p>Onshape’s solution is “FeatureScript”. Built right into Onshape is an IDE for their custom development language. FeatureScript has been specifically designed for creating design features. It is chock full of functions to aid in the creation of a feature. </p>
<p>The barrier to entry in creating a custom feature is unbelievably low. While all programming requires a little bit of a learning curve, basic programming concepts and a good understanding of parametric design can get you started.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_3c61e161e6ac4358afe90d3c747c5bdc.png" alt="" loading="lazy"></figure>
<p>The tutorial feature shows a user how to create a "slot" feature, used for joining laser cut pieces. The tutorial takes maybe 15-30 minutes to complete, and lets the user create a slot feature with a few clicks.</p>
<p>For a more experienced programmer, FeatureScript offers some powerful options for design automation. Curious what that looks like? <a href="https://github.com/dcowden/featurescript">Look through this github page</a> full of excellent samples. FeatureScript seamless handles everything from wood working joint automation to nesting. When features become this easy to automate, the bar for "is this worth automating" becomes much much lower. Companies using Onshape should seriously consider on-boarding a developer before expanding and already large design team. The overall time savings could be huge.</p>
<h2>Cloud?</h2>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_c90107a9b6694139852d3ec5d75974dc.png" alt="XKCD 908" loading="lazy"><figcaption>XKCD 908</figcaption></figure>
<p>The obvious point of contention to Onshape is that it is a cloud based solution. There’s a lot of argument about ongoing costs, freedom, etc. But from a developer’s perspective, the only real issue is that it requires an internet connection 100% of the time. When the internet goes down there is nothing you can do. But, as a cloud solution, users gain a whole lot.</p>
<ul>
<li>Updates to Onshape are painless. They happen like magic.</li>
<li>Most computers work. CAD programs require powerful computers to run smoothly. In a time where companies are investing in work from home measures, powerful computers can be a huge cost. It’s not suggested, but I can even load Onshape up on my phone in a pinch.</li>
<li>On-boarding is a breeze, file sharing is easy, and collaboration is actually possible.</li>
<li>Support is a much simpler process. The support team has access to both your models and the same CAD setup as you, so there's no confusion and "system specific issues" that can't be fixed.</li>
<li>Remote work is trivial - pretty relevant right now.</li>
</ul>
<h2>Conclusion: Onshape is great!</h2>
<p>It hasn't been long, but I've been greatly enjoying working with Onshape and FeatureScript. Its been a very different experience from working other CADs, almost unreal. The workflow for creating a feature is so simplified, it almost feels like something is missing. No messing around with UIs, installers, dll's of unknown versions. There hasn't been a moment of "But the solution works on my computer". I've spent a larger portion of my time directly on the solutions that create value.</p>
<p>Onshape is a fresh take on CAD, and I'm excited for its future.</p>]]></content:encoded></item><item><title>Learning UX from Video Games</title><link>https://www.smartbenchsoftware.com/post/learning-ux-from-video-games/</link><guid>https://www.smartbenchsoftware.com/post/learning-ux-from-video-games/</guid><pubDate>Sun, 14 Jun 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>The User Experience (UX) of a program, app, website, or video game encompasses both the look and feel of the product. The design of a program from keyboard shortcuts to fonts, has…</description><content:encoded><![CDATA[<p>The User Experience (UX) of a program, app, website, or video game encompasses both the look and feel of the product. The design of a program from keyboard shortcuts to fonts, has an impact on the usability of the product. Menus that are difficult to navigate slow down every action. Fonts that are hard to read can add eye strain and introduce additional human error. Every design decision in the UI should consider the impact on a user.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9c5290b4f1274e87a6f947e5d71556c2.gif" alt="An example of very bad UX" loading="lazy"><figcaption>An example of very bad UX</figcaption></figure>
<h2>Case Study: Autodesk Navisworks</h2>
<p>Navisworks is a 3D Model review software used in the architecture and construction industry. When a building is being designed, builders and engineers are able to use Navisworks to virtually walk through their model, and spot potential issues before breaking ground. Navisworks is a little different from other CAD programs in that a majority of the modelling has already been done, navigating, observing, and collaboration are the key functions.</p>
<p>Presenting a 3D world to a user through a 2D medium (a screen) poses challenges for navigation and spatial orientation. These same challenges are shared with video games. A player being able to immerse themselves in the virtual environment, and being able to efficiently navigate are key to enjoying the experience. But over the years, gaming has found a few solutions to these problems, and the CAD industry could benefit from.</p>
<h2>The Minimap</h2>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_b1dce391bfb94869bfb44f626c94ac34.png" alt="Dota 2 - A game with a minimap" loading="lazy"><figcaption>Dota 2 - A game with a minimap</figcaption></figure>
<p>The minimap is a common site in games where a player is required to navigate a virtual world. Typically situated in the corner of the screen, the minimap is a small representation of the larger world around the player. Minimaps have a few distinct features:</p>
<ul>
<li>Simplified for quick and easy reading</li>
<li>Provides both orientation and position information</li>
<li>Includes key information about your surroundings, either land features, quests, or other players</li>
</ul>
<p>In the above example, the game Dota 2, has a minimap providing at a quick glace: enemy and ally positions, and status of various buildings. An example we can take inspiration from.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_c2250eea6e12479db2eef815f344dba5.png" alt="Existing Navisworks Plan View" loading="lazy"><figcaption>Existing Navisworks Plan View</figcaption></figure>
<p>Navisworks does include a navigation map (plan view), but it's missing a number of elements that make minimaps so useful. Firstly, it's hidden away in a tab, and when that tab is expanded it covers the model view. You can either see the model, or know where you are in the model. Minimaps usually exist as an overlay to the main screen. Tucked away in a corner, it gives positional context at a glance, without sacrificing the core content or main view.</p>
<p>Secondly, the Navisworks plan view is a top down image of a viewpoint. It shows the same information as if you were looking top down on a model. Converting this view into a minimap wouldn't work exactly. Small details would be shrunk down and more difficult to read. The context of your position wouldn't reflect in the map, for example, showing a slice or floorplan of the current level would be more helpful than always showing the roof.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_441a86b6fde64bde83f079412b9dc675.png" alt="Navisworks with a Minimap in the Bottom Right" loading="lazy"><figcaption>Navisworks with a Minimap in the Bottom Right</figcaption></figure>
<p>In the above image is my concept of Navisworks with a Minimap, seen in the bottom right corner. Taking up much less screen real estate, the minimap provides positional context while navigating large plans. No more asking "where are we" during meetings. </p>
<h2>Peripherals</h2>
<p>Computer peripherals weren’t designed to work in a 3 dimensional space. We’ve been able to adapt them for use in 3D software, but not without limitations. Typically only one or two axis can be manipulated at once, Ex, look around but not move. Much of the CAD industry will point towards the one or two 3D mice on the market, but instead, I wanted to look at another approach.</p>
<p>Video game consoles have been shipping with specialized input devices since Pong. These controllers are designed with 3D space navigation, speed, and ease of use in mind. To see how it would fair in the CAD world, I created a plugin for Navisworks to use a controller from a Nintendo Switch for navigation. </p>
<p>Switch controllers (joycons) use bluetooth to communicate with the console. Connecting it to a computer like a wireless mouse lets me read the inputs, and manipulate the camera position in Navisworks. I set it up to use the joystick to look around, D-Pad for movement, shoulder buttons for elevation. Joycons contain many more inputs that could be utilized, from a gyroscope to an accelerometer, and more buttons on the controller. Meant to be used in pairs, a second controller would double the given inputs.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_0997a46cb8434a0ebff791cd14f8c5c1.gif" alt="Using a Joycon with Navisworks" loading="lazy"><figcaption>Using a Joycon with Navisworks</figcaption></figure>
<p>How did it turn out? Well, not as amazing as I hoped. The Navisworks API isn’t meant to be used for controlling the camera, so there is a bit of a delay in any action. Any camera changes require a re-update to the render, which causes Navisworks to be slower than normal. Reading inputs from a joycon was relatively easy, but making sensible controls in Navisworks proved to be a challenge. </p>
<h2>Summary</h2>
<p>Video games have been around for a similar amount of time as computer aided design. While the CAD industry might not be looking over the shoulders of gamers, it couldn't hurt. Technical challenges in software have come a long way in the past few decades, but good UX development requires creatives ideas. Video games and enterprise software have similar challenges, and one thing that video games have over enterprise is the ability to radically innovate. There are no small independent CAD software companies, but the video game industry is full of them. These small studios can take risks on novel ideas, and when the rest of the industry sees a great idea, it spread like wild fire. </p>
<p>I the future, I would like to see more innovation spread from video games to CAD software: interactive tutorials, better program settings pages, in-client collaborative tools, etc. There is a plethora of ideas that would be of great value to the industry.</p>]]></content:encoded></item><item><title>3 Tiers of ERP APIs</title><link>https://www.smartbenchsoftware.com/post/3-tiers-of-erp-apis/</link><guid>https://www.smartbenchsoftware.com/post/3-tiers-of-erp-apis/</guid><pubDate>Tue, 10 Mar 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>ERPs (Enterprise Resource Planning [software]) come in many forms, styles, and flavours. Onsite, cloud based, multi-site, ERPs exist to fit every niche and need of many…</description><content:encoded><![CDATA[<p>ERPs (Enterprise Resource Planning [software]) come in many forms, styles, and flavours. Onsite, cloud based, multi-site, ERPs exist to fit every niche and need of many industries. But no enterprise software can do 100% of what a company needs. It’s not uncommon for a company to have customizations, or external applications made to integrate with an ERP. Automation and reporting are the two big uses. As a developer, the APIs these ERPs provide can be wildly different to work with. At the end of the day, they all more or less will work, they just require differing amounts of time and cause different kinds of headaches. But that won’t stop me from ranking them:</p>
<h2>The Best- REST or SOAP</h2>
<p>Cloud-Based ERPs, such as Netsuite, Sage X3, or Exact Online are becoming all the rage. They’re easier to implement, require zero on-site infrastructure, and offer low upfront costs. It’s no wonder old-school players are slowly switching to cloud offerings. </p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_981e933b9f5140c5a0cda7b25d37a0e1.png" alt="XKCD &quot;The Cloud&quot; - 908" loading="lazy"><figcaption>XKCD 'The Cloud' - 908</figcaption></figure>
<p>They are all joined by a set standards. Web Services commonly follow either REST or SOAP standards, with SOAP being the more strict of the two. Web service standards add a layer of consistency to interacting with them. The wheel isn’t being reinvented with each API. Along with this, other standards such as OAuth further simplify the integration process.</p>
<p>Standardizations take a lot of the guesswork out of creating an integration. SOAP (or REST) based web service APIs will be quicker to develop than other integrations, with less roadblocks or “development by trial and error”. It’s also pretty common for cloud based APIs to have good documentation, a trend for the betterment of the world.</p>
<p>REST and SOAP APIs are not without their flaws, there are still a few drawbacks that need to be considered or even developed around:</p>
<p><strong>API Limits -</strong> Cloud services cost money to run, so it is very common to put a limit on the API by setting a cap on the number of requests in a given hour or day. Under normal use, this might not be an issue, but a bigger company might have to shell out for those extra API calls.</p>
<p><strong>Speed -</strong> Adding distance between the user and the server slows down their connection. A cloud based ERP is never going to be faster than a good local implementation. This speed drop can fall anywhere between unnoticeable and unusable.</p>
<p><strong>Sandbox Options -</strong> Cloud solutions prevent users from poking around critical parts of the system, which is good, but it also makes life as a developer more difficult. With most cloud solutions, you have no control over backups or databases. It’s fine until you accidentally create 10,000 sales orders with a buggy script, and you now need a new script to reverse it.</p>
<h2>The Good - Client Integration</h2>
<p>Prior to the rise of Cloud Solutions, every ERP was accessed through some kind of client; a desktop application specific to the ERP. Not every client offers an API, and the ones that do can have wildly different functionality. Clients can scale between “Worse than a direct database” and “As good as web services”. A client gives a certain predictability and stability to actions, at the cost of speed, error handling, and flexibility. A client may provide you a “search” function, but you have no control over how efficient that search will be done.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_faeb28bc7f6840deb5300885b9122a9f.png" alt="User friendly isn't always developer friendly" loading="lazy"><figcaption>User friendly isn't always developer friendly</figcaption></figure>
<p>Two factors are front and center when it comes to the quality of a client’s API:</p>
<p><strong>Validation of Data -</strong> In general, a web service doesn’t allow you to make a muck of the system, and ideally a client shouldn’t either. Validating API calls are a good practice to make integrations smoother. Expecting a developer to not put bad data into an API is like expecting a toddler to not spill a glass of juice. It’s possible, but nobody's perfect.</p>
<p><strong>Authentication -</strong> Client APIs should be as secure as the client themselves. A best practice is to allow the use of the client login screen with the API, keeping integrations consistent with the client. When the only option is to pass through the username and password as plain text into the API, you will certainly have developers store those credentials in plain text.</p>
<h2>The Bad - A Direct Database or Undocumented</h2>
<p>It’s an exaggeration to say “Bad”, but they can certainly be unpleasant to work with. Direct database access isn’t necessarily a problem, SQL can validate data, and provide secure authentication methods. The gotcha is that these types of integrations are commonly accompanied by zero documentation.</p>
<p>Your development process is no longer “agile”, it’s a treasure hunt. A salaried developer might find it enjoyable prying apart the forbidden inner workings, but management won’t be happy when two week sprints turn into two year marathons. Direct database integration leave room for bad things to happen, and not knowing how things work compound the fear behind this. It’s possible to insert or delete data that breaks the entire ERP. If you ever find yourself in this situation; make frequent backups, document your process, and send for help.</p>
<p>These kinds of integrations aren’t all bad, there are some benefits, but they don’t outweigh the grievances.</p>
<video src="https://media2.giphy.com/media/g79am6uuZJKSc/giphy.mp4?cid=e2a3cbdec42e20504c1f9ee56c542d3f651bace7cec17830&rid=giphy.mp4" autoplay loop muted playsinline></video>

<p><strong>Speed -</strong> A well implemented direct database connection on a local network can be incredibly fast. An API tool over web service could take 3 minutes in a place where a direct database connection took 3 seconds.</p>
<p><strong>Job Security -</strong> If you’ve created an integration to an obscure API with zero documentation, you likely have business critical knowledge that cannot be replaced. Make sure not to write any of it down, that would only serve to help colleagues and future generations.</p>]]></content:encoded></item><item><title>Send Emails From Google Sheets</title><link>https://www.smartbenchsoftware.com/post/send-emails-from-google-sheets/</link><guid>https://www.smartbenchsoftware.com/post/send-emails-from-google-sheets/</guid><pubDate>Tue, 03 Mar 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>You’ve made a complex spreadsheet to automate a good portion of your business. Great! But you still have the mundane task of sending the same emails over and over again. The good…</description><content:encoded><![CDATA[<p>You’ve made a complex spreadsheet to automate a good portion of your business. Great! But you still have the mundane task of sending the same emails over and over again. The good news is that you can <strong>send emails directly from a Google Sheet</strong>, automating yet another portion of your work. Sending emails is actually quite easy, so I’ll go through it step by step.</p>
<p>A couple reasons you might want to send emails from a good sheet include:</p>
<p><strong>Automated Report Generation -</strong> Share reports with the team as they are created.</p>
<p><strong>Reminders -</strong> Managing projects in google sheets, send reminders for deadlines and overdue items, send notifications when items are completed.</p>
<p><strong>Invoice Automation -</strong> You’ve made the invoice in Google Sheets, skip a step and have it send automatically too! No more sending the wrong invoice to the wrong person.</p>
<h2>How to send emails from Google Sheets</h2>
<p>In your spreadsheet, go to <strong>tools &gt; script editor</strong>.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_deccf96f10084f01ab13d8102faaba75.png" alt="Create a new google script" loading="lazy"><figcaption>Create a new google script</figcaption></figure>
<p>Google will now open a new Scripts project for you, with a blank function. </p>
<p>The blank function can be left in or removed.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_81077daaad894dc8a98eabd6b9447546.png" alt="Blank Script Project" loading="lazy"><figcaption>Blank Script Project</figcaption></figure>
<p>Next, we are going to create a <strong>send email function.</strong></p>
<p>Now, this function is a bit silly as it only has one line, but it is setting us up for later,</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_9bd39b6cd0534966912a72dcffc2470d.png" alt="Basic Send Email Function" loading="lazy"><figcaption>Basic Send Email Function</figcaption></figure>
<p>Our next step is that we need to check if <strong>email quota remains</strong>. Google limits gmail users to <strong>100</strong> emails per day, and G Suite users to <strong>1,500</strong> emails per day. We can check this and alert the user when no quota remains.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_20af59e02d764e9ab5f1b66b1d9985e1.png" alt="Send Email with Quota Check" loading="lazy"><figcaption>Send Email with Quota Check</figcaption></figure>
<p>Now we need to actually get the <strong>email addresses</strong>, <strong>subjects</strong>, and <strong>messages</strong>.</p>
<p>Assuming you already have a sheet that can generate this information, we will start by loading the data from this range.</p>
<p>To actually get the range, we have two options: <strong>specify the range in code</strong>, or use the <strong>active range</strong>. The active range is the currently highlighted set of cells in our sheet.</p>
<p>If the range never changes, specifying the range manually will yield better consistency, but using the active range gives a bit more flexibility.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_38a2c294c25741528e9f3cea2c6d7e21.png" alt="Get Email Info from Spreadsheet" loading="lazy"><figcaption>Get Email Info from Spreadsheet</figcaption></figure>
<p>Next we get the data for each email. We are making the assumption here that <strong>3</strong> columns have been selected, and that the orderis <strong>email, subject, message</strong>. With this data, we will use our send function.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_89713fd6689448b886009f6e6668bc12.png" alt="Get email data values and send email" loading="lazy"><figcaption>Get email data values and send email</figcaption></figure>
<p>Now, save the script, select our <strong>getEmailInfoAndSendEmail</strong> function, and hit <strong>run</strong>.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_329d3ef6223844bbad160867f75c7b0f.png" alt="Run the script" loading="lazy"><figcaption>Run the script</figcaption></figure>
<p>Your recipients should soon be greeted with their emails.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_72f0d667eccd450e871e283057ec0361.png" alt="Wait for emails to send" loading="lazy"><figcaption>Wait for emails to send</figcaption></figure>
<h2>What else can you do with Emails from Google Sheets?</h2>
<h3>Add a menu to launch our email script</h3>
<p>Its a bit annoying to have to open the scripts page to run our script. Adding the following function <strong>onOpen</strong> will add a menu shortcut under <strong>Add-ons</strong> when the sheet is loaded.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_6ad54f2b8de349a89aa7db2aa6cb6178.png" alt="" loading="lazy"></figure>
<h3>File Attachments</h3>
<p>You can attach files from the Google Drive to your emails. Just remember to change the <strong>MimeType.PDF</strong> if you are sending something other than a PDF.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_5d060c7f45194256bc2b3e4c555c9b92.png" alt="Send an email with an attachment" loading="lazy"><figcaption>Send an email with an attachment</figcaption></figure>
<h3>Add a CC recipient</h3>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_d70753b1621e442a858ca197c8b66217.png" alt="Send an email with a CC" loading="lazy"><figcaption>Send an email with a CC</figcaption></figure>
<h3>Change the Reply To address</h3>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_fd63a37c37c540f5b963385ad0e92d1c.png" alt="Send email with reply to address" loading="lazy"><figcaption>Send email with reply to address</figcaption></figure>
<p>To get a complete list of options for using the MailApp, checkout the google documentation: <a href="https://developers.google.com/apps-script/reference/mail">https://developers.google.com/apps-script/reference/mail</a></p>
<p>If you have any questions about automation or software development, feel free to reach out to me via email at caden.armstrong@smartbenchsoftwaree.com</p>]]></content:encoded></item><item><title>Save 6 Hours a Week with Smarter Software</title><link>https://www.smartbenchsoftware.com/post/save-6-hours-a-week-with-smarter-software/</link><guid>https://www.smartbenchsoftware.com/post/save-6-hours-a-week-with-smarter-software/</guid><pubDate>Wed, 26 Feb 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>The value of automation is directly linked to the amount of time workers spend on repetitive tasks, and the reduction of human errors. Even in the most automated systems, humans…</description><content:encoded><![CDATA[<h2>Strategies to minimize the burden of data entry</h2>
<p>The value of automation is directly linked to the amount of time workers spend on repetitive tasks, and the reduction of human errors. Even in the most automated systems, humans will still need to be involved in the data entry process. In a study by SmartSheet “59% say they could save six or more hours a week if the repetitive aspects of their job were automated.” [1]. The value of reducing data entry is clear, but how can one reduce the burden of data entry? Well, here are three easy ways:</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_d3fb85a175b3482d9ebb03918d4152ca.png" alt="Hiring mice is a last resort solution" loading="lazy"><figcaption>Hiring mice is a last resort solution</figcaption></figure>
<h3>Templating</h3>
<p>Automating data entry is about removing repetitive work. Not everything can be automated, but the next best thing is simplification. Reducing the workload of the task pays dividends in each repetition. Not every record is going to be completely unique, and a template is an easy way to input a lot of data very quickly. Traditional document templates (invoices, quotes, etc) are only the tip of the iceberg. Think more along the lines of mad libs and cookie cutters. The option to apply a template to a form or task gives an easy shortcut. Some examples include:</p>
<p><strong>A doctor filling out electronic health records -</strong> A doctor will likely see a few illnesses regularly (flu, cold, infections, bronchitis, etc). The option to quickly bring up options for symptoms, prognosis, and prescribed treatment for fast recording could give a doctor more time to focus on treatment instead of data entry.</p>
<p><strong>Sales call notes -</strong> A study of 10,000 salesforce users found that only 40% of sales updates are completed [2]. Categorizing and templating sales call records could lower the effort required to ensure calls don’t go missing in the pipeline. </p>
<h3>Linked Data</h3>
<p>Single Data Entry is the philosophy that data should only need to be entered once. Data that exists in multiple places can be connected, giving greater power to the database. Here are three benefits to linked data:</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_685ed438cfbe4a4ab26c31bd5e2888fc.gif" alt="Linked Data Example" loading="lazy"><figcaption>Linked Data Example</figcaption></figure>
<p><strong>Reduced errors -</strong> In many cases of automation, data needs to match exactly. The name of a manufacturer, client, email, etc. Mistakes or inconsistencies not only make data automation difficult, but potentially create costly errors.</p>
<p><strong>Faster -</strong> A single field generating <strong>X</strong> fields is <strong>X</strong> times faster, not even including the complexity of gathering the information for each field. The real speed gains comes from the automations possible with a linked database.</p>
<p><strong>Greater Potential -</strong> Exploring the possibilities of data automation and a consistent, linked data system, your imagination becomes the limit.</p>
<p>Take a stroll down example lane, and imagine a build to order manufacturer. When the manufacturer receives an order for an assembly, they will generate a bill of materials, and a well linked data system could do any number of the following:</p>
<ul>
<li>Create Purchase Orders and email them to Vendors</li>
<li>Update stock numbers in the warehouse</li>
<li>Schedule machines for production</li>
<li>Print documentation</li>
<li>Add the template workflow to project management and update sales with lead times</li>
</ul>
<p>The workflow relies on data linked between the Bill of Materials and the automated steps. Part files need to have vendor names included, machining operation requirements, etc. But the time to enter the vendor in a common part pays off when you create dozens, or hundreds of purchase orders for that part.</p>
<p>The same workflow can be applied to other industries. Generating paperwork, emails, reports, and records is universal in business.</p>
<h3>Data Validation</h3>
<p>Data validation within any automation or entry software provides two key values: The data has been entered, and has been entered correctly. Fixing data can be as big a problem as entering data to begin with.</p>
<p>An example of forced data compliance is a date picker. No training is required, and no format mistakes can be made. The data is guaranteed to be consistent in format, which is a huge time save in an automated system. Only one format needs to be accounted for, and bad data does not exist that would otherwise need to either be accounted for (manually most likely) or fixed.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_efd2fa66a67b4f9391a2cebdd77a0c91.png" alt="Date picker vs Date format chaos" loading="lazy"><figcaption>Date picker vs Date format chaos</figcaption></figure>
<p>As big an issue as getting data into the correct format is getting it to exist at all. It's not unreasonable for a busy worker to miss an important field. Quick work in a moment, a distraction in the office, or an interrupting call. But that missing data can prove to be an issue down the road. Validating completeness of data adds a layer of security against data debt.</p>
<h3>Conclusion</h3>
<p>And there you have it, 3 methods for reducing the burden of data entry. With these three strategies you can reduce the workload of data entry, mitigate errors, and expand the potential of your workflow.</p>
<p>If you are interested in discussing any of the topics in this article, feel free to send me an email: <a href="mailto:caden.armstrong@smartbenchsoftware.com"><strong>caden.armstrong@smartbenchsoftware.com</strong></a></p>
<p><strong>Sources</strong></p>
<p>[1] <a href="https://www.smartsheet.com/content-center/executive-center/2017-automation-report">https://www.smartsheet.com/content-center/executive-center/2017-automation-report</a></p>
<p>[2]<a href="https://www.business2community.com/sales-management/%E2%80%8Byoure-spending-too-much-time-updating-salesforce-and-here-are-5-reasons-why-01236170">https://www.business2community.com/sales-management/%E2%80%8Byoure-spending-too-much-time-updating-salesforce-and-here-are-5-reasons-why-01236170</a></p>]]></content:encoded></item><item><title>Bulk Report Generation</title><link>https://www.smartbenchsoftware.com/post/bulk-report-generation/</link><guid>https://www.smartbenchsoftware.com/post/bulk-report-generation/</guid><pubDate>Thu, 20 Feb 2020 12:00:00 +0000</pubDate><dc:creator>Caden Armstrong</dc:creator><description>I recently worked with a client, a medical clinic, with a simple request: automating biweekly reports. Every two weeks, the clinic needs to generate a report for each contractor.…</description><content:encoded><![CDATA[<p><strong>A Case Study for Automation</strong></p>
<p>I recently worked with a client, a medical clinic, with a simple request: automating biweekly reports. Every two weeks, the clinic needs to generate a report for each contractor. The biweekly report contains all of the invoiced and paid sessions of the clinic and contractor's clients. A Google Sheet had already been created to compile the information into a single sheet. The difficulty came in creating PDFs and emailing them to each of the contractors. Manually generating, saving and attaching the reports was too time consuming for the already overloaded admin duties. A task ripe for automation.</p>
<p>The task in essence is quite simple: change a cell value to generate the report, output to PDF, and email the file.</p>
<p><strong>1. Get the list of contractors</strong></p>
<p>When the application is run, the name of the cell containing the contractors names is asked for. From this cell, we can find the range that defines the list of contractors. We could easily just hard code in the name of the cell, but we lose the flexibility of using the application in other sheets, or moving the cell. The range we find is the same as defined in the “data validation” window that populates the drop down list.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_2782e3fe228147018cc53a52ad58d361.png" alt="Script Prompt for the driving cell name" loading="lazy"><figcaption>Script Prompt for the driving cell name</figcaption></figure>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_d765043bbd2748fe93bd8f3580192ee6.png" alt="Drop down list defining contractor names" loading="lazy"><figcaption>Drop down list defining contractor names</figcaption></figure>
<p>At the same time, we ask for the cell of the contractors email, for use later when emailing the PDFs.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_5fbbcffd820d40209087a4035969bbb8.png" alt="Script prompt for the email cell" loading="lazy"><figcaption>Script prompt for the email cell</figcaption></figure>
<p><strong>2. Set the sheet’s driving cell value to the contractor’s name</strong></p>
<p>Setting the value of the drop down list causes the rest of the spreadsheet to generate the report. No code is required here, just work your spreadsheet magic.</p>
<p><strong>3. Create a PDF</strong></p>
<p>Using the script, we are able to output the current sheet as a PDF to the same folder in the google drive. We can use the name of the sheet and the contractor to create a sensible filename for the PDF.</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_abe5aaffae8544c5a895def25171c63b.png" alt="Example output in google drive" loading="lazy"><figcaption>Example output in google drive</figcaption></figure>
<p><strong>4. Email the PDF</strong></p>
<p>With Gmail and Google Scripts, sending an automated email is incredibly easy. Our script only needs to provide an address, subject, message, attachment, and a name to appear as the sender. As we are always sending the same reports, we can include a static message that indicates the report period using the sheet name. When you realize how easy automated emails are to send, you’ll want to use them everywhere!</p>
<figure><img src="https://www.smartbenchsoftware.com/media/e76637_a215f54e509345a682479aaf650c5e35.png" alt="Auto generated email attaching the report for the contractor" loading="lazy"><figcaption>Auto generated email attaching the report for the contractor</figcaption></figure>
<p>Do you also have reports that need to be generated and emailed? Good News! I’ve included the above script for you to use. Open a Google Sheet, and navigate to <strong>Tools &gt; Script Editor.</strong> Copy the contents of the script file into a new script, re-open your spreadsheet, and that's it! Look under <strong>Add-ons</strong> for the new script. See below for a download link.</p>
<p>If you are interested in having your business automated, contact me at <a href="mailto:caden.armstrong@smartbenchsoftware.com">caden.armstrong@smartbenchsoftware.com,</a> and inquire about my bespoke software solutions. I specialize in creating add-ins and integrations for the engineering industry.</p>
<p><a href="https://drive.google.com/file/d/1LwYMeNfar8bgl5LrSRnAekv6OHyvJVq3/view?usp=sharing">Download Bulk Report Generator Here</a></p>]]></content:encoded></item>
</channel></rss>
