-
PSA: New additions to the FeatureScript Standard Library
If you aren't in the habit of regularly browsing the Standard Library Source or the Standard Library Documentation, you might have missed the addition of two new functions to the Onshape standard library in the latest Onshape release, isQueryEmpty and areQueriesEquivalent. (I guess they weren't deemed worthy of a mention…
-
Query specific edges
I'm looking for a way to query all the edges of a surface body. I'm hoping there is a way to filter only for edges that have two faces attached. I'm sure I read this somewhere but I am not able to find where it was.
-
Configuration variable range available in FeatureScript
Hey All I want to be able to display the range of a configuration variable in the feature tree. I am beginning to learn FS, so i am wondering if I can access the range (min and max value) of a configuration variable from FS? Or can I make a variable in my doc have the value of the Min or Max possible value of a…
-
Is there any scripting method to identify all arcs in a sketch to replace them with a line?
In trying to reduce the number of polygons in exported models, for performance reasons, I thought of converting all arcs within sketches to simple straight lines but have no idea how to do it through script. However, this might corrupt the sketch if there are other references to the targeted arc so a way to avoid that is…
-
Splitting Parts Removes Attributes
According to the docs at https://cad.onshape.com/FsDoc/library.html#module-attributes.fs "Attributes stay with the entity they are defined on, even as the Part Studio changes. An attribute on a face, edge, or body which is split in two will be set with the same name and value on both split pieces." However, the following…
-
Extrude Function Having Strange Behavior
Hi, while working on a shaft FeatureScript, some interesting behavior came up when using the extrude function (I do wish I could use the hole function). Where in certain inputs the extrude to apply the values work, but other times it doesn't. Some help would be greatly appreciated. Document link: TMM Featurescripts
-
Help with redundant code?
My code is very redundant, what would be a more efficient way to write this? I thought it may be a good place to use a function, but I'm not sure how to do it. if (definition.groups[g].configScope == ConfigScope.EVEN_COLUMNS || definition.groups[g].configScope == ConfigScope.ALL || evenColumnPreset) { if (evenColumn) { if…
-
Generating a sketch that can be derived in other part studios
I'm new to feature script. I'm trying to create a feature script that generates a sketch that can be derived in another part studio. So far, the feature script generates a sketch, but this sketch is not shown as an option when attempting to derive it in another part studio. Standard sketches can be derived, so I looked…
-
Direct access to imported data
It would be nice to be able to have access to image pixel data and access to the raw text of imported files inside FeatureScript, instead of just parsed CSV or JSON data. Parsed XML would be nice too but I'm not holding out. The impetus for this was working on an SVG import script.
-
FeatureScript Arrow Operator Improvements
In August of last year, Onshape added support for a new syntax operator, the arrow operator (->). It allows users to chain FeatureScript arguments together by passing the argument on the left of the operator into the function on the right as the first argument. For example, the following two statements are equivalent:…
-
Prevent selecting origin point in Featurescript entity parameter
Is there a way to prevent the origin point from being selectable in a Featurescript entity parameter, while allowing other points created by opPoint to be selectable? Roughly, I have a set of features where the user adds "points", manipulates them over the course of several features, and then I use them to generate a…
-
Cuboid Plus - New Custom Feature
Hello all! I have been using the FeatureScript function fCuboid() a lot lately, and I've been thinking that this could become a custom feature. So here is Cuboid Plus, an expansion of fCuboid(). This allows you to use the fCuboid() functionality of creating a rectangular prism between two points without needed to write…
-
Loading FeatureScript Files Crashes Session
I'm trying to become acquainted with FeatureScript by reviewing examples. Each time I try to load one, my session freezes, forcing me to quit Onshape entirely. The image shows what the window looks like when this happens. Is this a common occurrence? Might use of a different browser help (I'm presently using Safari on…
-
Laser joint but with single pin for sloting parts
Hello, as part of a laser cutting project, I want to create a number of parts that slot together. Similarly to how the laser joint Featurescript works but with only a single pin that takes up half the overlapping distance. As can be seen in the photo. Currently, I am doing this by hand but there is an incredible amount of…
-
Possible Editing Logic bug with Array parameters
[Only not posting to support because I first want some community feedback about whether I'm using Editing Logic incorrectly]MWE: https://cad.onshape.com/documents/6aeee181faba5f5f7d8abf2d/w/6af36a1d3037a2e5b20744d4/e/c8beebf8888117a1279d1623 My EL function is modifying feature parameters based on whether any entity is…
-
Using a Part Studio Reference Parameter Breaks ErrorStringEnum Functionality
For a bit of background, ErrorStringEnums are the internal Onshape error messages which are utilized by every Onshape standard library feature in order to make translating and standardizing error messages easier. Although ErrorStringEnums are not currently exposed to users directly in the documentation, the three types of…
-
Why do attributes not come through when instantiating?
When instantiating part studio reference parameters, I'm able to get the attributes to come through if I use the legacy setAttribute(), but with the new setAttribute(), where you can specify a name, it doesn't seem to work? Thanks in advance!
-
Abusing UIHints for Fun and Profit
I had some fun making an early April Fool's joke about adding microtransactions to my featurescripts. This uses UIHint.REMEMBER_PREVIOUS_VALUE, UIHint.ALWAYS_HIDDEN, and an editing logic function to keep track of how many times someone has used a script and encourages them to buy more uses when they run out. An example of…
-
Using the custompropertyID to show custom property in a custom table
Can someone show me the correct syntax to use the customPropertyID with PropertyType.CUSTOM? I just can't get it to work for some reason (mostly because I have almost no idea what I'm doing with FS!), but trying hard to learn..... var custom1 = getProperty(context, { "entity" : part, "propertyType" : PropertyType.CUSTOM,…
-
[FS] JSON Writer
Has anyone written a function to convert a map to a JSON string? (Basically the inverse of parseJsonWithUnits). Just looking for something rudimentary. It may be hard to do this if the map contains non-basic types. (e.g. after serializing a "plane", it wouldn't be straightforward to know that you needed to interpret the…
-
Managing a FeatureScript Library
Hey guys, We've spent the last year building a great set of custom features for our joinery company. But as the library grows, we're finding it difficult to keep on top of feature updates. We're splitting out bits of FeatureScript into functions that can be reused in different features, but then you have the issue of…
-
Pre selection logic?
I'm having trouble understanding how to export a function. Can someone give me some pointers? Here is what I'm trying to do: If you have pre selected a plane and a vertex, then click the feature, the feature will detect that you are wanting to use the "Up to vertex" method. I'm trying export these definitions so that the…
-
Set name property of curves with featurescript
In FS it's currently forbidden to set the name property of a curve (only works with bodies and faces). However, you can select and rename curves in the GUI, so it seems that this shouldn't be a fundamental issue. I have a system that needs to generate many curves and then allow the user to select them, and having a name…
-
Make a Configuration Variable that can accept a FS array/ any FS expression
I must be missing something. I'm trying to have one of my configuration variables accept an FS array, but when I attempt to specify the configuration variable type, I just get the options of Length, Angle, Integer, Real or Text. Is there no way to put in a general FS expression? The general PS variables have an "Any" type.…