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.
Is it possible to intersect path and plane without using opPlane and deleteBodies
brad_phelan
Member Posts: 89 ✭✭
The below seems inefficient.
function CurveIntersectPlane(context is Context, id is Id, curve is Path, plane is Plane){
var ppPlane = opPlane(context, id, {
"plane" : plane,
});
var r = evDistance(context, {
"side0" : ppPlane,
"side1" : qUnion(curve.edges)
}).sides[0].point;
deleteBodies(context, id + "delete", ppPlane);
return r;
return r;
}
Is this the correct way?
Is this the correct way?
Tagged:
0
Comments
On your end, I think what you have is the most performant solution. evDistance is the right tool for the job, it just lacks the most natural interface in this case.
function pathPlaneIntersection(path is Path, plane is Plane) returns Vector
{
var distance = 1*meter;
L = evPathLength(context, path);
var parameter = 0;
var point;
while (distance > Tolerance.ZeroLength*millimeter)
{
point = evPathTangentLines(context, path, [parameter]).tangentLines[0].origin;
distance = abs(dot(point-plane.origin, plane.normal));
parameter+=distance/L;
}
return point;
}
@kevin_o_toole_1 As a long term solution adding more numerical operations that don't require fiddling the feature tree will be great
Barring, that, I did a little profiling on your code and replacing pathPlaneIntersection body with the following (passing through the feature id) speeds it up by around 10x:
do startFeature()/abortFeature() give speed advantages compared to coping/creating geometry and deleting it?
(and what if to change "Tolerance.ZeroLength*millimeter" to "Tolerance.ZeroLength*meter" )
I haven't timed the difference -- in this case, I'm using it because it allows me to reuse the subfeature id, rather than having to invent a new one each time. Doing a bulk opPattern on the planes following a bulk opDelete might actually be faster here. In any case, since he's got a planar path, using a line will be the fastest way.