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.
whats the error
haryaksh_patil868
Member Posts: 4 ✭
here's the code FeatureScript 2737;
import(path : "onshape/std/geometry.fs", version : "2737.0");
import(path : "onshape/std/feature.fs", version : "2737.0");
annotation { "Feature Type Name" : "My Feature" }
export const myFeature = defineFeature function(context is Context, id is Id, definition is map)
precondition
{
// Shell
annotation { "Name" : "Shell Diameter" }
isLength(definition.shellDiameter, LENGTH_BOUNDS);
annotation { "Name" : "Shell Height" }
isLength(definition.shellHeight, LENGTH_BOUNDS);
// PCB
annotation { "Name" : "PCB Width" }
isLength(definition.PCBWidth, LENGTH_BOUNDS);
annotation { "Name" : "PCB Length" }
isLength(definition.PCBLength, LENGTH_BOUNDS);
annotation { "Name" : "PCB Thickness" }
isLength(definition.PCBThickness, LENGTH_BOUNDS);
// Battery
annotation { "Name" : "Battery Diameter" }
isLength(definition.BatteryDiameter, LENGTH_BOUNDS);
annotation { "Name" : "Battery Height" }
isLength(definition.BatteryHeight, LENGTH_BOUNDS);
{
// User can select one or more planes or planar faces
annotation { "Name" : "Select plane or planar face", "Filter" :EntityType.FACE, "MaxNumberOfPicks" : 10};
definition.selection is Query;
}
{
// Print the user’s choice(s) to console for debugging
println("User selected: " ~ definition.selection);
// Example: check if user picked nothing
if (isQueryEmpty(context, definition.selection)) {
println("⚠️ No selection made!");
}
else {
// Example: loop through selections
var items = evaluateQuery(context, definition.selection);
for (var item in items) {
println("Selected entity: " ~ item);
}
}
}
{
// --- Defaults (if user leaves values blank) ---
if (!definition.shellDiameter) definition.shellDiameter = 80 * millimeter;
if (!definition.shellHeight) definition.shellHeight = 30 * millimeter;
if (!definition.pcbWidth) definition.pcbWidth = 60 * millimeter;
if (!definition.pcbLength) definition.pcbLength = 30 * millimeter;
if (!definition.pcbThickness) definition.pcbThickness = 2 * millimeter;
if (!definition.batteryDiameter) definition.batteryDiameter = 18 * millimeter;
if (!definition.batteryHeight) definition.batteryHeight = 65 * millimeter;
// === Shell (cylinder) ===
const shellSketchId = id + "shellSketch";
const shellSketch = newSketch(context, shellSketchId, {
"plane" : plane(context, vector(0, 0, 0), vector(0, 0, 1))
});
skCircle(shellSketch, "c1", {
"center" : vector(0, 0) ,
"radius" : definition.shellDiameter / 2
});
skSolve(shellSketch);
opExtrude(context, id + "shellExtrude", {
"direction" : vector(0, 0, 1),
"endBound" : BoundingType.BLIND,
"endDepth" : definition.shellHeight
});
// === PCB (rectangle) ===
const pcbPlaneOrigin = vector(0, 0, definition.shellHeight + 1 * millimeter);
const pcbSketchId = id + "pcbSketch";
const pcbSketch = newSketch(context, pcbSketchId, {
"plane" : plane(context, pcbPlaneOrigin, vector(0, 0, 1))
});
skRectangle(pcbSketch, "r1", {
"center" : vector(0, 0) ,
"width" : definition.pcbWidth,
"height" : definition.pcbLength
});
skSolve(pcbSketch);
opExtrude(context, id + "pcbExtrude", {
"direction" : vector(0, 0, 1),
"endBound" : BoundingType.BLIND,
"endDepth" : definition.pcbThickness
});
// === Battery (cylinder) ===
const batteryInsetX = definition.pcbWidth / 2 - definition.batteryDiameter / 2 - 2 * millimeter;
const batteryInsetY = definition.pcbLength / 2 - definition.batteryDiameter / 2 - 2 * millimeter;
const batteryPlaneOrigin = vector(-batteryInsetX, -batteryInsetY, definition.shellHeight + 1 * millimeter);
const batterySketchId = id + "batterySketch";
const batterySketch = newSketch(context, batterySketchId, {
"plane" : plane(context, batteryPlaneOrigin, vector(0, 0, 1))
});
skCircle(batterySketch, "c2", {
"center" : vector(0, 0) ,
"radius" : definition.batteryDiameter / 2
});
skSolve(batterySketch);
opExtrude(context, id + "batteryExtrude", {
"direction" : vector(0, 0, 1),
"endBound" : BoundingType.BLIND,
"endDepth" : definition.batteryHeight
})
};
also the error is
mismatched input '<EOF>' expecting '{' |
| ||
|---|---|---|---|
125:1 | Feature Studio 1 |
Answers
Count your parentheses
I DID IT STILL