Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

Options

Correct way to do a "Center Point Arc" in Sketch in FeatureScript

Brad_GoodmanBrad_Goodman Member Posts: 38 ✭✭
edited January 2020 in FeatureScript
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:
<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&nbsp; });

</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&nbsp; });</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.


Comments

  • Options
    owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    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 Ltd
  • Options
    konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    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.
  • Options
    lanalana Onshape Employees Posts: 693
    @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

  • Options
    Brad_GoodmanBrad_Goodman Member Posts: 38 ✭✭
    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!

  • Options
    owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Nice script :+1:
    Glad you got it all working.
    Cheers,
    Owen S.

    Business Systems and Configuration Controller
    HWM-Water Ltd
Sign In or Register to comment.