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.
Getting (x,y,z) components of 3D line?
tony_459
Member Posts: 206 ✭✭✭
I need to get the (x,y,z) components for many 3D lines so that I can do some vector math with them.
If this were just one line, I’d do project it onto the x plane, the y plane, and the z plane, and then dimension the projections individually.
But I have many many lines to measure and I’m wondering if there’s a quicker way to do this—like... selecting the 3D line and automatically getting an (x,y,z) measurement?
I haven’t coded in FeatureScript so I'm afraid the learning curve there would more than offset the efficiency gain over just projecting the curves individually and then measuring the projections one by one by one by one...
If this were just one line, I’d do project it onto the x plane, the y plane, and the z plane, and then dimension the projections individually.
But I have many many lines to measure and I’m wondering if there’s a quicker way to do this—like... selecting the 3D line and automatically getting an (x,y,z) measurement?
I haven’t coded in FeatureScript so I'm afraid the learning curve there would more than offset the efficiency gain over just projecting the curves individually and then measuring the projections one by one by one by one...
Huge thanks if you know how to do this and can share!
EDIT:
OK, I see I can get the coordinates for individual points simply by selecting them and moving my eyes to the lower right screen corner. This is much better, since I can quickly get the (x,y,z) for point 1 and (x,y,z) for point 2 and subtract to get (dx,dy,dz) for the line segment... But I'm still wondering if there's a better way than this?
0
Best Answer
-
Alex_Kempen Member Posts: 248 EDUYou can actually click the measuring icon in the bottom right corner to pop up additional information about your measurement selection. For example, if you click two points, Onshape will actually report out the x change, y change, z change, and minimum distance between the points in the popped out measure dialog. It will also let you mouse over individual measurements, and display a graphical representation of said measurement in the model window.
Depending on what level of vector math you're actually trying to do, writing a quick FeatureScript to get some information and/or compute some vectors quickly could be worthwhile, although I agree that the learning curve can be quite steep initially. If you want, I'd be happy to throw together a quick example with some basic functionality to get you going; once you've converted query selections to a vector array, actually performing manipulations on vectors (like projecting, cross product, dot product, etc.) is very easy.CS Student at UT DallasAlex.Kempen@utdallas.eduCheck out my FeatureScripts here:1
Answers
Depending on what level of vector math you're actually trying to do, writing a quick FeatureScript to get some information and/or compute some vectors quickly could be worthwhile, although I agree that the learning curve can be quite steep initially. If you want, I'd be happy to throw together a quick example with some basic functionality to get you going; once you've converted query selections to a vector array, actually performing manipulations on vectors (like projecting, cross product, dot product, etc.) is very easy.
var crossVector = cross(vector1, vector2);
Of course, the tricky part is computing the two input vectors (in this case, vector1 and vector2) in the first place. FeatureScript takes inputs from the part studio as selections, called queries; queries are essentially instructions to find a specific entity or element of a part studio. You would then have to use an evaluate function to determine coordinates of certain elements. To get vectors representing the ends of a line, you'd probably need to use evEdgeTangentLine to compute a tangent line at the start and end of each selected line; you would then be able to use the origins of your evaluated lines to get a vector representing your line. From there, you would be able to take the cross product and perform other vector operations as needed.This sounds a lot more complicated than it actually is, but it does help if you have at least some experience with CS already. If you describe what you're trying to do more exactly, I can throw together a basic FeatureScript to get you pointed in the right direction.