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.
NEED HELP ON FS
papawo
Member, Developers Posts: 206 PRO
Comments
If this entire process is happening in FeatureScript, I would just sketch the rectangle in the position you actually want it rather than trying to move it around. You could also accomplish this entire case with "fCuboid" but I assume this is just a simplified version of something more generic.
The best way to do exactly what you want to do would be the following:
- Use opExtractSurface to turn the sketch face into a surface.
- Find the Plane at the center of the surface using evFaceTangentPlane with a parameter of (0.5, 0.5)
- Find the point and direction at the end of the edge using evEdgeTangentLine (*see node below)
- Change the found tangent line into a plane using Plane(tangentLine.origin, tangentLine.direction)
- Construct your transform using transform(faceTangentPlane, edgeEndPlane)
- Transform the surface using opTransform(...)
- Sweep using opSweep
* Note on how to find the tangent line:You may need to take in a helper point for the end of the line you care about and do something like the following to figure out which parameter to use:
^ There are a number of different ways to do something like this, this was just the first that came to mind.
This was a pretty high level explanation, and I'm not sure of your programming experience in FS. Please let me know if you'd like a more detailed explanation or have any specific questions.
I'm not sure there's a simpler way to do this, but I can try to make the process clearer. Would you prefer if I write a custom feature that does this for you so you can use it as a sample to learn from, or would you prefer that I write a more detailed description so that you can try to do it yourself?
https://cad.onshape.com/documents/57ffe78b4a526810dcbb1fc9/w/b5546fa462ee9ea8409fb580/e/9ffafc49f03e2e027ce54c34
I've made a custom feature for this, and hopefully the code itself, the comments in the code, and my initial explanation will be enough to piece together a picture of how to do this.
https://cad.onshape.com/documents/33258f05b113f6aad79dc7f9/w/7bbd4ad8c1b9d6d2dee33a83/e/1116aeea70b5188e5859cb93
In the provided document, I've made two features: "Transform sweep - simple" and "Transform sweep - advanced".
Simple is useful as a learning tool to see the basic MVP (minimum viable product) for something like this. As in my initial explanation it does the following:
- Copy the desired sketch as a surface
- Collect information about where the sketch is and where the line is
- Transform the surface to be at the start of the line
- Sweep the surface over the line
- Delete the helper surface (so as not to have a random surface hanging around in the part studio)
The code is pretty simple for this, I think if you take a look, it'll be straightforward to see what's going on. This simple version can be found in the feature studio called "simple".To augment this, "Transform sweep - advanced" can be found in the feature studio called "advanced". This feature augments the original feature such that:
As always, happy to answer any questions you may have after seeing this.
In your "Transform sweep - simple", instead of filtering entitytype:face , how can I change it to select featureList?
You can replace the two lines with in the precondition for definition.profile with the following:
Finally, for every place that previously referred to "definition.profile" , change that to "profileEntities" so the new full query will be used.
but replacing it doesnt work. can you point me what is wrong.
___________
This line uses the "definition.profile" defined above in the feature. If that name doesn't match the parameter name, it will have no value (that is, it will be "undefined"), which causes the error you saw.
It should be
with your code, if so its still doesnt work
The only thing you need to change from the code you pasted above is that:
should be:
Because the input variable in your feature is defined as 'definition.profile', not 'definition.features'. The qCreatedBy function that you've defined at the bottom of your file will take care of what Lana is telling you to do.
Calling it this way will give you everything created by the feature list that you take in. That means it will give you all the vertices, edges, faces, and bodies created by the selected features. You can see that this is the case if you add the line "debug(context, profileEntities);", which will print out for you the contents of the "profileEntities" query.
Once you make that change, you'll most likely have a new error on "opExtractSurface"! This is because you're then trying to pass these "profileEntities" (which currently include vertices, edges, faces, and bodies) into "opExtractSurface", but "opExtractSurface" only takes faces. This wasn't a problem in your old code because definition.profile was explicitly only taking faces. What you'll want to do to fix this is replace the line we're working on with:
which gets all the entities created by the selected features, and then filters out everything that isn't a face.
Now if you do "debug(context, profileEntities)", you will see that that query only refers to the created faces of the selected features.
After you make this small change, please comment if there are more errors!
No more error.
Thank you so much!! your explanation helps a lot!