Feature Studio Code is Driving Me Mad//"missing TOP_SEMI at function"
Hey everyone! I'm learning through practice on Onshape right now. I have this code for the Feature Studio to help me make designs faster. My code is down to it's final error code. No amount of reading the websites library, consulting AI, or the Onshape forum has helped. I have no background in programming nor CAD in general. I'm completely working on this from a newbie background.
The last errors I keep getting in my code are "missing TOP_SEMI at 'function'" and "Error in initializer function arguments." Can I get some help with these last few errors. This feels like hitting a brick wall right before the finish line of me learning this system.
Here is my code:
FeatureScript 3044;
import(path : "onshape/std/common.fs", version : "3044.0");
// --- Keyed Miter Joint Feature (Auto-Centering Version) ---
// Creates rectangular key slots centered along a miter joint.
annotation { "Feature Type Name" : "Keyed Miter Joint (Centered)" }
export const KeyedMiterJointCentered = defineFeature(function(context, id, definition) {
// -----------------------------
// Inputs
// -----------------------------
annotation { "Name" : "First miter face" }
definition.face1 is Query;
annotation { "Name" : "Second miter face" }
definition.face2 is Query;
annotation { "Name" : "Key width" }
isLength(definition.keyWidth, LENGTH_BOUNDS);
annotation { "Name" : "Key height" }
isLength(definition.keyHeight, LENGTH_BOUNDS);
annotation { "Name" : "Key depth (into boards)" }
isLength(definition.keyDepth, LENGTH_BOUNDS);
annotation { "Name" : "Number of keys" }
isInteger(definition.keyCount, { "min" : 1 });
annotation { "Name" : "Spacing between keys" }
isLength(definition.keySpacing, LENGTH_BOUNDS);
annotation { "Name" : "Fit tolerance (woodworking)" }
isLength(definition.tolerance, LENGTH_BOUNDS);
annotation { "Name" : "Auto-center keys?" }
definition.autoCenter is boolean;
// -----------------------------
// Extract intersection curve
// -----------------------------
var extractId = id + "intersection";
opExtractIntersectionCurve(context, extractId, {
"entities" : [definition.face1, definition.face2]
});
// Query the resulting intersection edge
var lineEdge = qCreatedBy(extractId, EntityType.EDGE);
// Evaluate the edge to get origin + direction
var edgeEval = evEdgeTangentLine(context, {
"edge" : lineEdge,
"parameter" : 0
});
var origin = edgeEval.origin;
var xAxis = normalize(edgeEval.direction);
// -----------------------------
// Compute bisector normal
// -----------------------------
var plane1 = evPlane(context, { "face" : definition.face1 });
var plane2 = evPlane(context, { "face" : definition.face2 });
var zAxis = normalize(plane1.normal + plane2.normal);