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.
Intersection between Circle and Ellipse
nir_naron
Member Posts: 26 EDU
Input is an Ellipse, my code generates a circle that intercects the ellipse exactly two times (its the smalles enclosing circle). How can I get the value of said two intersection points?
Sorry for messy code
Sorry for messy code
FeatureScript 2221; import(path : "onshape/std/common.fs", version : "2221.0"); annotation { "Feature Type Name" : "Elliptical Helix" } export const EllipticalHelix = defineFeature(function(context is Context, id is Id, definition is map) precondition { //qGeometry(definition.Ellipse is Query, GeometryType.OTHER_CURVE); annotation { "Name" : "Ellipse", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 } definition.Ellipse is Query; //annotation { "Name" : "Number of Turns"} //isInteger(definition.NumTurns, POSITIVE_REAL_BOUNDS); annotation { "Name" : "Circle", "Filter" : EntityType.EDGE, "MaxNumberOfPicks" : 1 } definition.Circle is Query; } { // Define the function's action var sketchId = id + "sketch"; var Ellipse = definition.Ellipse; var Circle = definition.Circle; var Center = evApproximateCentroid(context, {"entities" : Ellipse}); var BigRad = evCurveDefinition(context, {"edge" : Ellipse})["majorRadius"]; //var TwoDCenter = sort(Center, function(a,b){return(b-a);}); //println(resize(Center,2)); var sketchPlane = evOwnerSketchPlane(context, { "entity" : Ellipse }); var cSys = planeToCSys(sketchPlane); var sketchPlane2 = plane(Center*meter, cSys.zAxis); var sketch1 = newSketchOnPlane(context, sketchId, { "sketchPlane" : sketchPlane2 }); skCircle(sketch1, "circle1", { "center" : vector(0, 0)*meter, "radius" : BigRad}); skPoint(sketch1, "point1", { "position" : vector(0*meter, BigRad)}); //definition.point1 is Query; //var point1 = definition.point1; //println(point1); opHelix(context, id + "helix1", { "direction" : sketchPlane2["normal"], "axisStart" : Center, "startPoint" : point1, "interval" : [0, 10], "clockwise" : true, "helicalPitch" : 0.1 * inch, "spiralPitch" : 0 * inch }); skSolve(sketch1); println("haha"); }); //qGeometry(qBodyType(qEntityFilter(seed1_REPLACE_ME, EntityType.EDGE), BodyType.WIRE), GeometryType.CIRCLE)
0
Answers
seems to work. But it doesn't really contain the point's values, so I can't really use it for the Helixe's Start Point.
Error:
Thanks a lot for your help
<br><br><br>
I don't really need the sketch. What I'm trying to do is write a script that receives an ellipse and a hight as inputs and outputs an elliptical helix matching them. I plan on doing this using the Projected Curve tool.
Link to document. Check out the Part Studio named "Goal".
https://cad.onshape.com/documents/6e86fb25b6b8f98a9f75d61f/w/4ed281d19b48cdb345ec86ed/e/12a0d3a6f8e2817aba5b2e3d?renderMode=0&uiState=6597e1949a15484af8f96795
I managed to write a script that gets an ellipse as an input and creats a circle that fully encloses said ellipse. I was hoping to be able to just feed that into OnShape's Helix feature instead of working with opHelix. Is there a way to do that? If not, how would you reccomend getting this done with opHelix?
I am very new to FeatureScript. Many thanks
I would be curious to see how you would go about doing this with the Projected Curve approach (See the part studio named “Goal”).
Plus, how can I add a menu to switch feature-input types? Same way the Helix feature can receive either a circle or an axis or a face, and the Extrude feature can either be a New or an Add etc…