Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Tenon Joint FeatureScript help
I cannot get this to work because I have been using FeatureScript for and hour and a half so I am a complete novice. How should I go about this?
Comments
-
Hi Lee, how far have you got? Which bit are you stuck on?
Also have you done the Featurescript slot tutorial? It covers a lot of what you'll need for your script.
Cheers, Owen S
Business Systems and Configuration Controller
HWM-Water Ltd0 -
I had a look at it and I tried to do a simple extrude but it didn't work.
Here is the code:FeatureScript 392;import(path : "onshape/std/geometry.fs", version : "392.0");annotation { "Feature Type Name" : "My Feature" }export const myFeature = defineFeature(function(context is Context, id is Id, definition is map)precondition{annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }definition.face is Query;annotation { "Name" : "Part", "Filter" : EntityType.BODY && BodyType.SOLID, "MaxNumberOfPicks" : 1 }definition.Part is Query;annotation { "Name" : "Depth" }isLength(definition.depth, LENGTH_BOUNDS);}{var face = definition.face;var depth = definition.depth;opExtrude(context, id + "extrude1", {"entities" : face,"direction" : evOwnerSketchPlane(context, { "entity" : face }).normal,"endBound" : BoundingType.BLIND,"endDepth" : depth * centimeter});});There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0 -
What is your work flow process? That will also help determine how to write your script.Digital Engineering0
-
Well for the script I posted, I was following the slot FeatureScript tutorial and modifying it to extrude a certain distance that the user inputs. It didn't work and I don't know why.There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0
-
Okay, I am trying to work on it and I have it working with one sketch.
The problem I am having is I can't seem to get the 'extrudeCut' to work in both directions....
Digital Engineering0 -
@LeeH Welcome to FeatureScript! Overall, your tenon joint feature sounds like something FeatureScript should be very capable of doing.
Just looking, your opExtrude is probably failing because depth has the wrong units. definition.depth already has length units (and the user will type something like "3 in" in that field), so when you multiply by centimeter, you're giving it area units, which opExtrude doesn't know how to deal with.
The fix is probably to just delete " * centimeter" from the depth parameter in your script.
Also, in the future, posting a link to a public document or a screenshot of the error flyout in the Part Studio will let people identify your issues faster. Some of the errors reported by FeatureScript can at first be hard to identify, but for people who are used to looking at them, its often trivial for kind souls on the forums to point out the issue.
0 -
I deleted the centimeter unit and still no luck. In the part studio, it simply says is did not regenerate properly cannot resolve plane.
link: https://cad.onshape.com/documents/51a4ed191be8c3b458ce259f/w/847ee03f2e14af8f13ce60dc/e/d25738af38b0c07077d16456
Feature studio 2 is the one with the simple extrude. The other is the whole script which also doesn't work.There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0 -
The "Cannot resolve plane" is because in line 27 you're calling evOwnerSketchPlane on a non-sketch object; asking for the sketch plane to which the face belongs doesn't make sense in this case.
Replacing that with evPlane() makes the feature work, as evPlane takes any flat face as input.
At a glance you have the same problem in the full feature, as well as the doubled units problem @kevin_o_toole_1 mentioned above. As an aside, line 48 of FS1 is probably more idiomatic with a call to skRectangle rather than polyline.
Arul Suresh
PhD, Mechanical Engineering, Stanford University0 -
I did all you said to do but it is throwing the errorPrecondition of evPlane failed (arg.face is Query)There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0
-
What this error is telling you is that when you call evPlane, somewhere in the second argument you need to have
"face" : queryForFaceWhosePlaneYouWant
So the cause of one of two things: either you don't have a "face" entry at all or you have one but the thing to the right of "face" is not a query (it could be an array or some geometry or something else -- we'd need to see the rest of the code to tell).Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0 -
Hi guys, thanks for all the help but I still can't get it to work. It's very frustrating. I tried following the slot feature, but the opExtrude part in the video seems outdated, because there appears to be no "direction" section. Now this error shows up.
Sorry for all the hassle, I have been using FeatureScript for a day and I have made no progress, still confused and have no idea what I'm doing. Whole document including code:@opExtrude: Expected vector (a non-empty array), value is MAP
https://cad.onshape.com/documents/51a4ed191be8c3b458ce259f/w/847ee03f2e14af8f13ce60dc/e/d25738af38b0c07077d16456There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0 -
Looks like you resolved that error; the current error is "Precondition of evOwnerSketchPlane failed (arg.entity is Query)" which is telling you that the argument you're passing is not a Query (you can't pass a sketch to evOwnerSketchPlane, line 48). Since it's a sketch you created, you don't need to evaluate evOwnerSketchPlane, you can just directly use the normal of the sketch plane (pointFace in your code) to define the extrude.
<div>opExtrude(context, id + "extrude1", { <span><pre class="CodeBlock"><code> "entities" : face, <span> "direction" : pointFace.normal, </span><span> "endBound" : BoundingType.BLIND, </span><span> "endDepth" : depth </span><span> });</span>Arul Suresh
PhD, Mechanical Engineering, Stanford University0 -
@lemon1324 Thank you so much, it works! If I may ask one more thing, when using skRectangle(), how could I use the length parameters used in the precondition as vector coordinates? Also, it appears the feature results in a tenon that is a separate part. This is not what I wanted, do you know how to fix it?There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!0
-
Are you wanting to a 'project geometry' from one part to the other?
Digital Engineering0 -
@LeeH
With regard to the new part for the tenon the "extrude" as oposed to the opExtrude" has the following parameter:-<span>operationType as </span>NewBodyOperationType enumDefines how a new body from a body-creating feature (extrude, revolve, etc.) should be merged with other bodies in the context.
To include this enum with the same styling as the extrude dialog (and others), use
booleanStepTypePredicate(definition).
Regards, Owen S.Value Description NEWCreates a new body in the context with the geometry resulting from the operation.
ADDPerforms a boolean union between the new body and all bodies in the merge scope.
REMOVEPerforms a boolean subtraction of the new body from all bodies in the merge scope.
INTERSECTPerforms a boolean intersection between each new body and each body in the merge scope.
Business Systems and Configuration Controller
HWM-Water Ltd0 -
@LeeH to get things with units into a vector for skRectangle, just don't multiply by the unit afterwards
e.g.var minCorner = vector(definition.width, definition.height)
where definition.width and .height already have units.
Arul Suresh
PhD, Mechanical Engineering, Stanford University0 -
@lemon1324 and @owen_sparks
Thank you both for the information, everything now works as it should! It's taken a while but I finally got it.
I ended up sticking with the opExtrude() and simply included an opBoolean() afterwards, which suffices.
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!1





