top of page
Search

Making use of Hidden Parameters in FeatureScript

  • Writer: Caden Armstrong
    Caden Armstrong
  • 6 days ago
  • 1 min read

A parameter in an Onshape Custom Feature can be made hidden from the user by using a UIHint


ree

And this can lead to some interesting uses! But first we need an editing logic function. 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.


Array item labels


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:

ree

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.


ree

Example


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.


ree

ree



SmartBench Software is the industry leader in FeatureScript and Onshape automation.

 
 
 

Recent Posts

See All
Attributes in FeatureScript

Attributes are a feature of Onshape's FeatureScript that seem simple at face value, but are incredibly powerful. In the simplest terms,...

 
 
 
The Hidden Parameter in newSketch

I accumulate a lot of weird and niche knowledge about Onshape and FeatureScript in the course of my work. This is no exception. Honestly,...

 
 
 

Comments


bottom of page