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.

Useful Sketch Arc Midpoint Function

NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,688
In case anybody needs one...

skArc requires start, mid, and endpoint to create a sketch arc.
function getArcMidpoint(center is Vector, start is Vector, end is Vector) returns Vector
{
    // need to convert 2D vectors back to 3D
    const center3D = vector(center[0], center[1], 0 * meter);
    const start3D = vector(start[0], start[1], 0 * meter);
    const end3D = vector(end[0], end[1], 0 * meter);
    const angle = angleBetween(center3D - start3D, center3D - end3D) / 2;
    start = center - start;
    var ca = cos(angle); // in radians
    var sa = sin(angle);
    return center - vector(ca * start[0] - sa * start[1], sa * start[0] + ca * start[1]);
}


Senior Director, Technical Services, EMEAI

Comments

  • billy2billy2 Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
    Thanks Neil-

  • cory_isaacsoncory_isaacson Member, Developers Posts: 43 PRO
    This is really a great function, saved me a lot of time.
  • Stormi_BackusStormi_Backus Member Posts: 49
    I just spent so much time trying to figure this one out and got no where on my own, thanks Neil!!! 
Sign In or Register to comment.