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.
Extrusion Direction based on Collision Evaluation
fluvio_lobo_fenoglietto
Member Posts: 36 PRO
Hello,
I am trying to create a routine that changes the direction of the extrusion based on a collision evaluation.
The script performs this task right after sweeping a cylindrical structure.
My goal is to extrude another cylinder (different to the original), in the opposite direction.
My initial though was to use the "evCollision()" to determine if the extrusion generated an INTERFERE clash and then change the direction by multiplying normal * -1, as shown here:
The original script is here
I am trying to create a routine that changes the direction of the extrusion based on a collision evaluation.
The script performs this task right after sweeping a cylindrical structure.
My goal is to extrude another cylinder (different to the original), in the opposite direction.
My initial though was to use the "evCollision()" to determine if the extrusion generated an INTERFERE clash and then change the direction by multiplying normal * -1, as shown here:
var extrude_params = { "entities" : qSketchRegion(id + "sketch1"), "direction" : evOwnerSketchPlane(context, {"entity" : qSketchRegion(id + "sketch1")}).normal * -1, "endBound" : BoundingType.BLIND, "endDepth" : 1 * millimeter, "operationType" : NewBodyOperationType.ADD }; opExtrude(context, id + "extrude1" + unstableIdComponent("1"), extrude_params); // execute extrusion with default parameters
var clashes = evCollision(context, { // execute collision test
"tools" : qCreatedBy(id + "extrude1", EntityType.BODY),
"targets" : qCreatedBy(id + "bitBodySweep", EntityType.BODY)
});
var interfere = ClashType.INTERFERE;
if( clashes[0]['type'] == interfere ) { // if the number of clashes detected is greater than "4"
extrude_params.direction = evOwnerSketchPlane(context, {"entity" : qSketchRegion(id + "sketch1")}).normal;
opExtrude(context, id + "extrude1" + unstableIdComponent("2"), extrude_params);
println( clashes[0]['type'] );
}
My challenges are the following;
- Since I am not using a "try-catch" (because the collision does not raise an error), how can I avoid generating the first extrusion ("extrude 1")?
- Could I create my own "error" for "try-catch"? If so, could someone give some advice?
- I am also having issues with adding the .ADD vs .NEW parameter on the extrusion. Hence, the current script only generates new parts.
I always find myself overthinking the solution, so I am very open to suggestions!!!
- Since I am not using a "try-catch" (because the collision does not raise an error), how can I avoid generating the first extrusion ("extrude 1")?
- Could I create my own "error" for "try-catch"? If so, could someone give some advice?
- I am also having issues with adding the .ADD vs .NEW parameter on the extrusion. Hence, the current script only generates new parts.
I always find myself overthinking the solution, so I am very open to suggestions!!!
The original script is here
Tagged:
0
Comments
For some good examples, see the use of abortFeature() in booleanHeuristics.fs and hole.fs.