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.
Variable Extrude
jack_white396
Member Posts: 7 EDU
I am trying the vary which direction I do an extrude based on where there is material. Essentially, this feature will take a point and make a specific hole pattern and extrude them, but if the point is on the opposite side of an object the feature does not work since there is nothing to be subtracted. I need to somehow be able to vary which direction I extrude based on where the point I select is in relation to the object I want extruded through. Here is my code- https://cad.onshape.com/documents/dd9b41942bbf9f447e9d9d6d/w/2b64a0a98ab7927062949adf/e/d176417788ab53093aeccb69
0
Answers
Try something like this:
A vector is an array, if you ever need the other values of the vector:
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴
Try using an implicit mate connector. If you need to measure the distance instead of a manual entry, you can use the above technique that I mentioned and measure from the startPlane.
Code:
FeatureScript 1746; import(path : "onshape/std/geometry.fs", version : "1746.0"); annotation { "Feature Type Name" : "Bearing mount" } export const bearingMount = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Start location", "Filter" : BodyType.MATE_CONNECTOR || BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 } definition.mate is Query; annotation { "Name" : "Distance" } isLength(definition.distance, LENGTH_BOUNDS); } { const startCsys = evMateConnector(context, { "mateConnector" : definition.mate }); const startPlane = plane(startCsys); const point = startPlane.origin; const cent = worldToPlane(startPlane, point); const addition1 = vector(0, .690625) * inch; const addition2 = vector(((0.690625/2)*sqrt(3)), (-1*(0.690625/2))) * inch; const addition3 = vector((-1*((0.690625/2)*sqrt(3))), (-1*(0.690625/2))) * inch; const cent2 = (cent+addition1); const cent3 = (cent+addition2); const cent4 = (cent+addition3); const sketch1 = newSketchOnPlane(context, id + "sketch1", { "sketchPlane" : startPlane }); skCircle(sketch1, "circle1", { "center" : cent, "radius" : (1.125/2) * inch }); skCircle(sketch1, "circle2", { "center" : cent2, "radius" : (5/64) * inch }); skCircle(sketch1, "circle3", { "center" : cent3, "radius" : (5/64) * inch }); skCircle(sketch1, "circle4", { "center" : cent4, "radius" : (5/64) * inch }); skSolve(sketch1); extrude(context, id + "extrude1", { "entities" : qSketchRegion(id + "sketch1"), "endBound" : BoundingType.BLIND, "depth" : definition.distance, "oppositeDirection" : true, "operationType" : NewBodyOperationType.REMOVE, "booleanScope" : qAllNonMeshSolidBodies(), }); // opExtrude(context, id + "extrude1", { // "entities" : qSketchRegion(id + "sketch1"), // "direction" : -planey.normal, // "endBound" : BoundingType.THROUGH_ALL, // }); });Learn more about the Gospel of Christ ( Here )
CADSharp - We make custom features and integrated Onshape apps! Learn How to FeatureScript Here 🔴