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.
Sketch line intersecting an edge

Hi,
I need to draw a sketch line on the face of a part from a given point to the intersection with an edge.
What would be the best way to detect that intersection please?
Thank you.
0
Best Answer
-
NeilCooke Moderator, Onshape Employees Posts: 5,833
Easiest thing to do is to create a sketch manually as you would want it to behave, then "Show code" from the Part Studio tab at the bottom. That will show you the correct syntax for the sketch constraints.
Senior Director, Technical Services, EMEA0
Answers
select the end point and the edge and use a coincident mate. i use this a lot:
https://cad.onshape.com/documents/ff345351f1a51fa6ec937559/w/13955793aec30906f8daa850/e/a76debb0d4f0e45a9a21fb8a?renderMode=0&uiState=67e90dd44aa6473d2ff75335
Check Sketch 4 & 5
Tip: A link to the file with the issue is hand.
Thank you for your reply but I’m looking to do this in Featurescript.
I’ve currently worked around this by splitting the parts with planes and then sketching along the splits after finding the edges and vertices created by the splits.
I’d still be interested to know if there is a more direct way of achieving this?
Thank you.
Sounds like you need to use a pierce constraint in your sketch.
https://cad.onshape.com/help/Content/sketch-tools-pierce.htm
https://www.onshape.com/en/resource-center/tech-tips/pierce-relation
Thank you I’ll look at that. I didn’t realise that could be down in FS.
Easiest thing to do is to create a sketch manually as you would want it to behave, then "Show code" from the Part Studio tab at the bottom. That will show you the correct syntax for the sketch constraints.
Good idea thank you.
So I'm struggling with this.
I've made a test document at:
https://cad.onshape.com/documents/713f92603f5e0e6ae5df75bf/w/5425b4fa6aa26e769422562b/e/d349288f4e933f5c9cbb74bd
Essentially I want to draw a line at angle from one edge to the intersection point of a second edge.
The test document doesn't work but shows how the Part Studio code is formed.
Trial and error in decoding the Part Studio code hasn't worked for me so far.
I can't find any documentation or source code for the constraint types?
Any help appreciated.
The test document at:
https://cad.onshape.com/documents/713f92603f5e0e6ae5df75bf/w/5425b4fa6aa26e769422562b/e/d349288f4e933f5c9cbb74bd
now partially works with sketch constraints - decoded from Part Studio code as recommended by @NeilCooke
The idea is that multiple target edges can be selected in the UI and the code will step through those edges until a coincident constraint with the line at requested angle can be made. So to the user they can specify any suitable angle and the appropriate edge will be selected for the line to intersect.
The current issue is that there doesn't appear to be a way to determine whether the constraints succeeded or not.
In the test document I have a test that seems to work for the curved edge but I can't see a way to test the straight edges. The curved edge constraint may well not be robust for other geometries.
Is there a way to test constraint success?
Is there a better way to go about this, it feels as though I'm swimming against the tide here?