Mirror for spline
quentin_mouty
Member, Developers Posts: 13 ✭
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 :
Thank for any help.
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.
0
Answers
-
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!0 -
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)
I was wondering if it is not due to the fact that the line 1 and spline 1 cross each other ?throw Execution error73: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)
0
