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.
Unable to create a basic working script
baskar_raj
Member Posts: 2 ✭
I've used a variety of AI tools and they all seem to think this is ok. Onshape has issues - please help correct this script:
FeatureScript 2641;
import(path : "onshape/std/common.fs", version : "2641.0");
annotation { "Feature Type Name" : "Simple Block" }
export const createSimpleBlock = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
annotation { "Name" : "Width", "Filter" : QuantityBound("0 * meter", GT), "UIHint" : UIHint.LENGTH }
is width is Length;
annotation { "Name" : "Height", "Filter" : QuantityBound("0 * meter", GT), "UIHint" : UIHint.LENGTH }
is height is Length;
annotation { "Name" : "Depth", "Filter" : QuantityBound("0 * meter", GT), "UIHint" : UIHint.LENGTH }
is depth is Length;
}
{
// Create a sketch on the XY plane
var sketch = skCreate(context, id + "sketch", {
"sketchPlane" : qPlane(StandardPlane.TOP)
});
// Add a rectangle to the sketch
skRectangle(sketch, id + "rectangle", {
"corner1" : vector(0, 0),
"corner2" : vector(definition.width, definition.height)
});
skSolve(sketch);
// Extrude the sketch to create the solid block
opExtrude(context, id + "extrude", {
"entities" : qSketchRegion(id + "sketch"),
"direction" : vector(0, 0, 1),
"endBound" : BoundingType.BLIND,
"depth" : definition.depth,
"operationType" : NewBodyOperationType.NEW
});
}
);
—
These are the errors I see:
| |||
|---|---|---|---|
5:47 | Feature Studio 1 | ||
missing TOP_SEMI at 'function' | |||
|---|---|---|---|
extraneous input 'is' expecting {'[', '+', '-', 'return', 'if', 'for', 'while', 'new', '!', '++', '--', '::', 'function', 'operator', 'undefined', 'break', 'continue', 'var', 'const', 'try', 'in', 'switch', 'throw', SEMI, '{', '(', BOOLEAN, NUMBER, ID, BUILTIN, STRING} | |||
|---|---|---|---|
9:9 | Feature Studio 1 | ||
extraneous input 'is' expecting {'[', '+', '-', 'return', 'if', 'for', 'while', 'new', '!', '++', '--', '::', 'function', 'operator', 'undefined', 'break', 'continue', 'var', 'const', 'try', 'in', 'switch', 'throw', SEMI, '{', '(', BOOLEAN, NUMBER, ID, BUILTIN, STRING} | |||
|---|---|---|---|
12:9 | Feature Studio 1 | ||
extraneous input 'is' expecting {'[', '+', '-', 'return', 'if', 'for', 'while', 'new', '!', '++', '--', '::', 'function', 'operator', 'undefined', 'break', 'continue', 'var', 'const', 'try', 'in', 'switch', 'throw', SEMI, '{', '(', BOOLEAN, NUMBER, ID, BUILTIN, STRING} | |||
|---|---|---|---|
15:9 | Feature Studio 1 | ||
extraneous input ')' expecting {<EOF>, 'annotation', 'export', 'enum', 'type', 'function', 'predicate', 'operator', 'typeconvert', 'const', TOP_SEMI} | |||
|---|---|---|---|
40:1 | Feature Studio 1 | ||
Comments
Close but no cigar. LLMs are not good at this. I suggest you check out the FS course on the Learning Center.