-
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…
-
FeatureScript: Query imported geometry
I am trying to figure out how to refer to any geometry of a feature that has been imported into a PS through FeatureScript. (Import is done using either opMergeContext() or importDerived(), not sure which one is preferable). It is important to me that there is no user selection (feature querying) involved, as I will be…
-
Mate connector
Hi! I added a mate connector to my bevels gear: https://cad.onshape.com/documents/9b04fb889def400dfd4a693f/v/49c81b9a7cb792589aff29d1/e/fc99f57d0b9bb11ec95b86b7 Is there a way to have them appear as independant Mate connectors, so I can show/hide them, and also to be able to select them from the parts list, in an assembly?…
-
Error when calling opSplitPart, CANNOT_RESOLVE_ENTITIES
Hello all, yet again I have another error, but in a different script this time. I am creating a script that splits a part into laminations, for use when creating counter tops out of many boards for example. I am using a for loop with the variable i to do this. The user selects the face which they want the board length to…
-
Fasteners creator
Hi everyone, I have started a document to easily create standard fasteners. Currently I have 3 featureScript that allow quick creation of washer screw and bolt. Each feature rely on table, currently the table are not fully completed but this is an ongoing work. I am new at featureScript and any suggestion on this document…
-
Use an editing logic function with booleans?
Can an editing logic function be used to tick a boolean check box in the UI? If so, how? Thanks Lee Hesketh
-
What is the best way to offset vectors depending if they're positive or negative?
Hello all, I have come across a peculiar error in my code. I am using a vertex as a reference point for the first corner of an skRectangle(). I am using worldToPlane() to achieve this. I am then adding a vector which is offsetting the first corner in relation to the vertex. It looks like this: skRectangle(sketch1,…
-
How to mirror a part using a plane?
I tried calling mirror, but there was no option to select entities or a mirror plane. Which function do I have to call to do this?
-
Using an editing logic function to drive multiple UI values
Hello all. Can one editing logic function be used to updated multiple changed values int the UI panel? If there are two values, let's say for simplicity's sake two length values, that are then changed in the code. Will both values be able to be updated or do ELF's only change one value?
-
skPoint unique ID's
In the following code: <br>for (var i = 0; i < 1/pointmultiplyer; i += 1)<br> {<br> <br> skPoint(theSketch,"point"+ toString(i), {<br> "position" : vector(curx, cury) <br> });<br> curx+=pointxadder;<br> cury+=pointyadder;<br> } It tells me "Can not add string and string" How else do I use a unique ID?
-
FS Hole example
The documentation is incomplete for the hole feature, is there an example of how to drill a hole in a part? Looking at the hole.fs source, it's not obvious how to do it either.
-
GeometryType.OTHER_CURVE documented but not implemented?
This query doesn't seem to work, but similar ones for GeometryType.ARC and GeometryType.LINE do: `var asCurves = evaluateQuery(context, qGeometry(path.edges[i], GeometryType.OTHER_CURVE));` The message I get is `@evaluateQuery: Unknown geometry type: OTHER_CURVE`. But the docs for the GeometryType enum do have the other…
-
constructPath using faces with holes
I'm attempting to traverse paths on a face that potentially has holes in it. Using the constructPath function throws an error with the message "Edges do not form a continuous path" in the case where there is a hole. I suppose this makes sense. Two questions: (1) is there a reasonable pre-processing I can do to the edge…
-
Vectors different depending on which plane used to create part
@ilya_baran Since you are familiar with my script, I thought it best if you had a look at this problem I have. Everything works fine except when creating the tenon after specific creation of parts. Basically, depending on which plane I use to create the sketch that is used to make the part that has the tenon, it either…
-
Use a variable in a boundSpec
Hell again, how could I use a variable as the maximum value for a lengthBoundSpec? Thanks Lee Hesketh
-
Suppressing automatic filling of disjoint polylines and keeping sketches extrudeable
I'm working on a little FeatureScript just as a learning exercise which generates a sketch based on the 10 PRINT routine. It's still rough but I am hitting a problem early on. Onshape is creating faces correctly for my closed polyline entities, however it is also creating additional faces if multiple polyline objects…
-
Get all faces of a part
Hi, how could I get all the faces of a body? I have got the body I need, I just need to iterate through the faces to find the smallest area and use that in a distance calculation. The body is a simple cuboid. Thanks Lee Hesketh
-
Query for specefic edges that are looped around faces?
Hello, still having difficulty with featurescript! I am trying to query these edges from a loop of faces: I have already got the faces, but when I use qEdgeAdjacent(), it selects the end edges as well. I don't need these as I am hoping to use the edges as arguments for a fillet operation. How could I query this? I have…
-
A one-shot script that populates a feature tree
Hi Everybody! I had already touched upon this subject but there was no way to implement it. Let me remind as discussion was carried out: Is there any way to write a script that could call features in the particular order(i.e. by scenario)? I know that I can just create another feature and call all functions (custom…
-
3D and 2D points not matching
Hi all, hope you had a good Christmas and Happy New Year! I have encountered a problem yet again with my mortise and tenon script. I used the worldToPlane() function to use as a reference point for skRectangle(). I debugged the 3D point and added vectors to get the correct width between the two points and that works. The…