-
Featurescript to select the variable
Is it possible to use featurescript to select the #variable array? I have a #Variable array that I would like to select using UI booleans.
-
Need help with feature naming template
Hi, I am struggling with the feature naming template and have already checked most posts currently on the forums but from what I can tell my example should work: feature definition: annotation { "Feature Type Name" : "Profile Generator", "Manipulator Change Function" : "flipManipulators", "Feature Name Template" :…
-
Featurescript: Can't get qEdgeAdjacent to work?
This basically my code with some bloat stripped out. It creates an edge between two points and extrudes it into a face, then into a body (a door in this case). I then want to extrude the face along the hinge so that I can form a union with the door frame (i.e. not just joined at an edge). I'm getting there but not sure on…
-
How to find extent planes for a solid in a specific direction
I have created a feature script feature. The user can select * S is Solid * P is Plane I would like to generate two planes that bound S in the direction of normal to P Before: After: Any ideas how to do this?
-
How to import a sketch into a feature script and then in a loop make copies of it along a path.
Hi there, I have a sketch in my document. It has 3 variables set MidThickness Width Height the variables parameterize a cross section profile along a boat hull. I would like to create a feature script feature that imports the sketch and then in a loop makes copies of it. I have imported the profile into a feature like so…
-
Get vector for edge direction
I am writing a feature that requires me to select a vertex and returns the vectors corresponding to the direction of the edges that meet at that vertex. Is this possible? Thank you.
-
Feature Name Template includes container symbols
I would like my feature to set its name based on the type of part it's creating. It works correctly but it looks ugly because if I use setFeatureComputedParameter to assign a string to the feature name, I get the quotation marks in the name of my feature. This seems to also be the case for an array. As far as I can tell,…
-
constructPath returning error, need advise on correcting
I have this line: var upperQueries is Query = qUnion([sketchEntityQuery(id + "sketch1", EntityType.EDGE, "upperLEArc"), sketchEntityQuery(id + "sketch1", EntityType.EDGE, "UpperLE_Spline"), sketchEntityQuery(id + "sketch1", EntityType.EDGE, "UpperTE_Spline"), sketchEntityQuery(id + "sketch1", EntityType.EDGE,…
-
Determine which options were selected when previously using a feature to create a part?
Is there a way to access a piece of information that was input by selecting an enum value to create a feature, the next time that feature is used? For instance, if I made a feature to create cube with an enum option for filleted edges, would it be possible to then use featurescript to query that cube and determine whether…
-
Writing a measured value to a variable in the model tree and keeping it updated.
Essentially I'm trying to recreate a 'sensor' or User-Defined Measurement. In the simplest case I have an arc, would like to evaluate it's length, then store that number in a variable so that I can reference it later in my model tree. I'm just jumping into featurescript so it's not immediately obvious to me how to do this,…
-
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…