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.
But despite that warning, lets look at what I think are the most useful ones...
To follow along and view the code samples, check out this public document
opExtractSurface (context is Context, id is Id, definition is map)
Take a list of faces and generate surface bodies. Source faces and bodies are not affected.
definition | map | |
faces | query | List of faces to be converted |
tangentPropagation | boolean | whether additional faces should be added to the selection by tangent propagation |
offset | ValueWithUnits | (Optional) Offset extracted surface faces by this distance along the normal |
useFacesAroundToTrimOffset | boolean | (Optional) Use surrounding faces extensions to trim offset |
redundancyType | ExtractSurfaceRedundancyType | Controls the culling of redundant geometry on the result body. |
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.
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.
opEdgeChange (context is Context, id is Id, definition is map)
This function moves the boundary of a surface inward.
definition | map | |
edgeChangeOptions | array | |
edge | query | edges to modify |
face | query | face the edge is adjacent to |
offset | ValueWithUnits | (optional) amount to offset edge |
replaceFace | query | (optional) query of a face to move edge to |
transformList | array of transforms | (optional) transformations applied to the edge |
opExtendSheetBody (context is Context, id is Id, definition is map)
Extend edges of a sheet body outward
definition | map | |
endCondition | ExtendEndType | |
entities | query | edges to extend |
tangentPropagation | boolean | Whether to add additional edges based on tangent propagation |
extendDistance | ValueWithUnits | Distance to extend if end condition is Blind |
target | query | Required if endCondition is Extend to Target - Part to extend up to |
extensionShape | ExtendSheetShapeType | Shape characteristic of extension. |
opCreateOutline(context is Context, id is Id, definition is map)
Generate surfaces representing the outlines of parts or surfaces projected onto a surface
definition | map | |
tools | query | The tool parts or surfaces |
target | query | The face whose surface will be used to create outline. Current only planes, cylinders, or extruded surfaces are supported. |
offsetFaces | query | (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 |
The result of the operation is a surfaces that is a silhouette or projection of the body.
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.