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

Parameters For a Helical Gear Feature Script

peter_morrispeter_morris Member Posts: 43 ✭✭
I'm very slowly getting to grips with Featurescript and modifying Neil Cooke's Spur Gear code to allow me to apply a helical gear profile to an already extruded blank.  The next stage requires (in my mind) the confirmation that the queried face is in fact a circle and then to extract the position of its centre and its radius/diameter.

I think I'm then going to have a question about how to use feature script to apply a helix to an extruded circular surface, but that perhaps can wait for another day.

Any advice greatly received.

Many thanks.

Peter

Comments

  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    Take a look at evCurveDefinition and evSurfaceDefinition (for a face).
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    cody_armstrongcody_armstrong Moderator, Onshape Employees, Developers, csevp Posts: 213
    edited March 2017
    You can grab the edge of the queried face with qEdgeAdjacent.  Something like this...
     var edge = qEdgeAdjacent(face, EntityType.EDGE);
    Then use evCurveDefinition to return the edge as a circle.
    var curve = evCurveDefinition(context, { "edge" : edge });
    Then create an If statement that throws a regen error if the edge is not a circle.

    <div>if (!(curve is Circle)) // if the selected curve is not a circle throw error</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw regenError("Selected face does not have a circular edge");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>

    Now that you know it is a circle you can get the radius.

    var curveRadius = curve.radius;
    I created a straight sided spline feature that does alot of this.  Might be worth checking out.

    Straight Spline Feature
  • Options
    peter_morrispeter_morris Member Posts: 43 ✭✭
    Thank you both for your quick responses which are already helpfing! Very much appreciated.

    Peter
Sign In or Register to comment.