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

Sketch modification by FS

konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
I'd like to find out if FS allows to take a user-defined sketch as one argument and and the dimention from that sketch or the viriable that drives a certain dimention and generate a new sketch having those dimention changed by user set rule. This can be used for dimention-driven patterns and in kinematically-defined planar curves.

Comments

  • Options
    ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,178
    It is doable, but it's not as easy as I'd like.  I thought it's possible using just a linear feature pattern and a variable (see Neil's feature pattern video here https://forum.onshape.com/discussion/2675/improvements-to-onshape-february-11th-2016/p1), like this: https://cad.onshape.com/documents/380f2724ca01d5e71d281fa3/w/78704abdcb1709d70a5602d3/e/eb4260d3c129eab80edaf3a8

    But unfortunately, the sketches don't line up: inside a feature pattern, a sketch drops all external constraints (this makes it possible to pattern a solved unchanging sketch without patterning everything it is constrained to, but at the cost of this use case).  So I think the way to fix this with FS is to modify the linear pattern feature so that after each sketch call it queries for a point on the sketch and does an opTransform on all created sketch entities to bring it back to where you want it.

    Hope this helps and post if you have further questions.

    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • Options
    konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    Hello, @ilya_baran
    I'd like to return to this problem as soon as can't find sketch calls inside the Linear pattern feature in the explicit form.
    Minimal task is - take a sketch as first argument, take the name of variable as a second one, and the value of the variable as a third argument. Then regenerate the sketch with this changed value of variable.
    I apologize in advance for possible stupid questions.
    The questions are:
    - How to get sketch object from query as one? Im trying precondition "is FeatureList" but it gives a map, wich I process with "valuesSortedById" and obtain a function, but it isn't of sketch type, and skSolve can't be applied.
    - Maybe I shouldn't try regenerating the original sketch, but instead somehow create an intermediate copy of it?

    here is my code, the only thing it does now - changes value of variable
    FeatureScript 543;<br>import(path : "onshape/std/geometry.fs", version : "543.0");<br><br>annotation { "Feature Type Name" : "Sketch modificator" }<br>export const sketchModificator = defineFeature(function(context is Context, id is Id, definition is map)<br>    precondition<br>    {<br>        // Define the parameters of the feature type<br>        annotation { "Name" : "Source Sketch", "Filter" : /*EntityType.FACE && */SketchObject.YES, "MaxNumberOfPicks" : 1 }<br>        definition.mySketch is FeatureList;<br>                        <br>        annotation { "Name" : "Name of variable" }<br>        definition.varName is string;<br>               <br>        annotation { "Name" : "Value of variable" }<br>        isLength(definition.value, LENGTH_BOUNDS);<br><br>    }<br>    {<br>        // Define the function's action<br>        var sourceSketch = valuesSortedById(context, definition.mySketch)[0];<br>            <br>        var variable = definition.varName;<br>        <br>        var val = definition.value;<br>        <br>        setVariable(context, variable, val);<br>        defineFeature(sourceSketch);<br>        <br>    });







Sign In or Register to comment.