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.

3D and 2D points not matching

Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
Hi all, hope you had a good Christmas and Happy New Year! I have encountered a problem yet again with my mortise and tenon script. I used the worldToPlane() function to use as a reference point for skRectangle(). I debugged the 3D point and added vectors to get the correct width between the two points and that works. The problem is that when I convert the 3D coordinates to use on the plane, draw the rectangle and then extrude, it doesn't extrude where I want it to and I don't know why.


Here is the file:https://cad.onshape.com/documents/580b256ade95e210af0261d8/w/1d22e17d9b07548059b7b311/e/119330903d9f0efa384481b9
Thanks
Lee Hesketh

There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    Hi @Lee_Hesketh - please try worldToPlane3D() to see if you get the result you want.

    Senior Director, Technical Services, EMEAI
  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    @NeilCooke I just tried it and this error pooped up : Precondition of operator+ failed (@size(vector1) == @size(vector2)). I assumed it was because one vector has 3 coordinates and the other two, but doesn't skRectangle() need 2D vectors not 3?
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    It does, so I would usually do something like var vec1 = vector(vec2[0], vec2[1]);
    Senior Director, Technical Services, EMEAI
  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    So would that be using the worldToPlane3D()?
    Also could you explain what you are suggesting please?
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    Sorry I was misleading you there - we changed the code of how those functions worked a while back and thought that might be the cause.

    I think it is just an error in the sign of your maths and where the origins of the face are (if you still can't work it out, post back)


    Senior Director, Technical Services, EMEAI
  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    I don't think it's an origin issue. What I'm doing is using evPlane() on intFace1 to use as the plane for worldToPlane() and vertexPoint as the coordinates to convert to 2D. Then I am simply taking those coordinates and translating them by adding another 2D vector. It works in 3D as shown in my image, the red dots. The error seems to be when using worldToPlane(). Could it be that onshape doesn't know which axis intFace1 is facing? i.e. it doesn't have an x direction. Before, I was using the Plane() function and using evFaceTangetntPlanes().x but now I am just using evPlane(). Could you possibly use your featurescript mastery to help?
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    edited January 2017
    Not sure I follow this logic - surely centrePoint1[0] is never going to equal vertexPoint[0] from the graphic above? If I comment out this code it looks good? Where should it be offsetting from? vertexPoint or centrePoint?

          if (tolerantEquals(centrePoint1[0], vertexPoint[0]))
                {
                    if (centrePoint1[1] - vertexPoint[1] < 0)
                    {
                        h *= -1;
                        width *= -1;
                    }
                }
                if (tolerantEquals(centrePoint1[1], vertexPoint[1]))
                {
                    if (centrePoint1[0] - vertexPoint[0] < 0)
                    {
                        h *= -1;
                        width *= -1;
                    }
                }

    Senior Director, Technical Services, EMEAI
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,671
    Senior Director, Technical Services, EMEAI
  • Lee_HeskethLee_Hesketh Member, Developers Posts: 148 ✭✭✭
    I have seen your script, but I wanted to add more functionality since I am a woodworker, I use a face side and edge to reference against when marking out. Regarding the code you posted, that is for rails that are perpendicular to the ones posted in the graphic, then they have the same x coordinate. For the ones in the picture, they have the same y coordinate, so it skips the first if statement.
    There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Sign In or Register to comment.