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.
How do I orient an ellipse (skEllipse)?
Aaron_Hoover
Member Posts: 35 EDU
I'm generating an ellipse on a plane with skEllipse and I'd like to be able to rotate it in plane with respect to the coordinate system of the sketch plane. One way to do this would be specify the angle of the major axis wrt the X axis of the coordinate system, but there's no angle parameter in the skEllipse definition. So, I figured when I specify the "majorRadius" field perhaps I could pass a 2D vector rotated by the angle I want (with the minorRadius rotated by the same angle.) But, I get the following error:
Precondition of skEllipse failed (value.minorRadius is undefined || is...) | |||
232:5 | onshape/std/units.fs (val is ValueWithUnits) | ||
69:5 | onshape/std/valueBounds.fs (isLength(value)) | ||
439:5 | onshape/std/sketch.fs (skEllipse) |
0
Best Answers
-
lana Onshape Employees Posts: 706Please try this:
annotation { "Feature Type Name" : "Ellipse" } export const fEllipse = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Angle" } isAngle(definition.angle, ANGLE_360_BOUNDS); annotation { "Name" : "Major Radius" } isLength(definition.majorRadius, LENGTH_BOUNDS); annotation { "Name" : "Minor Radius" } isLength(definition.minorRadius, LENGTH_BOUNDS); } { const sketch = newSketch(context, id, { "sketchPlane" : qCreatedBy(makeId("Top"), EntityType.FACE) }); const center = vector(0, 0) * meter; const majorAxis = vector(cos(definition.angle), sin(definition.angle)) * meter; skEllipse(sketch, "ellipse1", { "center" : center, "majorAxis" : majorAxis, "majorRadius" : definition.majorRadius, "minorRadius" : definition.minorRadius }); skSolve(sketch); });
majorAxis is not well documented and is2dPoint precondition is wrong, actually a normalized 2d vector is expected.6 -
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565+1 to everything above, though note that the majorAxis does work with lengths that aren't 1 meter (e.g. vector(1, 1) * inch is fine). I'll add documentation for this argument in the standard library for a future release!
5
Answers