Correct way to do a "Center Point Arc" in Sketch in FeatureScript
Brad_Goodman
Member Posts: 39 ✭✭
What is the correct way to do a "Center Point Arc" in FeatureScript. I have tried an unbelievable amount of methods, and some seem to work, but when their points are contrained to other points on the sketch, under some angles they fall apart. The noteworthy thing here is that I need to constrain the three points to other geometry features.
The only real method I have found to do so I scraped from looking at sketch code - and I don't understand it at all - it's using several layers of undocumented stuff:
I am basically trying to draw two arcs like below, and connect their left and right lines. It works - but if the inner arc is greater than the outer arc - constraints go crazy and everything seems to disappear. I don't understand why/how the above code really works - or if there is a "better" way to do be doing this.
The other somewhat natural way to do this is to draw circles and trim the areas outside the lines - but again, the trim functions seem to rely on other skConstraints which are again undocumented and even more confusing/unintuitive.

The only real method I have found to do so I scraped from looking at sketch code - and I don't understand it at all - it's using several layers of undocumented stuff:
<div>skConstraint(sketch, "inner_arc1_center", { "constraintType" : ConstraintType.COINCIDENT, "localFirst" :
"inner_ellipticalArc1.center",<span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;"> "externalSecond":definition.location});
</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">skConstraint(sketch, "inner_arc1_quadrant", { "constraintType" : ConstraintType.QUADRANT, "localFirst" :
"inner_line1.end",</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">"localSecond" : "inner_ellipticalArc1" });
</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">skConstraint(sketch, "inner_line1_startSnap1", { "constraintType" : ConstraintType.COINCIDENT, "localFirst" :
"inner_line2.end",</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">"localSecond" : "inner_ellipticalArc1.start", "sketchToolType" : SketchToolType.TRIM });
</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">skConstraint(sketch, "inner_line1_startSnap2", { "constraintType" : ConstraintType.COINCIDENT, "localFirst" :
"inner_line1.end",</span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;">"localSecond" : "inner_ellipticalArc1.end", "sketchToolType" : SketchToolType.TRIM });</span></div>I am basically trying to draw two arcs like below, and connect their left and right lines. It works - but if the inner arc is greater than the outer arc - constraints go crazy and everything seems to disappear. I don't understand why/how the above code really works - or if there is a "better" way to do be doing this.
The other somewhat natural way to do this is to draw circles and trim the areas outside the lines - but again, the trim functions seem to rely on other skConstraints which are again undocumented and even more confusing/unintuitive.

0
Comments
-
Off topic reply I know but most of what i've seen with Onshape FS sketches relies on putting the geometry where you want it via coordinates and leaving it unconstrained rather than involving constraints at all. Not sure if that's due to a limitation in implementing sketch constraints or because they're really not necessary.
Hopefully one of the pros will jump in and explain best practice.
Cheers, Owen.Business Systems and Configuration Controller
HWM-Water Ltd3 -
You can calculate 3 points for built-in arc from center point, arc end point and arc angle, or from other parameters like 2 points and radius.
0 -
@Brad_Goodman
I don't think you need to use sketch constraints inside your custom feature. If you could share more information on what you are trying to achieve we'd be able to help you with your feature. e.g. here https://cad.onshape.com/documents/0d6f479475672dffd95e2482/w/7467794890fa74040bda1557/e/294ea16a64f1a9616e4c0c3e
1 -
So I did what @owen_sparks recommended - and just used regular math to calculate explicit points for everything - all seems to work well and was not too difficult. Thanks all!2
-
Business Systems and Configuration Controller
HWM-Water Ltd1



