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.

transformBox3D help

Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
I'm trying to find a bounding box of a part, that is oriented in a certain direction, but I'm not getting the results I expected from transformBox3d. Any pointers?
Here's the code I'm using
FeatureScript 1311;
import(path : "onshape/std/geometry.fs", version : "1311.0");

annotation { "Feature Type Name" : "embedded" }
export const embedded = defineFeature(function(context is Context, id is Id, definition is map)
    precondition
    {
        annotation { "Name" : "Printer Z-direction", "Filter" : BodyType.MATE_CONNECTOR, "MaxNumberOfPicks" : 1 }
            definition.printercSys is Query;
            annotation { "Name" : "nut", "Filter" : EntityType.BODY && BodyType.SOLID}
            definition.nut is Query;
    }
    {
        var nut = definition.nut;
        var printercSys = evMateConnector(context, {
                "mateConnector" : definition.printercSys
        });
        debug(context, printercSys);
        var nutBox = evBox3d(context, {
                "topology" : nut,
                "tight" : true,
                "cSys" : printercSys
        });
        debug(context, nutBox);
        nutBox = transformBox3d(nutBox, toWorld(printercSys));
        debug(context, nutBox);
    });

Evan Reese / Principal and Industrial Designer with Ovyl
Website: ovyl.io

Best Answer

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,310
    I'm not actually sure of the use case of transformBox3d in its current form.
    Senior Director, Technical Services, EMEAI
  • Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
    @NeilCooke
    thanks! I need to study the different options for debug. I only ever use the most basic one 😅.

    I will eventually need to reference the "top" face of the box (relative to my cSys) to create a sketch there, so I need a box at the actual location. This assumes there's not a better way to get a plane touching a part at the farthest point along a direction.

    For the curious, I'm exploring whether I'm able to automate the creation of support parts for embedding nuts in 3D prints similar to what's in this article: https://markforged.com/blog/embedding-nuts-3d-printing/, and that's meant to be part of a larger Nut Pocket feature. I've wanted to try writing my own version with all of my dream functionality since I saw the cool one that @owen_sparks worked on.
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Evan_ReeseEvan_Reese Member Posts: 2,060 PRO
    @NeilCooke
    I still couldn't figure out how to transform a box there, but in my particular case, I found a better way not using a box3D. Since my "nut" body always has a vertex (or a few) at the farthest point (unlike a sphere, or something where part of a curved face is the farthest portion), I did it this way, and it's working:
            var nut = definition.nut;
            var nutPoints = qOwnedByBody(nut, EntityType.VERTEX);
            var printercSys = evMateConnector(context, {
                    "mateConnector" : definition.printercSys
            });
            var farthestPoint = evaluateQuery(context, qFarthestAlong(nutPoints, printercSys.zAxis))[0];
            var supportPlaneOrigin = evVertexPoint(context, {
                    "vertex" : farthestPoint
            });
            var supportPlane = plane(supportPlaneOrigin, printercSys.zAxis, printercSys.xAxis);

    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
Sign In or Register to comment.