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.
How to check if an edge is a straight line?
eric_pesty
Member Posts: 1,881 PRO
This is probably obvious but I'm struggling with figuring out if something is "straight"...
I'm computing the min radius of curvature of a sweep path and got it working (I stole/repurposed the code from @NeilCooke 's cable/wire routing) but i would like to do a check first so I don't sample curvature a bunch of times if the segment is just a straight line...
I thought I could use "canBeLine" but it seems to always return false even when I pick a straight sketch segment as my input...
I'm computing the min radius of curvature of a sweep path and got it working (I stole/repurposed the code from @NeilCooke 's cable/wire routing) but i would like to do a check first so I don't sample curvature a bunch of times if the segment is just a straight line...
I thought I could use "canBeLine" but it seems to always return false even when I pick a straight sketch segment as my input...
Tagged:
0
Comments
I need to study this more but it looks like exactly what I need to do, I'll take a look when I get a chance! I'm assuming the "circle" case will detect a circular arc?
This is what I currently have, the key difference being I need an extra loop as I'm looking for the curvature on a path that can have multiple segments:
EDIT: why is the "code" block so dumb in here?
I also meant to ask, where does the "length / (min bend / 4)" come from on the number of samples? Is that a "scientific" way to determine how many samples are required or just something that "works"? Just curious!
In my case I am just trying to find the minimum bend radius and display in a table (rather than establish a pass/fail so I might need to do this a bit differently...). I replaced your min bend radius with the diameter of my sweep but really what I'm looking for is not dependent on what I'm sweeping!
I should be doing whatever the "curvature comb" is doing to display the min curvature... (and as a side note it would be really nice if we had access to a function that would do that for us as efficiently as possible rather than writing our own!)
I had pasted the code first and selected it and formatted as code and that was a disaster (the whole thing was on one line with extra HTML crap), talk about hard to read:
I ran into some difficulties with implementing the code above as I am doing things a bit differently but then I did a "profile" and sampling the curvature 50times on a straight line is quicker than 5 samples on a spline so the performance impact seems pretty negligible.
Interestingly, adding the debug arrow is quite a bit slower than the curvature sampling loops, and the opSweep are also slower so while it's not super efficient it doesn't really have a noticeable performance impact so I am going to leave it like this for now.