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.

Mirror for spline

quentin_moutyquentin_mouty Member, Developers Posts: 13
edited March 2017 in FeatureScript
Hello,
I want to mirror a spline around a line in a sketch in a feature script.
I find the mirror function but I am not sure if it is the right function to do it and if so how to use it.
I tried this :
mirror(context, id + "mirror1", {<br>        "patternType" : MirrorType.FEATURE,<br>        "entities" : "spline1",<br>        "mirrorPlane" : "line1"<br>        });
Where spline1 and lin1 are :
skFitSpline(sketch1, "spline1", {<br>                    "points" : [<br>                            vector(X(0, rayon_base), Y(0, rayon_base)) * millimeter,<br>                            vector(X(0.1, rayon_base), Y(0.1, rayon_base)) * millimeter,<br>                            vector(X(0.2, rayon_base), Y(0.2, rayon_base)) * millimeter,<br>                            vector(X(0.3, rayon_base), Y(.3, rayon_base)) * millimeter,<br>                            vector(X(0.4, rayon_base), Y(0.4, rayon_base)) * millimeter,<br>                            vector(X(0.5, rayon_base), Y(0.5, rayon_base)) * millimeter,<br>                            vector(X(0.6, rayon_base), Y(0.6, rayon_base)) * millimeter,<br>                            vector(X(0.7, rayon_base), Y(0.7, rayon_base)) * millimeter,<br>                            vector(X(0.8, rayon_base), Y(0.8, rayon_base)) * millimeter,<br>                            vector(X(0.9, rayon_base), Y(0.9, rayon_base)) * millimeter<br>                        ]<br>                });<br>skLineSegment(sketch1, "line1", {<br>                "start" : vector(0,0) * millimeter,<br>                "end" : vector(rayon/millimeter*cos(alpha*degree), rayon/millimeter*sin(alpha*degree)) * millimeter<br>        });

Thank for any help.




Tagged:

Answers

  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    You're really close to getting it. What you have written will throw an error because "spline" and "line" are just strings and are not suitable for use in a function. What you should do is assign the skFitSpline and skLineSegment functions to variables. Then you can use those variables in the mirror function.
    Also, the mirror function needs to go after the other code.
    Like this:
    <pre class="CodeBlock"><pre><code>var spline = skFitSpline(sketch1, "spline1", {<br>                    "points" : [<br>                            vector(X(0, rayon_base), Y(0, rayon_base)) * millimeter,<br>                            vector(X(0.1, rayon_base), Y(0.1, rayon_base)) * millimeter,<br>                            vector(X(0.2, rayon_base), Y(0.2, rayon_base)) * millimeter,<br>                            vector(X(0.3, rayon_base), Y(.3, rayon_base)) * millimeter,<br>                            vector(X(0.4, rayon_base), Y(0.4, rayon_base)) * millimeter,<br>                            vector(X(0.5, rayon_base), Y(0.5, rayon_base)) * millimeter,<br>                            vector(X(0.6, rayon_base), Y(0.6, rayon_base)) * millimeter,<br>                            vector(X(0.7, rayon_base), Y(0.7, rayon_base)) * millimeter,<br>                            vector(X(0.8, rayon_base), Y(0.8, rayon_base)) * millimeter,<br>                            vector(X(0.9, rayon_base), Y(0.9, rayon_base)) * millimeter<br>                        ]<br>                });<br>var line = skLineSegment(sketch1, "line1", {<br>                "start" : vector(0,0) * millimeter,<br>                "end" : vector(rayon/millimeter*cos(alpha*degree), rayon/millimeter*sin(alpha*degree)) * millimeter<br>        <span>});</span>
    mirror(context, id + "mirror1", {<br>        "patternType" : MirrorType.FEATURE,<br>        "entities" : spline,<br>        "mirrorPlane" : line<br>        });
    Hopefully this helps.
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • quentin_moutyquentin_mouty Member, Developers Posts: 13
    edited March 2017
    Hello,
    Thank for your answer but I still have an error with mirror :


    Precondition failed (definition.instanceFunction is FeatureList)

    50:13   
    onshape/std/mirror.fs (const mirror)

    52:17   
    onshape/std/feature.fs (defineFeature)


    121:9   
    Feature Studio 1 (const Gear)

    52:17   
    onshape/std/feature.fs (defineFeature)


    41:21   
    Part Studio 1 (const buildPrivate)


    44:13   
    Part Studio 1 (const buildPrivate)

    28:17   
    onshape/std/partStudio.fs (definePartStudio)


    17:12   
    Part Studio 1 (build)


    7:12   
    Part Studio 1 (main)

    throw Execution error

    73:21   
    onshape/std/feature.fs (defineFeature)


    121:9   
    Feature Studio 1 (const Gear)

    52:17   
    onshape/std/feature.fs (defineFeature)


    41:21   
    Part Studio 1 (const buildPrivate)


    44:13   
    Part Studio 1 (const buildPrivate)

    28:17   
    onshape/std/partStudio.fs (definePartStudio)


    17:12   
    Part Studio 1 (build)


    7:12   
    Part Studio 1 (main)
     I was wondering if it is not due to the fact that the line 1 and spline 1 cross each other ?
Sign In or Register to comment.