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

evaluateQuery gives runtime error

peter_morrispeter_morris Member Posts: 43 ✭✭
Hi,

I'm trying to create my own featurescript to produce a helical gear - primarily as a learning exercise.  Its exercising me!!

I'm developing the code in stages and the current iteration is shown below.  The problem I'm experiencing is that the generation fails and Featurescript reports: 'Call evaluateQuery(Context, undefined) does not match evaluateQuery(..., Query).

I've copied code from the Spur Gear FeatureScript example and apart from changing the name from definition.circle to definition.myCircle I can't see the difference that should cause this problem. I believe the precondition is fundamentally the same as in the Spur Gear example as is the calculation of the location (I've tried to highlight both pieces of code in the code below).

I'd be really grateful for any advice.

Many thanks.

Peter

annotation { "Feature Type Name" : "My Gear" }
export const MyGear = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Face", "Filter" : EntityType.FACE, "MaxNumberOfPicks" : 1 }
        definition.myFace is Query;
       
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; annotation { "Name" : "Centre Point", "Filter" : EntityType.VERTEX && SketchObject.YES, "MaxNumberOfPicks" : 1 }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; definition.myCentre is Query;

       
        annotation { "Name" : "Pitch Diameter" }
        isLength(definition.pitchDiameter, LENGTH_BOUNDS);
       
        annotation { "Name" : "Gear Module or Number of Teeth?" }
        definition.gearModule is boolean;
       
        if (definition.gearModule)
        {
        annotation { "Name" : "Module" }
        isReal(definition.Module, MODULE_SPEC_BOUNDS);           
        }
        else
        {
        annotation { "Name" : "Number of Teeth:" }
        isInteger(definition.numTeeth, TEETH_COUNT_BOUNDS);         
        }
       
        annotation { "Name" : "Pressure Angle" }
        isAngle(definition.pressureAngle, ANGLE_BOUNDS);
       
        annotation { "Name" : "Gear Type" }
        definition.gearType is MyGearType;
       
        if (definition.gearType == MyGearType.helical)
        {
            annotation { "Name" : "Helix Angle" }
            isAngle(definition.myHelixAngle, ANGLE_BOUNDS);
        }
        {
            //do nothing
        }
    }
    {
        // Define the function's action
        var location = vector(0, 0, 0) * meter;
        var sketchPlane = plane(location, vector(0, -1, 0), vector(1, 0, 0));
        var center3D = location;

        // find location of selected vertex and its sketch plane and create a new sketch for the gear profile
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; location = evaluateQuery(context, definition.myCenter)[0];

            debug(context, location);
           
            sketchPlane = evOwnerSketchPlane(context, { "entity" : location });
            center3D = evVertexPoint(context, { "vertex" : location });
    });


Best Answer

Answers

  • Options
    peter_morrispeter_morris Member Posts: 43 ✭✭
    am I allowed to say I love you!!! how unbelievably simple - I was looking for syntax, structure, anything - never thought to check the spelling!!

    Many thanks Lana, very much appreciated.
Sign In or Register to comment.