Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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.

Determine if Sketch entities are within an area (Face)

timo_schmidtimo_schmid Member Posts: 36 EDU
Hi everyone,
I'm writing a FeatureScript that automatically creates many sketch lines on a given surface (similar to a raster). Depending on the shape of the surface, sometimes a line is outside of the surface area.
Is it possible to remove all sketch entities that are not within the given Face? Especially, also lines that are between 2 points on the Face edges, but are outside of it, should be deleted (see picture - yellow marked lines).
Thanks for suggestions,
Timo

Comments

  • Evan_ReeseEvan_Reese Member Posts: 538 PRO
    I can only think of a bad way. If you're desperate, you could evaluate whether a point on an entity is more than 0meters away from the face and cull the line if so. For example, in a for loop, find the midpoint of each line, check the min distance to the face, and if it's 0, append it to an array.

    Now, will someone who knows this stuff please come save @timo_schmid from my answer?
    Evan Reese / Principal and Industrial Designer with Fractal
    Website: fractalmade.com
    Instagram: @evan.reese.designs
  • mahirmahir Member, Developers Posts: 1,031 ✭✭✭✭✭
    Not sure this would work, but maybe you could use qAdjacent with AdjacencyType set to Line. Assuming this query considers sketch lines on a surface as adjacent to that surface, this would identify any lines that intersect the surface by more than a point.


  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 3,356
    You might want to employ the same process I have here:
    https://forum.onshape.com/discussion/14546/new-custom-feature-wire-mesh
  • mahirmahir Member, Developers Posts: 1,031 ✭✭✭✭✭
    @NeilCooke, it looks like the good bit is:
    opSplitFace(context, splitFaceId, {
    			"faceTargets" : qCreatedBy(meshSurfaceId, EntityType.FACE),
    			"edgeTools" : qCreatedBy(id + "meshSketch", EntityType.EDGE),
    			"direction" : meshPlane.normal
    		});
    
    opExtractWires(context, id + "extractWires", {
    			"edges" : qCreatedBy(splitFaceId, EntityType.EDGE)
    The gist of which is you split the face with the mesh sketch using opSplitFace. Then, you create wire bodies from the edges created by the split, which notably would not include any open space within the face in question.
Sign In or Register to comment.