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.
How to copy user sketch to another plane and extrude (Fixed)
sean_connor714
Member Posts: 6 ✭
Hey all,
I have a predefined user sketch on a default plane, and I'd like to essentially copy that user sketch to a feature script generated plane and extrude it from there.
Is something like that possible through feature script?
FeatureScript 2180; import(path : "onshape/std/common.fs", version : "2180.0"); annotation { "Feature Type Name" : "Truss" } export const truss = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Slot Sketch", "Filter" : EntityType.FACE, } definition.slot is Query; annotation { "Name" : "Slot Wall Sketch", "Filter" : EntityType.FACE, } definition.slotWall is Query; annotation { "Name" : "Body Radius" } isLength(definition.bodyRadius, LENGTH_BOUNDS); } { opSphere(context, id + "sphere1", { "center" : vector(0, 0, 0) * millimeter, "radius" : definition.bodyRadius }); var plane = createPlaneOnSphere(context, id + "pointPlane1", vector(0, 0, 0), definition.bodyRadius, vector(1, 0.5) * radian); opExtrude(context, id + "slot", { "entities" : definition.slotWall, // Here I'd like to essentially copy the sketch the calculated plane above and extrude from there instead. "direction" : evOwnerSketchPlane(context, {"entity" : definition.slotWall}).normal, "endBound" : BoundingType.BLIND, "endDepth" : definition.bodyRadius * 2 }); }); export function createPlaneOnSphere(context is Context, id is Id, sphereCenter is Vector, sphereRadius is ValueWithUnits, uv is Vector) { // Convert U & V (spherical coordinates) to Cartesian coordinates println(uv[1]); var x = sphereCenter[0] + sphereRadius.value * sin(uv[1]) * cos(uv[0]); var y = sphereCenter[1] + sphereRadius.value * sin(uv[1]) * sin(uv[0]); var z = sphereCenter[2] + sphereRadius.value * cos(uv[1]); var pointOnSphere = vector(x, y, z); // The normal vector is simply the vector from the center to the point on the sphere var normalVector = normalize(pointOnSphere - sphereCenter); println(pointOnSphere); // Create the plane var plane = opPlane(context, id + "plane1", { "plane" : plane(pointOnSphere, normalVector) }); return plane; }}
Thanks,
0
Comments