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.
Bounding Box Help
Nath_McC
Member Posts: 127 PRO
Hi Forum,
I was wondering if a feature script smart person could give me a helping hand. I am trying to create a bounding box around my part. I have had a look at some other feature scripts but they included sheet metal parts (mine does not) and I got confused.
What I am looking for is to below:
Line 51 - Add a script that will get the X,Y, Z lengths of the part, My thinking is that I can then use these to find the longest of the three sides. These values will link to the variables xLength, yLength and zLength.
Line 60 - Add code which will take the longest axis and set it as longestAxis variable from the array.
Line 106 - If the 'create bound box' checkbox is ticked build a bounding box around the part, I guess this will end up being a new body so it would be great if that could be auto named 'Part # - Bounding Box'. That the name of the select body and then adding the extra to the end.
It has taken me quite a while to get to this point so if anybody could help, it would be greatly appreciated.
https://cad.onshape.com/documents/5da157e99bb455d905d327d2/w/d44f3937f3715cfeea184d91/e/cc11569037b08d0bcc741424
I was wondering if a feature script smart person could give me a helping hand. I am trying to create a bounding box around my part. I have had a look at some other feature scripts but they included sheet metal parts (mine does not) and I got confused.
What I am looking for is to below:
Line 51 - Add a script that will get the X,Y, Z lengths of the part, My thinking is that I can then use these to find the longest of the three sides. These values will link to the variables xLength, yLength and zLength.
Line 60 - Add code which will take the longest axis and set it as longestAxis variable from the array.
Line 106 - If the 'create bound box' checkbox is ticked build a bounding box around the part, I guess this will end up being a new body so it would be great if that could be auto named 'Part # - Bounding Box'. That the name of the select body and then adding the extra to the end.
It has taken me quite a while to get to this point so if anybody could help, it would be greatly appreciated.
https://cad.onshape.com/documents/5da157e99bb455d905d327d2/w/d44f3937f3715cfeea184d91/e/cc11569037b08d0bcc741424
Tagged:
0
Comments
https://cad.onshape.com/documents/2ce3e64026df1ac7e63b98bd/w/7a2029e15b241c80c591a492/e/ee8919ad0a28cec3b0740617
For line 60, the max function can take an array:
To create the bounding box part, you can use fCuboid:
With naming, there's a bit of a snag since you don't know the part name yet at this point during regen. You can give it a static name, but not a name that depends on the part:
Hope this helps.
@ilya_baran Thank you, that break down give me a great starting point for updating my code.
To be clear, I didn’t write the feature script I linked to.