Variable WORLD_ORIGIN not found Variable Z_DIRECTION not found

Fda
Fda Member Posts: 42 ✭✭
Why is the code broken?
I do not get it


const lineToRotateAround = line(WORLD_ORIGIN, Z_DIRECTION);  //?????????  
                const angleIncrement = (360 * degree) / MyCount;

                var transforms = [];
                var instanceNames = [];


                //definition.count -> MyCount
                for (var i = 1; i < MyCount; i += 1) // Iterar de 1 -> (definition.count - 1) porque ya hemos creado la instancia base (0)
                {
                    const currAngle = i * angleIncrement;
                    const currTransform = rotationAround(lineToRotateAround, i * angleIncrement);
                    // Añadir currTransform a la lista de transformaciones
                    transforms = append(transforms, currTransform);
                    // los nombres de instancia no importan, solo deben ser cadenas únicas
                    instanceNames = append(instanceNames, toString(i));
                }









Comments

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,120 image
    Where are those variables declared? If they are standard Onshape constants did you include the module they are declared in?
    Senior Director, Technical Services, EMEA
  • Jake_Rosenfeld
    Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646 image
    @fermin_fermin_1

    These are fairly new constants in the system, your feature studio may be on too old of a version to have them.   Can you post a screenshot of the very top of your feature?  I am interested in the line that says "FeatureScript ####;" and all the imports that come after that.

    If you have an import of "onshape/std/geometry.fs" and the FS version is high enough, those constants should exist.
    Jake Rosenfeld - Modeling Team
  • Fda
    Fda Member Posts: 42 ✭✭
    @fermin_fermin_1

    These are fairly new constants in the system, your feature studio may be on too old of a version to have them.   Can you post a screenshot of the very top of your feature?  I am interested in the line that says "FeatureScript ####;" and all the imports that come after that.

    If you have an import of "onshape/std/geometry.fs" and the FS version is high enough, those constants should exist.


    </code>FeatureScript 1096;
    <pre class="CodeBlock"><code>import(path : "onshape/std/geometry.fs", version : "1096.0");



    This fixes the error:

    <div>FeatureScript 1120;</div><div>import(path : "onshape/std/geometry.fs", version : "1120.0");&nbsp;</div>

  • Jake_Rosenfeld
    Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646 image
    For anyone with the same problem, `Z_DIRECTION` is just shorthand for `vector(0, 0, 1)` and `WORLD_ORIGIN` is just shorthand for `vector(0, 0, 0) * meter`
    Jake Rosenfeld - Modeling Team
  • Fda
    Fda Member Posts: 42 ✭✭
    For anyone with the same problem, `Z_DIRECTION` is just shorthand for `vector(0, 0, 1)` and `WORLD_ORIGIN` is just shorthand for `vector(0, 0, 0) * meter`
    So that no one else wastes time, as I did.
    const lineToRotateAround = line(vector(0, 0, 0) * meter, vector(0, 0, 1)); </code>const lineToRotateAround = line(WORLD_ORIGIN, Z_DIRECTION);  <span>//????????? 
    
    </span><pre class="CodeBlock"><code>