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", {
"patternType" : MirrorType.FEATURE,
"entities" : "spline1",
"mirrorPlane" : "line1"
});
Where spline1 and lin1 are :
skFitSpline(sketch1, "spline1", {
"points" : [
vector(X(0, rayon_base), Y(0, rayon_base)) * millimeter,
vector(X(0.1, rayon_base), Y(0.1, rayon_base)) * millimeter,
vector(X(0.2, rayon_base), Y(0.2, rayon_base)) * millimeter,
vector(X(0.3, rayon_base), Y(.3, rayon_base)) * millimeter,
vector(X(0.4, rayon_base), Y(0.4, rayon_base)) * millimeter,
vector(X(0.5, rayon_base), Y(0.5, rayon_base)) * millimeter,
vector(X(0.6, rayon_base), Y(0.6, rayon_base)) * millimeter,
vector(X(0.7, rayon_base), Y(0.7, rayon_base)) * millimeter,
vector(X(0.8, rayon_base), Y(0.8, rayon_base)) * millimeter,
vector(X(0.9, rayon_base), Y(0.9, rayon_base)) * millimeter
]
});
skLineSegment(sketch1, "line1", {
"start" : vector(0,0) * millimeter,
"end" : vector(rayon/millimeter*cos(alpha*degree), rayon/millimeter*sin(alpha*degree)) * millimeter
});

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:
    var spline = skFitSpline(sketch1, "spline1", {
    "points" : [
    vector(X(0, rayon_base), Y(0, rayon_base)) * millimeter,
    vector(X(0.1, rayon_base), Y(0.1, rayon_base)) * millimeter,
    vector(X(0.2, rayon_base), Y(0.2, rayon_base)) * millimeter,
    vector(X(0.3, rayon_base), Y(.3, rayon_base)) * millimeter,
    vector(X(0.4, rayon_base), Y(0.4, rayon_base)) * millimeter,
    vector(X(0.5, rayon_base), Y(0.5, rayon_base)) * millimeter,
    vector(X(0.6, rayon_base), Y(0.6, rayon_base)) * millimeter,
    vector(X(0.7, rayon_base), Y(0.7, rayon_base)) * millimeter,
    vector(X(0.8, rayon_base), Y(0.8, rayon_base)) * millimeter,
    vector(X(0.9, rayon_base), Y(0.9, rayon_base)) * millimeter
    ]
    });
    var line = skLineSegment(sketch1, "line1", {
    "start" : vector(0,0) * millimeter,
    "end" : vector(rayon/millimeter*cos(alpha*degree), rayon/millimeter*sin(alpha*degree)) * millimeter
    });
    mirror(context, id + "mirror1", {
    "patternType" : MirrorType.FEATURE,
    "entities" : spline,
    "mirrorPlane" : line
    });
    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.