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.
Creating 3D Points
billy2
Member, OS Professional, Mentor, Developers, User Group Leader Posts: 2,068 PRO
I've scanned this forum for code that does these, I haven't found any solutions.
3 cases
-at a vertex
-on an edge at cursor location
-on a surface at cursor location
case #1:
someone picks a vertex (I got this one working).
code for 3D point at a vertex:
3 cases
-at a vertex
-on an edge at cursor location
-on a surface at cursor location
case #1:
someone picks a vertex (I got this one working).
code for 3D point at a vertex:
const chinPt = evVertexPoint(context, {"vertex" : evaluateQuery(context, definition.chin)[0]});
opPoint(context, id + "chin", { "point" : chinPt * meter, "origin" : true });
create a 3d point at selected vertex:
case #2
someone picks along an edge
create a 3D point on edge at cursor location:
case #3
someone picks on a surface
create a 3D point on a surface at cursor location:
0
Comments
Features like this don't fit as well in the parametric paradigm because the user has no control over exact coordinates (beyond eyeballing), and, when it comes time to update that point due to upstream changes to that edge or surface, there's no way to infer the original design intent. Did the user want it half an inch from one side? Two inches from the other? 20% along the line?
See other discussion here.
Parametrics has no meaning in what I'm doing. I'm working with imported geometry so there won't be any upstream changes. These models are surfaces so we've left the world of accuracy many moons ago and things that look good are surprising good enough. I believe geometry 1st, parametrics 2nd. I'm not needing a parametric solution. Just a 3D point on some 3D geometry.
Can I sketch a 2D point on a sketch plane then query and find stuff under the point? Does evdistance give me this distance from a sketch plane to an edge at my 2D point location? I can add this to distance to the sketch and then transpose it to the world. This would work for me. I've been following the discussion on uv positions on a surface. But there's no how in these discussions.
Can you explain how this is done. I'm really want x,y,z in world coordinates. There is a solution, it is determinant. If I have to use a sketch to get there, hey, let's do it. Seems a little funky but if I can get the view matrix, I'll create a temporary sketch, place 2D point, do my math, get my 3D point coordinates, and clean up all the garbage and I'll have my 3D point.
Can I query the current view matrix? I see world to sketch and sketch to world, but no world to view. If you're telling me I have to work on a 2D sketch, place my 2D point, run some math and get a normal distance to my edge/surface, transpose it back to world. Yes, a 3D point in world coordinates. Valid for only an instant which is good enough for me.
Can this be done? I really want to place a 3D point on some 3D geometry. I don't care about parametrics.
Looking for a way to return a vector with the following intersection:
Search std lib for intersect and came up with this:
intersection() won't work with a face, only a plane. So let's try an get a vector & a plane working:
Ok, so featurescript returns LinePlaneInstersection which is a map kinda like an object in javascript?
So intersect.LinePlaneIntersection.intersection should return a Vector?
1. How do I extract the Vector out of LinePlaneIntersection? It's intersect.intersection
yahoo:
2. How do I intersect with a face?
3. Do you have a pretty print function for these maps when using println?
If they intersect, that point will be the same on both sides of the result. But for when they don't intersect, you should choose whether you'd rather grab the point on the line closest to the surface, or the point on the surface closest to the line.
I'll play around with an infinite line, surface & evDistance.
I guess you can create 3D points on 3D geometry! The secret is in the evDistance() and forcing an infinite line through the 3D geometry. Kevin is right in that the line has to pass through the 3D geometry otherwise you'll get a minimal distance projection.
The question now is how to create an infinite line inside OS from a skPoint? Shouldn't be that hard.
Thanks Kevin,
Kevin I was wondering if I could use a direction vector call to evDistance.
Is a normalized 3D vector inside OS a 4x4 matrix? You can't create this from the UI right.
Direction approach:
I'll try this 1st and see if I can skip evBox3D. I'm assuming the normalized 3D Vector needs to be in world. Can I pass a
normalized vector from a sketch through one of your transforms and end up with a world direction?
evBox3D approach:
I was thinking of Ilya's approach. Just needed to look up how to make evBox3D work in the sketch coordinates. Take Z's from the evBox3D and construct 2 vectors in sketch coordinates based on point, move them to world and construct opFitSpline. I take it opFitSpline is world coordinates and will pass it into evDistance. Should be easy.
evOwnerSketchPlane(...).normal
Unfortunately you can't get the view matrix from inside FeatureScript. So the above relies on the user first making a sketch on a plane pointing in the direction they want. Perhaps you can think of a better heuristic but depending on the camera angle is not possible.
I was wondering about view manipulation from featurescript. My thought was to create a sketch on the fly based on the view and the user would never know how the 3D points were created. Oh well, what a crazy idea.
This solution I now have will work fine.
Thanks again,