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.
startTracking with sweep
MBartlett21
Member, OS Professional, Developers Posts: 2,050 ✭✭✭✭✭
I am trying to do a tracking query on a sweep to get a face to put into opReplaceFace.
However, it resolves to nothing.
Here is my code:
However, it resolves to nothing.
Here is my code:
// Sketch var sketch = newSketchOnPlane(context, id + "sketch", { "sketchPlane" : skPlane }); skLineSegment(sketch, "face1Line", { "start" : vector(0, 0) * inch, "end" : face1Point }); skLineSegment(sketch, "face2Line", { "start" : vector(0, 0) * inch, "end" : face2Point }); skArc(sketch, "arc", { "start" : face1Point, "mid" : normalize(face1SkDir + face2SkDir) * dist * (shape == FilletShape.CONVEX ? 1.15 : 0.75), "end" : face2Point }); skSolve(sketch); toDelete[] = append(toDelete[], qCreatedBy(id + "sketch")); // Weld Faces var weldFace1 = qEntityFilter(startTracking(context, id + "sketch", "face1Line"), EntityType.FACE); var weldFace2 = qEntityFilter(startTracking(context, id + "sketch", "face2Line"), EntityType.FACE); // Sketch face var sketchFace = qCreatedBy(id + "sketch", EntityType.FACE); var sweepDef = { "profiles" : sketchFace, "path" : qClosestTo(qEdgeAdjacent(face1, EntityType.EDGE), distResult.sides[0].point), "lockFaces" : face1 }; opSweep(context, id + "sweep", sweepDef); debug(context, weldFace1); // Resolves to nothing :(
0
Best Answers
-
lana Onshape Employees Posts: 706tracking swept faces requires secondaryQuery of the corresponding path edge . Please see
<div>function sweptfaceTrackingQuery(context is Context, sketchId is Id, sketchEntityId is string, path is Query) returns Query {</div><div> const sketchQuery = sketchEntityQuery(sketchId, undefined, sketchEntityId); <span style="background-color: transparent; color: inherit; font-size: inherit;"><font face="Flama, sans-serif"> const trackingQ = startTracking(context, {</font> </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;"> 'subquery' : qUnion([sketchQuery, makeQuery(sketchId, "IMPRINT", undefined, {"derivedFrom" : sketchQuery})]), </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;"> 'secondarySubquery' : path </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;"> }); </span><span style="background-color: transparent; color: inherit; font-size: inherit; font-family: Flama, sans-serif;"> return qEntityFilter(trackingQ, EntityType.FACE);</span></div><div>}</div>
5 -
lana Onshape Employees Posts: 706Yes, makeQuery(sketchId, "IMPRINT", undefined, { "derivedFrom" : sketchQuery }) resolves to the edge of sketch face corresponding to the sketch curve of sketchQuery5
-
Jake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,646@mbartlett21
If you have a query for the selection, you can just call `startTracking` directly, with that query as the "subquery" and the path as the "secondarySubquery".Jake Rosenfeld - Modeling Team5
Answers
here
Is this part of the function the edge of the sketch face?
IR for AS/NZS 1100
How would I get the sketch id from a user's selection?
Or can't I do that?
IR for AS/NZS 1100
If you have a query for the selection, you can just call `startTracking` directly, with that query as the "subquery" and the path as the "secondarySubquery".
What I was wanting was to allow sketch edge selection for my shaped flange feature
https://cad.onshape.com/documents/602655eff016f183fc184978
IR for AS/NZS 1100
Are you sweeping the sketch region and trying to track one of the side faces, or sweeping sketch edge itself into a surface? If you're sweeping the sketch edge, you should be able to just do:
startTracking(context, { "subquery" : definition.edgeToSweep, "secondarySubquery" : pathEdge });
If you are sweeping a region into a solid, and trying to track one of the edges by user selection, it'll require some creativity. Sketch edges are actually independent wire bodies which sit on top of the sketch regions. Sketch regions have their own bounding edges, which are not topologically associated with the sketch edges. If your sketch is simple, though, it should not be too hard to find the correct sketch region edge to track, based off of a sketch edge selection.
Here is a document with an example of how to do both of the above things:
https://cad.onshape.com/documents/aeead03c19e203f80f7a8a42/w/7860ea9de8207834674fd2b8/e/7ef5715b5172858bcbc526fb
I am wanting to get the sketch face adjacent to the edge so I can do an opExtractSurface on it.
IR for AS/NZS 1100