featurescript
Discussion List
-
How to read in specific variables from a CSV based on user inputs
Howdy Folks, I am trying to scan the first two columns of rows in a CSV using two numeric user inputs as the search key and find a match. Then, return the remaining two column values as variables required for creating a hub on a sprocket. Every simplification/variation of the code that I have tried returns the same…
-
How do I query an object after a boolean union?
I'm creating a feature that allows me to extend multiple walls up to a target height. * Select the top face of a wall element. * opExtrude a calculated distance to create a new wall element. * opBoolean union to join the two parts * I need to select the part created with the opBoolean to modify its attributes. I see the…
-
Passing in featureList as Argument, but not from a Feature Parameter
I'm in a slight dead end figuring out how a feature I've written can be used by some other features, when the feature has an 'is featureList' input (to ingest all the things created by a feature, which may vary). See the below example, where I want the thing represented by 'fList' to be a featureList type, and for it to…
-
FeatureScript name is red
Hello I wrote a feature script that runs without error, but the name of the featurescript is highlighted in red. Even closed. Why ? https://cad.onshape.com/documents/b779fbc5c77223353d4ce6aa/w/5beeb6a22fc35205de002ae9/e/d808d6b0bcd0567c369b865a?renderMode=0&uiState=64d9f243c22dde25a208712e
-
Why debug feature is not displayed ?
Hello, When I use the debug feature on a vector, the data are displayed in the FeatureScript Notice, but the lines are not drawn on the screen.I thought they should appear, right? I use the debug feature to display these lines on the sketch { // 1st line var line1Start = [x1, y1]; var line1End = [x2, y2];…
-
setExternalDisambiguation - Multiple Face Replacements on a Solid Body
I'm trying to create a feature that will approximate a number of curved surfaces, usually just 4 sided, with simplified planar surfaces using ReplaceFace. Taking three vertices from a face and turning it into a plane which replaces a face. If there's only one curved face in the solid body, then it works fine. But I can't…
-
Is it possible to configure properties of a body with Featurescript?
I'm trying to find out if it's possible to configure a body using Featurescript. The concept: -Prompt for two user-selected bodies -Get string from property "Name" of each part -Create a new simple body (in this case a cylinder) -Configure the cylinder to have two configurations -Set configured "Name" properties of the…
-
FeatureScript behaviour
I'm trying to understand how FeatureScripts work. I wrote a simple script :: export const main = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Select Spline", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 100 } definition.curves is Query ; } {…
-
FeatureScript Notice
Hello, Is there a way to clear the FeatureScript Notice ?
-
Spline with an array
Hello I need some help with the spline.I wrote a feature which draw a spline from a csv fileInside I use this code } else if (linetype == "C") { var P1 = point_courant; var P2 = vector(aline[1], -aline[2]) * ZoomCoefficient + splineOffset; var P3 = vector(aline[3], -aline[4]) * ZoomCoefficient + splineOffset; var P4 =…
-
FeatureScript TableData not effective.
I write a FeatureScript which has to import a csv file : export const CSV_Path = defineFeature(function (context is Context, id is Id, definition is map) precondition { annotation { "Name": "file" } definition.myPathCurve is TableData; My problem is that half the time the file is not read The script starts correctly, If I…
-
println units
Hello Here is a small piece of code: var sketchPlane = evOwnerSketchPlane(context, { "entity" : definition.selectedEdge }); var n = 100; var samples = evEdgeTangentLines(context, { "edge" : definition.selectedEdge, "parameters" : range(0, 1, n) }); var origin = worldToPlane(sketchPlane, samples[0].origin); println(origin *…
-
evaluateSpline: Parameter at index 0 is outside the knot vector
I used a Split feature on a curve (helix) entity, and wanted to then subdivide this split version of the entity into line segments. However, I got the below error. Is this because the curve needs to in an ideal world be reparameterised between 0 and 1? Has the split operation done some funky business where it's almost…
-
skFitSpline and bSplineCurve .controlPoints
Hello, I draw a spline on sketch1: skFitSpline(sketch1, "spline1", { "points" : [ vector( 0 , 0) * centimeter, vector( 100, 100) * centimeter ], "startDerivative" : vector(150 , 0) * centimeter, "endDerivative" : vector(0 , 150) * centimeter, }); test: same with code formatting <div> skFitSpline(sketch1, "spline1",…
-
Reading feature related infromation
Is there any way to get the information added in feature script(samples below) through api. throw regenError("This is a regen error");reportFeatureInfo(context, id, "Some error found"); https://cad.onshape.com/documents/a63f2300d0234e62b89f906d/w/1432bb01183f19577aa937e2/e/32e2592e0830a05993a8a875
-
Seeking featurescript for: select 3 points, automatically generate triangle surface face
Does anyone know if something of the like has already been made by someone? I am seeking the ability to select 3 points anywhere on my model, then fill a triangular face there. I am currently using bridging curves and the fill tool, but would like to consolidate down to a single feature as this is a relatively frequent…
-
RayCast Result: Entity Equivalence in a TransientId
I have an input surface that I am casting rays onto, but as well as this surface I am also casting rays through another object's faces. I'm trying to see which ones reach the surface and which don't. So I'm attempting to use the transientId in the RaycastResult map. What I'm finding though, is that evaluating the surface…
-
3D polylines with featurescript?
Hi. I want to make featurescript where I can make a 3D polyline with featurescript. When the polyline is created I also want to be able to make sketch fillets on the corners afterwards. How should I approach this? One of the featurescript samples is "Featurescript 3D spline". Can I use this as a basis?…
-
Overriding 'Expected Query' when running an imported feature within another
I've had a little dabble with importing and running a feature from a different document within another feature's body. What I'm experiencing though is that where the imported function expected queries for vertices etc, I would like to be able to pass in vertices which have, for instance, been calculated/determined in a way…
-
Query that Resolves to nothing != qNothing()
I stumbled on some strange behaviour I couldn't figure out. What I thought was quite a straightforward conditional where I do a qSubtraction, resolved weirdly. As below. const allGeom = qCreatedBy(id + "extrudeThin", EntityType.FACE); const planeGeom = qGeometry(qCreatedBy(id + "extrudeThin", EntityType.FACE),…
-
Allow selection of only flattened geometry
I hacked together a Featurescript based on smPerforateBend but with simple holes instead of slots to better suit my application: Bend Holes I also added an option to 'suppress' holes that are too close to a reference edge/vertex. The issue is this only behaves appropriately when selecting geometry in the flat pattern.…
-
dumb question from dumb user about making clone of featurescript
The short question is: Can I clone somebody else's featurescript and rename it so it is easily searched (and found) by my younger students? long version: I run a school technology workshop where any kid in the school from age 5 to 18 can pop in and work on any project that inspires them. The vast majority of the projects…
-
PSA - New FeatureScript UI Options
Onshape recently updated the UI precondition parser, which unlocked some new options for specifying UI. Since it seems these changes didn't make it into the changelog, I figured I'd make a post highlighting some of the new additions: * Group parameters can now be driven by Quantity parameters. This results in the group…
-
Linear Mass Custom Property via FeatureScript
I have successfully created a few lines of FeatureScript to take the volume of a 100mm long extrusion and output the volume per metre (including changing the units) using evVolume. I want to do the same thing with mass per metre, but it appears evApproximateMassProperties requires a hard-called density, even though the…
-
Referencing cut list information in assembly drawings and Onshape BOM
Prefacing this with being only a couple weeks into actually using Onshape I have a number of parts studios that use featurescripts to produce a cut list with information we want to show on PDF shop drawings. It's pretty straightforward to insert just the composite part created from the frame tool (etc) into a drawing and…
-
Query for entities to boolean
Hi, I'm trying to boolean subtract bodies created with oppattern inside a for loop. Not sure what I should do... Thank you! doc: https://cad.onshape.com/documents/ef3ba98102efc6b4e4c71194/w/50cf1b58a05a4b7c535589fd/e/8c530af3038d5e69dbf7c755 for (var i = -1; i < definition.numberOfHoles - 1; i += 1) { const…
-
Measuring Flat Patterns?
I'm trying to figure out a way to model a flex circuit in its bent form and by controlling a dimension, end up with the flat pattern having the correct length. I can get something by trial and error which is close enough (a path length measurement in sketcher sure would help here). One frustration is that the custom…
-
ACCESSING/CONTROLLING ONSHAPE FROM AN EXTERNAL PROGRAM (Python script for instance)
Hello, Is it possible to access Onshape through an external program, perhaps something written in python? I am working on a FeatureScript that generates a solid from a .csv file with vertex data. My goal would be to automate the whole process by having a python script; 1 - generate/update the .csv file (independent from…