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.
transformBox3D help
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
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
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
1
Best Answer
-
NeilCooke Moderator, Onshape Employees Posts: 5,686I had the same problem recently so I know the solution
The help states:debug (context is Context, boundingBox is Box3d, cSys) Displays the edges of a bounding box in the given coordinate system.</code><a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#transformBox3d-Box3d-Transform">transformBox3d</a> <span>(boxIn is <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#Box3d" title="Link: https://cad.onshape.com/FsDoc/library.html#Box3d">Box3d</a>, transformation is <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#Transform">Transform</a>)</span> <span>returns <a rel="nofollow" href="https://cad.onshape.com/FsDoc/library.html#Box3d">Box3d</a> </span>Return a box aligned with transformed coordinate system <b style="background-color: rgb(255, 255, 255); font-family: Flama, sans-serif; font-size: 16px;">containing the input box</b></pre><div><p>So it's not transforming the calculated box, but calculating a new one.</p><p>If you only want to display the box using debug, then there is an overload for Box3d:</p><p></p><pre class="CodeBlock"><code>
Example:
const myBox = evBox3d(context, { "topology" : entities, "cSys" : myCSys }); debug(context, myBox, myCSys);
If you want to use the values calculated by the Box3d then you just need to transform the values from World cSys to your local one.
Senior Director, Technical Services, EMEAI6
Answers
The help states:
Example:
If you want to use the values calculated by the Box3d then you just need to transform the values from World cSys to your local one.
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.
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: