Finding FeatureScript documentation resources?
ken_kaiser
Member Posts: 6 ✭
Hi! I'm new here and I found the FeatureScript documentation at https://cad.onshape.com/FsDoc/index.html
I am now looking to apply a Circular Pattern: it is a documented feature but there is no map definition documented for that feature.
https://cad.onshape.com/FsDoc/library.html#module-circularPattern.fs
Looking into the onshape/std/circularPattern.fs doesn't give me many hints.
I was able to find examples of most, if there is any way to search for an example that uses that specific feature, I'll be able to figure it out.
Where are other places to find documentation? Thanks
I am now looking to apply a Circular Pattern: it is a documented feature but there is no map definition documented for that feature.
https://cad.onshape.com/FsDoc/library.html#module-circularPattern.fs
Looking into the onshape/std/circularPattern.fs doesn't give me many hints.
I was able to find examples of most, if there is any way to search for an example that uses that specific feature, I'll be able to figure it out.
Where are other places to find documentation? Thanks
0
Best Answer
-
Hi Ken!
Glad you're interested in FeatureScript programming. Usually we provide documentation for the underlying operation (opSweep, opFillet, opDraft) rather than the Onshape feature itself (see the geomOperations section of the documentation). This is because the features themselves take a more complicated set of inputs corresponding to the options in the feature dialog and end up just mapping them to the underlying operation anyway.
In the case of opPattern, we recently realized that forming a custom set of coordinate systems just to pattern something in FeatureScript is a little obtuse to force on the end user, so linear, circular, and curve pattern documentation is coming soon. In the meantime I hope these screenshots of the upcoming circularPattern documentation can help you.

p.s. the precondition of any Onshape feature is the best place to look for the required inputs in the definition.
Jake Rosenfeld - Modeling Team6
Answers
-
Hi Ken!
Glad you're interested in FeatureScript programming. Usually we provide documentation for the underlying operation (opSweep, opFillet, opDraft) rather than the Onshape feature itself (see the geomOperations section of the documentation). This is because the features themselves take a more complicated set of inputs corresponding to the options in the feature dialog and end up just mapping them to the underlying operation anyway.
In the case of opPattern, we recently realized that forming a custom set of coordinate systems just to pattern something in FeatureScript is a little obtuse to force on the end user, so linear, circular, and curve pattern documentation is coming soon. In the meantime I hope these screenshots of the upcoming circularPattern documentation can help you.

p.s. the precondition of any Onshape feature is the best place to look for the required inputs in the definition.
Jake Rosenfeld - Modeling Team6 -
Thanks Jake! Great to see active development.
I don't need to tell you but being able to create a custom UI of tools that you use, that are written in FeatureScript changes everything. A huge undertaking but having examples of every FS function would open it up to people who just copy-paste with slight modification.
0 -
Follow up, the axis parameter which asks for a query took some debugging. The FeatureScript debugger came back with no axis provided when I queued a body, face, or a vector. There also is no other query that results in an axis so it was guess and check. It took me to the evAxis function which didn't work, but it says it should, when you QueryFilterCompound.ALLOWS_AXIS something you select it works. What ended up working was drawing a line using skLineSegment on the axis I wanted and queried the edge.
Debug is useful when something doesn't work, when you select the function in the Part Studio it highlights the part in red and showing FeatureScript notices the {?} icon, it says what it resolved to. e.g.
debug(context, qCreatedBy(id + "partToPattern", EntityType.BODY));
// I used it to copy equally spaced circles around a cylindercircularPattern(context, id + "myPattern", {"patternType" : PatternType.PART,"entities" : qCreatedBy(id + "partToPattern", EntityType.BODY),"axis" : qCreatedBy(id + "sketch", EntityType.EDGE),"angle" : 360 * degree,"instanceCount" : repeatedTimes,"equalSpace" : true});0 -
Hi Ken!
Thanks for the feedback, I'll look into making the axis documentation a little better. The ALLOW_AXIS query filter is somewhat strange; theoretically we want to end up with a mathematical representation of some axis to pattern around, but because this is a feature (rather than an operation) we want to let a user click on some geometry (a Query) that can be turned into an math-axis internally. To facilitate this, definition.axis will take any linear edge, circular edge, or cylindrical face as an "axis". The is one of the problems I mentioned earlier with calling Onshape features (rather than lower level operations) in FeatureScript. Often the inputs are a little unintuitive because they correspond to what goes into the feature dialog rather than the pure mathematical object that is needed (as another example some features will not accept negative valued inputs, but rather always take a positive value and determine the sign with a definition.oppositeDirection variable).
Sorry this help came after you solved your own issue. Hopefully it can help Onshapers of the future!Jake Rosenfeld - Modeling Team2

