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.
missing top_semi at 'function' Error in initializer function arguments

my script has been checked several times,
where am i wrong ?
FeatureScript 2780 ;
import(path:"onshape/std/common.fs", version:"2780.0");
annotation { "Feature Type Name" : "Locker Cabinet", "Feature Type Description" : "Generates the flat 1mm sheet metal parts for the 1380x520x580mm locker." }
export const lockerCabinet = defineFeature(function(context is Context, id is Id, definition is map)
precondition
{
// 1. Define Global Parameters (Dimensions in millimeters)
define(definition, "CabinetHeight", LENGTH, { "default" : 1380 * mm, "description" : "Overall Height (H)" });
define(definition, "CabinetWidth", LENGTH, { "default" : 520 * mm, "description" : "Overall Width (W)" });
define(definition, "CabinetDepth", LENGTH, { "default" : 580 * mm, "description" : "Overall Depth (D)" });
define(definition, "Thickness", LENGTH, { "default" : 1 * mm, "description" : "Sheet Thickness (t)" });
// Internal & Component Dimensions define(definition, "TopSpaceH", LENGTH, { "default" : 200 * mm, "description" : "Top Shelf Clearance" }); define(definition, "ShelfSpaceH", LENGTH, { "default" : 240 * mm, "description" : "Middle Shelf Section Height" }); define(definition, "InternalDivisions", INTEGER, { "default" : 3, "description" : "Number of 240mm shelf sections" }); define(definition, "SupportH", LENGTH, { "default" : 30 * mm, "description" : "Rail/Brace Height" }); define(definition, "FrontStileW", LENGTH, { "default" : 10 * mm, "description" : "Front Vertical Frame Width" }); define(definition, "DoorClearance", LENGTH, { "default" : 2 * mm, "description" : "Total Gap for Doors" }); define(definition, "OmegaQty", INTEGER, { "default" : 10, "description" : "Quantity of Omega Profiles" }); define(definition, "OmegaDevelopedW", LENGTH, { "default" : 70 * mm, "description" : "Est. Flat Width of Omega Profile" }); } { // Retrieve defined parameter values (using definition.ParamName) var Thickness is definition.Thickness; var CabinetHeight is definition.CabinetHeight; var CabinetWidth is definition.CabinetWidth; var CabinetDepth is definition.CabinetDepth; var SupportH is definition.SupportH; var InternalDivisions is definition.InternalDivisions; var Internal_W = CabinetWidth / 2; // Helper variable: Center of sheet thickness (for Z-positioning) var HalfThickness = Thickness / 2; // --- DEBUG 1: Verify Parameter Retrieval --- println("START: H=" ~ CabinetHeight ~ ", W=" ~ CabinetWidth ~ ", D=" ~ CabinetDepth); // ----------------------------------------------------- // 1. BACK PANEL (Sketch on XY plane, Extrude in Z) // ----------------------------------------------------- var backSketch = newSketch(context, id + "backSketch", { "sketchPlane" : plane( makeTransform(vector(0*mm, 0*mm, 0*mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(CabinetWidth, CabinetHeight, 0 * mm))); }; opExtrude(context, id + "backPanel", { "entities" : qSketchRegion(backSketch), "depth" : Thickness, "direction" : vector(0, 0, 1), "newBody" : true, "startBound" : makeBound(-HalfThickness), "endBound" : makeBound(HalfThickness) // Centered on Z=0 plane }); // ----------------------------------------------------- // 2. EXTERNAL SIDE PANELS (H x D) // ----------------------------------------------------- var SidePanelSketch = newSketch(context, id + "SidePanelSketch", { "sketchPlane" : plane( makeTransform(vector(0 * mm, 0 * mm, 0 * mm), axisAngle(vector(1, 0, 0), 90 * degree)) ) }) // Sketch on XZ plane { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(CabinetDepth, CabinetHeight, 0 * mm))); }; // Ext. Side Panel Left (Extrude in Y, positioned at X=0) opExtrude(context, id + "SidePanel_L", { "entities" : qSketchRegion(SidePanelSketch), "depth" : Thickness, "direction" : vector(0, 1, 0), // Extrude along Y-axis "newBody" : true, "startBound" : makeBound(-HalfThickness), "endBound" : makeBound(HalfThickness) }); // Ext. Side Panel Right (Extrude in Y, positioned at X=Width) opExtrude(context, id + "SidePanel_R", { "entities" : qSketchRegion(SidePanelSketch), "depth" : Thickness, "direction" : vector(0, 1, 0), "newBody" : true, "startBound" : makeBound(-HalfThickness), "endBound" : makeBound(HalfThickness), "transform" : makeTransform(vector(CabinetWidth, 0 * mm, 0 * mm), IDENTITY_QUATERNION) // Move to X=520mm }); // ----------------------------------------------------- // 3. FRONT STILE (H x FrontStileW) - Now sketched on YZ plane and translated // ----------------------------------------------------- var StileSketch = newSketch(context, id + "StileSketch", { "sketchPlane" : plane( makeTransform(vector(0 * mm, 0 * mm, 0 * mm), axisAngle(vector(0, 1, 0), 90 * degree)) ) }) // Sketch on YZ plane { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(CabinetHeight, definition.FrontStileW, 0 * mm))); }; var Stile_X_Right = CabinetWidth - definition.FrontStileW; var Stile_Z = CabinetDepth + HalfThickness; // Front Stile Left (Extrude in X, positioned at Z=580) opExtrude(context, id + "Stile_L", { "entities" : qSketchRegion(StileSketch), "depth" : Thickness, "direction" : vector(1, 0, 0), "newBody" : true, "startBound" : makeBound(Stile_Z), "endBound" : makeBound(Stile_Z + Thickness) }); // Front Stile Right (Extrude in X, positioned at X=510, Z=580) opExtrude(context, id + "Stile_R", { "entities" : qSketchRegion(StileSketch), "depth" : Thickness, "direction" : vector(1, 0, 0), "newBody" : true, "startBound" : makeBound(Stile_Z), "endBound" : makeBound(Stile_Z + Thickness), "transform" : makeTransform(vector(Stile_X_Right, 0 * mm, 0 * mm), IDENTITY_QUATERNION) }); // ----------------------------------------------------- // 4. HORIZONTAL SHELVES AND RAILS (W x D) - Sketch on XY, Extrude in Z // ----------------------------------------------------- // Rail Sketch is W x D (Used for Top Rail, Base Rail, Top Shelf, Mirror Support) var RailSketch = newSketch(context, id + "RailSketch", { "sketchPlane" : plane( makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(CabinetWidth, CabinetDepth, 0 * mm))); }; var ExtrudeMap = { "entities" : qSketchRegion(RailSketch), "depth" : Thickness, "direction" : vector(0, 0, 1), "newBody" : true, "startBound" : makeBound(-HalfThickness), "endBound" : makeBound(HalfThickness) }; // Top Rail var TopRail_Y = CabinetHeight - SupportH; opExtrude(context, id + "TopRail", ExtrudeMap + { "transform" : makeTransform(vector(0 * mm, TopRail_Y, 0 * mm), IDENTITY_QUATERNION) }); // Base Rail opExtrude(context, id + "BaseRail", ExtrudeMap + { "transform" : makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION) }); // Top Shelf var TopShelf_Y = CabinetHeight - definition.TopSpaceH - Thickness; // Position below TopSpaceH opExtrude(context, id + "TopShelf", ExtrudeMap + { "transform" : makeTransform(vector(0 * mm, TopShelf_Y, 0 * mm), IDENTITY_QUATERNION) }); // Mirror Support var MirrorSupport_Y = TopShelf_Y - definition.SupportH - Thickness; // Position below Top Shelf opExtrude(context, id + "MirrorSupport", ExtrudeMap + { "transform" : makeTransform(vector(0 * mm, MirrorSupport_Y, 0 * mm), IDENTITY_QUATERNION) }); // ----------------------------------------------------- // 5. LOOPED MIDDLE SHELVES AND BRACES (W/2 x D) // ----------------------------------------------------- var MidShelfSketch = newSketch(context, id + "MidShelfSketch", { "sketchPlane" : plane(makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(Internal_W, CabinetDepth, 0 * mm))); }; var BraceSketch = newSketch(context, id + "BraceSketch", { "sketchPlane" : plane(makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(Internal_W, SupportH, 0 * mm))); }; var current_Y = MirrorSupport_Y; for (var i = 1; i <= InternalDivisions; i++) { // 1. Shelf Position Calculation current_Y = current_Y - definition.ShelfSpaceH - Thickness; println("Loop " ~ i ~ ": MidShelf Y start: " ~ current_Y); opExtrude(context, id + "MidShelf_" + i, ExtrudeMap + { "entities" : qSketchRegion(MidShelfSketch), "transform" : makeTransform(vector(0 * mm, current_Y, 0 * mm), IDENTITY_QUATERNION) }); // 2. Brace Position Calculation (Below the shelf) current_Y = current_Y - definition.SupportH - Thickness; println("Loop " ~ i ~ ": Brace Y start: " ~ current_Y); opExtrude(context, id + "VBrace_" + i, ExtrudeMap + { "entities" : qSketchRegion(BraceSketch), "transform" : makeTransform(vector(0 * mm, current_Y, 0 * mm), IDENTITY_QUATERNION) }); } // ----------------------------------------------------- // 6. DOORS // ----------------------------------------------------- var Door_W = (CabinetWidth / 2) - definition.DoorClearance; var Door_Z = CabinetDepth + HalfThickness; var DoorSketch = newSketch(context, id + "DoorSketch", { "sketchPlane" : plane(makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(Door_W, CabinetHeight, 0 * mm))); }; // Door Panel Left opExtrude(context, id + "Door_L", { "entities" : qSketchRegion(DoorSketch), "depth" : Thickness, "direction" : vector(0, 0, 1), "newBody" : true, "startBound" : makeBound(Door_Z), "endBound" : makeBound(Door_Z + Thickness), "transform" : makeTransform(vector(definition.DoorClearance / 2, 0 * mm, 0 * mm), IDENTITY_QUATERNION) }); // Door Panel Right opExtrude(context, id + "Door_R", { "entities" : qSketchRegion(DoorSketch), "depth" : Thickness, "direction" : vector(0, 0, 1), "newBody" : true, "startBound" : makeBound(Door_Z), "endBound" : makeBound(Door_Z + Thickness), "transform" : makeTransform(vector(CabinetWidth / 2 + definition.DoorClearance / 2, 0 * mm, 0 * mm), IDENTITY_QUATERNION) }); // ----------------------------------------------------- // 7. OMEGA PROFILES (Flat Sheets for Cut List) // ----------------------------------------------------- var OmegaSketch = newSketch(context, id + "OmegaSketch", { "sketchPlane" : plane(makeTransform(vector(0 * mm, 0 * mm, 0 * mm), IDENTITY_QUATERNION)) }) { skRectangle(map_create("corner1" : vector(0 * mm, 0 * mm, 0 * mm), "corner2" : vector(definition.OmegaDevelopedW, CabinetHeight, 0 * mm))); }; for (var i = 1; i <= definition.OmegaQty; i++) { opExtrude(context, id + "Omega_" + i, { "entities" : qSketchRegion(OmegaSketch), "depth" : Thickness, "newBody" : true, "direction" : vector(0, 0, 1), "startBound" : makeBound(0), "endBound" : makeBound(Thickness), "transform" : makeTransform(vector(i * 10 * mm, 0 * mm, CabinetDepth/2), IDENTITY_QUATERNION) }); } }
);
Answers
Your AI tool knows nothing about FeatureScript - I suggest you start here: https://learn.onshape.com/learn/course/featurescript-fundamentals