-
Correct Tools Query Call for opBoolean Union of Shelled and Intersected parts
Very frustrated. I'm at the very end of my Feature script that creates 3D lattice infill for parts and I can't get the last operation to work Below is the tail end of my script, the very last operation "//Union of Shell and Intersect" always throws an error "@opBoolean: BOOLEAN_BAD_INPUT". I've tried everything from…
-
Splines in Onshape - (almost) everything you want to know
Greetings, Recently I've been doing a fair bit of experimentation with splines in Onshape, and in the process I've written a small treatise on my blog about splines, B-splines, offset curves, etc., together with some code examples in FeatureScript. If you've been puzzled by skFitSpline(), opFitSpline(),…
-
How to access data written to parts with setAttribute
Hi, I'm attempting to write a program that analyzes some of the geometry of each part, and then writes the results into the parts in order for another app to pick it up and read it through the API. I've successfully written the data I need to the parts by using setAttribute, but I've been going through the API request list…
-
Trouble with extrude
I am using extrude instead of opExtrude, but it keeps saying that the EXTRUDE_FAILED. extrude(context, id + "extrude2", { "entities" : qSketchRegion(id + "sketch2"), "oppositeDirection" : true, "endBound" : BoundingType.UP_TO_BODY, "operationType" : NewBodyOperationType.REMOVE, "endBoundEntityBody" : qCreatedBy(id +…
-
How Do I Subtract a Number from My Variable
I am trying to iterate an skCircle to space them out evenly, but I keep on running into an error: "Can not subtract ValueWithUnits (map) and number" for (var i = 0 * inch; i < definition.length; i += 1) { var iss = i - 0.5; skCircle(sketch2, "circle" ~ i, { "center" : vector((iss), 0.5 * inch), "radius" : 0.6299 * inch });…
-
Featurescript fails when using EvBoundingBox?
Hello all, I'm currently trying to write a script which evaluates the bounding boxes of a given set of parts, and then prints the vertices to the featurescript terminal. However, when I attempt to do this, it breaks and throws a Precondition of evBox3d failed (arg.topology is Query) error. I have added my code below. I'm…
-
Sheet metal and feature script
Hello, I try to use the featurescript "laser joint" with sheet metal module whithout finish this module. Can we do that? Is this included in an upcoming update?
-
Problems with Extruding in FeatureScript
var sketch1 = newSketchOnPlane(context, id + "sketch1", { "sketchPlane" : plane(vector(0, 0, 0) * inch, vector(0, 0, 1)) }); skRectangle(sketch1, "rectangle1", { "firstCorner" : vector(0, 0) * inch, "secondCorner" : vector(1, 2) * inch }); skRectangle(sketch1, "rectangle2", { "firstCorner" : vector(0.1, 0.1) * inch,…
-
Why OnShape defines a new program language - FeatureScript?
Hi, Why OnShape defines a new program language? Why not use the formal script language like JS? Seems FeaureScript is not easy to learn for both programmer and engineer. And FeatureScript can not be used out of Onshape. If using JS, at least, some people can easy to start. I would like to know the reason. Thanks!
-
A question on preconditions.
Can I somehow separate the preconditions out of the main function? there are two reasons I wish to do this: * it's getting too long and messy. * I want to take a precondition of queries and split it and return it in two separate definition maps i.e. definition.plane and definition.lines, I could split it into two queries…
-
Trying to add units and bounds for velocity... am I missing something?
So I have this code: export type VelocityBoundSpec typecheck canBeVelocityBoundSpec; export predicate canBeVelocityBoundSpec(value)
{ canBeBoundSpec(value); @size(value) == 1; for (var entry in value) isVelocity(entry.key);
} /** * True for any value with velocity units. */
export predicate isVelocity(value)
{ value is…
-
Point of Intersection.
Is there a good way to evaluate the point at which two lines or edges intersect? Cheers, Darren
-
Re-apply attributes to patterned entities
Let's say I'm (linear) patterning a couple of bodies. Some of these have been given a specific attribute using FeatureScript ({"A" : true}), some others another attribute ({"B" : true}). The new bodies apparently don't get the attributes, which I'll need for later boolean operations! The instance count is based on a…
-
Sorry for the beginner's question, but I need to mix length units and I do not know how...
i.e. I would like to say const VNSpindleBearingOD is string = "SpindleBearingOD"; const SpindleBearingOD is number = 3.15; // this value is in inch const VNSpindleBearingOD is string = "SpindleBearingID"; const SpindleBearingID is number = 80; // This value is in mm verifyVariableName (VNSpindleBearingOD);…
-
How can I create string variables?
I have a featurescript feature that takes a string as a precondition. Is it possible to define a variable that is a string that I can pass into this feature? I've tried setting the value of a variable to be something quoted in double quotes and single quotes, neither of these is accepted.
-
New FeatureScript - Mortice and Tenon
Hello, after many attempts, I now have a working mortice and Tenon Script. The user selects the edge where the face side and face edge meet (the arris) And it creates both the tenon and mortice. The default width if the tenon is a third of the part and automatically haunches the tenon if the rail is flush with the top of…
-
What happens when I run out of vertical estate on a feature script UI, do I get a scroll bar?
My UI expands as I add different options such as ribs stringers and spars, with these options comes many more options for each one, what if my UI extends down further than I have screen? I tried just shrinking my browser but I just lost half my UI with no way of accessing the bottom half.
-
Featurescript - query/delete all sketches
I want to clean up my Part Studio, so that when I derive it in another (using opMergeContexts in FeatureScript) I don't get all the sketches and points and all, but I do want to import all parts and surfaces at once. Either I can query these one by one, calling opDeleteBodies on all the queries, but I'd really like a…
-
Using qCapEntity with a manually generated body
Hi. I am very new to both Onshape and FeatureScript, and I'm hoping I may be missing something obvious here. Is there a way to use qCapEntity to locate the cap of a body which was generated via an Extrude or Thicken in the PartStudio? All the examples I can find use a body generated within the FeatureScript (and thus with…
-
Code review of feature script to create a wood joint
I am working on learning FS. I would appreciate any criticisms of the following code. Feel free to say this would be faster, would have made the coding process easier... Anything will be appreciated. Here is the code. The code creates a joints between parts. The user needs to select faces to have tabs, parts to be slotted,…
-
Using Z axis of mate connector error once transformed
Hello, I am working on a feature that imports a part with a mate connector. I am then rotating that part using the mate connectors Z axis. I also have a boolean which if true, it will rotate about the mate connectors X axis first. The error occurs when I then want to rotate about the mate connectors Z axis. I would think…
-
Feature Request - UIHint HIDE_ON_CREATION
Hi, I have an idea that could be useful. It is another UI Hint that once a script is executed, it hides the feature on the feature tree. Similar to clicking the eye symbol in a part studio. This would be useful to hide mate connectors, sketches etc. This UI Hint could be placed in the initial feature name section.
-
Suppress through FS?
Is there any possibility to edit features in the part studio feature tree by means of FS? Specifically I'm interested in suppressing certain features, such as extrudes or holes, or other FS features, based on boolean parameters. I see in the part studio code that a suppressed feature simply is enclosed in an if (false) { }…
-
Change variable values after mergeContext / importDerived?
Now, I might be dreaming, but I'd really love this to be possible. Is there a way to Change variable values after using mergeContext or importDerived to import geometry from another PS? This would allow several morphologically different instances of the same geometry. I figured since variables are added to the context,…
-
Having troubles with: skCircle(Sketch, Id (array), map) does not match skCircle(..., string, ...)
the id: id+'circle1'+keys debugs to: Id : [ "FIZxwPCJn00T9Nq_1" , "circle1" , "0" ] I presume the issue is that it is an array of strings however this is valid for a sketch so I am puzzled. The link is: https://cad.onshape.com/documents/95877be3b17f49277e87a2c3/w/b503830fd20472014beb1221/e/4c4431103f44e823aca947dd the…
-
Use FeatureScript to automatically hide itself
Hello all, how could I set my script up such that when executed, it is hidden in the feature tree? Is it simply using the UIHint ALWAYS_HIDDEN in the feature name annotation at the top? Thanks Lee Hesketh
-
FeatureScript Profiler discussion
Hey FeatureScript authors, We're happy this week to have released the FeatureScript profiler, Onshape's tool for viewing timing data for individual execution steps inside your custom features (you can check out a quick video here or the documentation here). We're already eating our own dogfood and using this tool to help…
-
Is there a way of excluding a piece of code to a single action command?
This makes sense in my head, to elaborate... If I have a piece of code that is intensive in terms of many iterations etc, I don't want it to run every time I change a variable. Is there a way of holding off until the setup is finalised and then have some kind of way (maybe a button) to activate the intensive part? I…