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.
question about feature script sketch merge and constrain when using circular pattern
Hi, I have two questions about my 2D sketches project at school.
first, when I use the circular pattern, the sketch will not fully constrain. I try to use skconstrain tool but realize that I need to skslove the sketch to be able to use the circular pattern tool. I do not know how to use the skconstrain when the sketch was already solved.
the second question is also about the constraint. Since I sketch my circles and arcs in different sketches so they do not recognize each other, which make perfect sense. However, Is there a way to merge different sketches?
using a circular pattern with multiple sketches
https://cad.onshape.com/documents/13fd38394d33485d50d1541d/w/7bb55977ab2fa287378daae6/e/afef66410945473a7c0073c3
end up hardcoding everything in the second version on below works but not pretty:
https://cad.onshape.com/documents/7bd52314a96f9a14b24e8ca8/w/290640dd845c1e9488e4008d/e/4a2a3650ac6f9bad46b17163
Thank you in advance
first, when I use the circular pattern, the sketch will not fully constrain. I try to use skconstrain tool but realize that I need to skslove the sketch to be able to use the circular pattern tool. I do not know how to use the skconstrain when the sketch was already solved.
the second question is also about the constraint. Since I sketch my circles and arcs in different sketches so they do not recognize each other, which make perfect sense. However, Is there a way to merge different sketches?
using a circular pattern with multiple sketches
https://cad.onshape.com/documents/13fd38394d33485d50d1541d/w/7bb55977ab2fa287378daae6/e/afef66410945473a7c0073c3
end up hardcoding everything in the second version on below works but not pretty:
https://cad.onshape.com/documents/7bd52314a96f9a14b24e8ca8/w/290640dd845c1e9488e4008d/e/4a2a3650ac6f9bad46b17163
Thank you in advance
0
Best Answers

paul_chastell Onshape Employees Posts: 126The problem may be that circularPattern is a feature operation. If your goal is to put all the geometry in the same sketch I would suggest making all the geometry in the same sketch to begin with, which is what the second document appears to do. You don't need to add any constraints at all if you make the geometry in the correct place. However, if you want the sketch to do the work for you, and reposition geometry to meet the constraints of the pattern, then you will. Doing it yourself, using loops rather than coding each one individually would make for more concise code with fewer bugs, e.g. draw_lit_cir could be rewritten with a loop, a bit of math, and only one call to skCircle.
Note that adding pattern constraints probably won't help you anyway because you still need to create all the geometry and you probably need to create it close to where it will eventually be so that Onshape has a chance of solving. Were I doing this I would not add constraints, I would just use math and loops.Paul Chastell
TVP, Onshape R&D6 
paul_chastell Onshape Employees Posts: 126And I've added a simple example of what I mean here: https://cad.onshape.com/documents/8e940365ff5576f2d5947b66/w/87fa8e9e372ccba0ab8f9bc0/e/943f06a64756586adae6da37
annotation { "Feature Type Name" : "Patterned sketch" } export const patterned = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Count" } isInteger(definition.count, POSITIVE_COUNT_BOUNDS); } { // Make the sketch const sketch = newSketchOnPlane(context, id + "sketch", { "sketchPlane" : plane(vector(0, 0, 0) * meter, vector(0, 0, 1)) }); // Define the position of the geometry for the 'seed' position const mm = millimeter; const start = vector(100, 10, 0) * mm; const mid = vector(130, 0, 0) * mm; const end = vector(100, 10, 0) * mm; const axis = line(vector(0, 0, 0) * meter, vector(0, 0, 1)); const full = PI * 2 * radian; // Loop through the required number of instances, transform the points and create the geometry for (var i = 0; i < definition.count; i += 1) { const lineId = "line" ~ i; const arcId = "arc" ~ i; const rotation = rotationAround(axis, (i / definition.count) * full); const start3d = rotation * start; const mid3d = rotation * mid; const end3d = rotation * end; const start2d = vector(start3d[0], start3d[1]); const mid2d = vector(mid3d[0], mid3d[1]); const end2d = vector(end3d[0], end3d[1]); skLineSegment(sketch, lineId, { "start" : start2d, "end" : end2d }); skArc(sketch, arcId, { "start" : start2d, "mid" : mid2d, "end" : end2d }); } skSolve(sketch); });
Paul Chastell
TVP, Onshape R&D1
Answers
Thank you for the reply
Note that adding pattern constraints probably won't help you anyway because you still need to create all the geometry and you probably need to create it close to where it will eventually be so that Onshape has a chance of solving. Were I doing this I would not add constraints, I would just use math and loops.
TVP, Onshape R&D
TVP, Onshape R&D
If you have want to take a look below is my github. We able to play with the 3D as well
github: https://github.com/JCTGY/2D_FeatureScript
Onshape: https://cad.onshape.com/documents/7bd52314a96f9a14b24e8ca8/w/290640dd845c1e9488e4008d/e/a40c1ed49153c80a4acac5b6
TVP, Onshape R&D