Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
evaluateQuery gives runtime error
peter_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;
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
debug(context, location);
sketchPlane = evOwnerSketchPlane(context, { "entity" : location });
center3D = evVertexPoint(context, { "vertex" : location });
});
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;
annotation { "Name" : "Centre Point", "Filter" : EntityType.VERTEX && SketchObject.YES, "MaxNumberOfPicks" : 1 }<br> 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
location = evaluateQuery(context, definition.myCenter)[0];
debug(context, location);
sketchPlane = evOwnerSketchPlane(context, { "entity" : location });
center3D = evVertexPoint(context, { "vertex" : location });
});
0
Best Answer
-
lana Onshape Employees Posts: 706Notice spelling difference between "myCentre" in precondition and "myCenter" in evaluateQuery() call5
Answers
Many thanks Lana, very much appreciated.