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.

Feature Script: Roll Form Die - How to subtract transformed parts in a loop?

ludwig_haasludwig_haas Member, Channel partner Posts: 5 EDU
edited April 2021 in FeatureScript
Hi Onshapers,

In essence, I am trying to create a roll form die from an imported part.
I have identified two ways of doing this:

Way #1: "Rotate Part around roll"
In this case, I import the part, drop a MateConnector on its center and create a cylinder as a "roll" above it. The center of the cylinder is aligned with the center of the part, but moved up, by the radius R.
With the following code I rotate the part around the MC while moving its tangential point accordingly and create a copy for every step.
This yields me a number of parts (from -90° to +90° it is 180) that I then have to subtract from the cylinder.
My question is: How do I incorporate the opboolean to subtract every new generated part from the cylinder.
(Doing this by hand takes some time and some parts fail to subtract)
&nbsp;&nbsp;&nbsp;    precondition<br>        <br>    <br>    {<br>        annotation { "Name" : "My Query", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }<br>        definition.Part is Query;<br>        <br>        annotation { "Name" : "Mate Connector", "Filter" : BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 }<br>        definition.mc is Query;<br>         <br>        annotation { "Werkstuck2" : "My Query", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }<br>        definition.cyl is Query;    <br>    <br>    }<br>    {<br>        <br>        const parentId = id + "tools";<br>        const parentId2 = id + "boolean";<br>        var i = 0;<br>        var angle = -90;<br>        for (var i = 1; i < 180; i += 1)<br>        {<br>        <br>        var mc = evMateConnector(context, { "mateConnector" : definition.mc });<br><br>        var rotation = rotationAround(line(mc.origin, mc.xAxis), angle * degree);<br>        <br>        var verschieben = transform(vector((5.31496*sin(angle * degree))+((angle/180*5.31496*PI)*-cos(angle * degree)), 0, (5.31496*-cos(angle * degree)+5.31496)+((angle/180*5.31496*PI)*-sin(angle * degree))) * inch);<br>        <br>                <br>        opPattern(context, parentId + toString(i), { "entities" : definition.Part,<br>                                 "transforms" : [verschieben * rotation],<br>                                 "instanceNames" : ["1"],<br>                                 notFoundErrorKey("entities") : ErrorStringEnum.COPY_SELECT_PARTS });   <br>        angle = angle + 1;<br>        <br><br>        opBoolean(context, parentId2 + toString(i), {<br>                "tools" : definition.Part,<br>                "targets" : definition.cyl,<br>                "operationType" : BooleanOperationType.SUBTRACTION,<br>                "keepTools": true<br>        });<br>        <br>        }<br>                             <br>    });<br>

Way #2: "Rotate and move Roll on tool"
In this scenario I am placing the cylinder on the very left of the part and then perform a rotational and translational movement to the roll. (The slot was just to track if the rotation was correct).
Again I am struggeling to incorpoorate the boolean subtraction into my loop.
precondition<br>        <br>    <br>    {<br>       annotation { "Tool" : "My Query", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }<br>        definition.Part is Query;<br>        <br>        annotation { "Roll" : "My Query", "Filter" : EntityType.BODY, "MaxNumberOfPicks" : 1 }<br>        definition.cyl is Query;<br>        <br>        <br>        annotation { "Name" : "Cylinder", "Filter" : EntityType.FACE && GeometryType.CYLINDER, "MaxNumberOfPicks" : 1 }<br>        definition.Constant is Query;<br>            <br>    <br>    }<br>    {<br>        const parentId = id + "tools";<br>        const parentId2 = id + "tools2";<br>        const parentId3 = id + "boolean";<br>        var i = 0;<br>        var angle = 90;<br>        //for (var i = 1; i < 5; i += 1)<br>        //{<br>        <br>        var axis = evAxis(context, { "axis" : definition.Constant });<br><br>        var rotation = rotationAround(axis, angle * degree);<br>        <br>        var move = transform(vector(((angle/360)*PI*2*5.158241), 0, 0) * inch);<br>        <br>                             <br>        opTransform(context, parentId + toString(i), {<br>                "bodies" : qOwnerBody(definition.cyl),<br>                "transform" : move * rotation <br>        });<br>        <br>        opTransform(context, parentId2 + toString(i), {<br>        "bodies" : qOwnerBody(definition.Constant),<br>        "transform" : transform(vector(((angle/360)*PI*2*5.158241), 0, 0) * inch)<br>        });<br>        <br>                          <br>        opBoolean(context, parentId3 + toString(i), {<br>                "tools" : definition.Part,<br>                "targets" : qOwnerBody(definition.cyl),<br>                "operationType" : BooleanOperationType.SUBTRACTION,<br>                "keepTools": true<br>        });<br>        <br>        //angle = angle + 1;<br>        //}                       <br>    });




Follow up question: The Roll needs to be imported into a simulation tool. If the boolean leaves me with a rough surface, I might need to smoothen it. Is there a way to do that?

Thanks in advance
Ludwig
Tagged:

Best Answer

  • konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    edited April 2021 Answer ✓
    The Envelope feature is not very perfomant, so the regen time for 50 cross sections per 50 points in each is about 60 seconds and it is the best I could do with the functions avaliable.
    RotTrace creates an array of tool body instances in their intermediate positions during the motion relatively to workpiece body.
    Envelope feature detects the points of envelope surface using raycast function.
    If your tool body has any symmetry I would absolutely reccomend to use a minimal nontrivial part of this body and then creating the pattern of resulting envelope geometry

Answers

Sign In or Register to comment.