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.
Deduce a existant diameter or project a face
clément_schreiber
Member Posts: 2 ✭
Hello,
I would like to make a new Feature with FeatureScript. I would like to automatize the creation of screw thread. To do this I need to create a sketch on a surface. On this sketch I have to project the circle, or at least know the diameter of the screw.
For the moment, I could create a sketch plane with a circle but I could not deduce the diameter of the screw.
I absolutely need this function. If there is an other existent Feature to automatize the creation of a screw thread or a cosmetic screw thread it will be excellent.
I hope I was clear in the description of my problem.
I would like to make a new Feature with FeatureScript. I would like to automatize the creation of screw thread. To do this I need to create a sketch on a surface. On this sketch I have to project the circle, or at least know the diameter of the screw.
For the moment, I could create a sketch plane with a circle but I could not deduce the diameter of the screw.
I absolutely need this function. If there is an other existent Feature to automatize the creation of a screw thread or a cosmetic screw thread it will be excellent.
I hope I was clear in the description of my problem.
Tagged:
0
Best Answer
-
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565If you're starting with a cylinder, you can call evSurfaceGeometry() to get a Cylinder object, which has the radius stored as a ValueWithUnits.
To start off, below is a feature which evaluates a cylinder and places a plane on one side or the other, ready to be sketched on.
Source document (public): https://cad.onshape.com/documents/be8a5af4574bfcf507c34e38/w/e2dceba2d05f717895e64a88/e/1ddfec332143db1e7bfb2888
Feature code:annotation { "Feature Type Name" : "Screw start" } export const screwStart = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Shaft", "Filter" : GeometryType.CYLINDER, "MaxNumberOfPicks" : 1 } definition.shaft is Query; annotation { "Name" : "Flip side" } definition.flipSide is boolean; } { const cyl is Cylinder = evSurfaceDefinition(context, { "face" : definition.shaft }); println("radius: " ~ toString(cyl.radius)); const boundingBox is Box3d = evBox3d(context, { "topology" : definition.shaft, "cSys" : cyl.coordSystem }); var sketchPlane; if (definition.flipSide) { sketchPlane = plane( cyl.coordSystem.origin + cyl.coordSystem.zAxis * boundingBox.maxCorner[2], // origin -cyl.coordSystem.zAxis, // normal -cyl.coordSystem.xAxis // x ); } else { sketchPlane = plane( cyl.coordSystem.origin + cyl.coordSystem.zAxis * boundingBox.minCorner[2], // origin cyl.coordSystem.zAxis, // normal cyl.coordSystem.xAxis // x ); } debug(context, sketchPlane); var sketch1 = newSketchOnPlane(context, id + "sketch1", { "sketchPlane" : sketchPlane }); // Create sketch entities here skSolve(sketch1); });
6
Answers
Just need to automate these steps with the feature script code.
Hope it is usefull
To start off, below is a feature which evaluates a cylinder and places a plane on one side or the other, ready to be sketched on.
Source document (public): https://cad.onshape.com/documents/be8a5af4574bfcf507c34e38/w/e2dceba2d05f717895e64a88/e/1ddfec332143db1e7bfb2888
Feature code:
@kevin_o_toole_1: That is great! Thank you very much.