Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape, CAD, maker project and design.

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.

Is there a way to find the extents of an object with one command?

bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
My ideal would be a way to 'automatically' find the smallest volume rectangular box containing the object(s) and then spit out the height, width, length, area, & volume of said box.  The target objects being individual or combination of surfaces, parts, or assemblies (whatever is selected).

Best Answers

  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    @bruce_williams

    The bounding box size appears as a printout in the FeatureScript console of your part studio.  To access this press the button at the top of your page that looks like a set of braces surrounding a checkmark:



    Then, when you use the feature, the printout will appear in the panel at the bottom of your screen.
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    @bruce_williams

    Figured I'd just jump the gun and do it.  See new "keep bounds as new part" option in V2.



    Note: There's not anything special about "Part 3" here, I just set its appearance to white and transparent in the right click > "Edit Appearance for Part 3..." menu after committing the feature.
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    It would be hard to display anywhere besides the console reliably from inside FeatureScript.  You can get the l/w/h easily through the UI though:



    Just click the edge in question and it will display the length in the bottom right corner of the screen.
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    As of right now part colors cannot be changed through FeatureScript, but stay tuned.

    FYI, (noticed something in another comment) you don't actually have to copy the document to get the custom feature in your toolbar.  If you just click the "+" button while looking at my document, you can add the feature from the "current document" section of the dialog that pops up.  That way, if there are ever updates to the feature you will automatically be prompted about them and be given the option to update to the new version, rather than having to discover them yourself organically, and copy the document again.

    So, click the +, then "current document", then the feature in question:


    Then when there's an update available, you'll see a little blue notification and can right click and press "Update":

    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    Ask and you shall receive! See new V3 :) :)
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Posts: 1,075
    Accepted Answer
    The units pulldown determines the units of the printout in the FeatureScript console.  I'm not sure how useful the printout is though, I may just simplify the script by getting rid of the printout and always keeping the see-through box as a new part.
    Jake Rosenfeld - Modeling Team
  • mbartlett21mbartlett21 Posts: 1,121 EDU
    Accepted Answer
    @Jake_Rosenfeld
    @bruce_williams
    Look at what the SolidWorks article says. :smile:
    It should be noted that for multibody parts, creating a bounding box using this method will include all bodies (unless hidden). As such, it’s not currently possible to create separate bounding boxes for each body individually using the new Bounding Box command
    They can't do bounding boxes for separate bodies. :smiley:
    MB (I make FeatureScripts: view FS)
«1

Answers

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    @bruce_williams

    This could probably be done in FeatureScript, although the smallest volume part may get a little tricky.  Additionally, if it was done in FeatureScript it could only be done for a part studio (of course you could always go the in context -> copy in place route to get an assembly into a part studio).

    I'll do some googling about bounding volume algorithms :)
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    @bruce_williams

    Just to clarify, would you be happy with the smallest axis-aligned bounding box around the selected items? The coordinate system could be defined as either the default or by a mate connector.  Or does the tool you have in mind also find the orientation of the box that makes it the smallest?
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Part studio only will be fine.  I was shooting for the moon...  I use this for evaluating imported models for quoting and also developing material sizes.  Just a little tedious to measure or make sketch to bound.

    On smallest volume - I would be happy with manually setting up a parallel plane.  This does not need to be precise.
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    @Jake_Rosenfeld
    our messages crossed.  Yes, the shortest axis (or close to it) would be good.  And OK to set mate connector or plane before fs
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    wow that was fast @Jake_Rosenfeld !  The link is not working for me though.   :(
  • mbartlett21mbartlett21 Member Posts: 1,121 EDU
    @Jake_Rosenfeld

    I think you need to make the document public so we can access it and get the custom feature.
    MB (I make FeatureScripts: view FS)
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    @bruce_williams @mbartlett21

    Sorry! Made it public, should be working now!
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    @Jake_Rosenfeld
    got it copied and it looks very promising.  Maybe I do not know how to use.  How do I get the bounding box sizes?  I see the box while in dialog and then green check the box disappears.
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    @bruce_williams

    The bounding box size appears as a printout in the FeatureScript console of your part studio.  To access this press the button at the top of your page that looks like a set of braces surrounding a checkmark:



    Then, when you use the feature, the printout will appear in the panel at the bottom of your screen.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    @Jake_Rosenfeld

    Kudos Mr. Rosenfeld!   That is exactly what I need; going to be used every day.  Thank you!
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    You're absolutely welcome!  Please let me know if you think of any tweaks or improvements for the tool, or any other useful geometry tools.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    edited January 8
    Well, since you asked.  An option to save the box would help for stock & tool design.

    just for reference - sw bounding box

    and I do have other ideas. I will work on defining; pretty exciting to see and the team so responsive.  Thanks
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    I could add a checkbox to keep the bounding box as a new Part in the Part Studio if you'd like.  Would that help?
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    @bruce_williams

    Figured I'd just jump the gun and do it.  See new "keep bounds as new part" option in V2.



    Note: There's not anything special about "Part 3" here, I just set its appearance to white and transparent in the right click > "Edit Appearance for Part 3..." menu after committing the feature.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Yes,  A checkbox would be perfect.

    And for extra credit -  is there a fairly easy way to show the size/volume values without using the FS console?  Once the box is a part, mass properties show area & volume but not x, y, z linear size.
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    It would be hard to display anywhere besides the console reliably from inside FeatureScript.  You can get the l/w/h easily through the UI though:



    Just click the edge in question and it will display the length in the bottom right corner of the screen.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Nicely done with the checkbox.

    I agree on easy to get anything needed with UI now that you have the create part option.  I really like the white transparent idea - how about having the FS set that appearance.  Bounding box will almost never be used for anything but reference.
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    As of right now part colors cannot be changed through FeatureScript, but stay tuned.

    FYI, (noticed something in another comment) you don't actually have to copy the document to get the custom feature in your toolbar.  If you just click the "+" button while looking at my document, you can add the feature from the "current document" section of the dialog that pops up.  That way, if there are ever updates to the feature you will automatically be prompted about them and be given the option to update to the new version, rather than having to discover them yourself organically, and copy the document again.

    So, click the +, then "current document", then the feature in question:


    Then when there's an update available, you'll see a little blue notification and can right click and press "Update":

    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Thanks for the info on adding FS.  
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    As of right now part colors cannot be changed through FeatureScript, but stay tuned


    @Jake_Rosenfeld,   With OS update release today for FS property programming - the white semi-transparent would be a nice touch  imho    :)
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    Ask and you shall receive! See new V3 :) :)
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    @Jake_Rosenfeld ;  Mathew 7:7 words to live by

    That is beautiful.  Thanks!

    Question - what does the units pull down do?
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Accepted Answer
    The units pulldown determines the units of the printout in the FeatureScript console.  I'm not sure how useful the printout is though, I may just simplify the script by getting rid of the printout and always keeping the see-through box as a new part.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Oh yeah!  Although I would love to be FS literate it is not happening yet.  IMHO I like your simpler route.  Doubt if many would pick up on looking at the console.  And the box can always be hidden or deleted.

    Again Nice work and this is useful.

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,075
    Really appreciate all the feedback,

    I just made an update to V4.1, the feature now operates on an option of whether to create a new part or print out the results.  If the print option is selected, a banner at the top of the screen explains how to open the console.
    Jake Rosenfeld - Modeling Team
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    Elegant!  I just showed this latest version to my assistant and it is easily understood.
  • mbartlett21mbartlett21 Member Posts: 1,121 EDU
    Accepted Answer
    @Jake_Rosenfeld
    @bruce_williams
    Look at what the SolidWorks article says. :smile:
    It should be noted that for multibody parts, creating a bounding box using this method will include all bodies (unless hidden). As such, it’s not currently possible to create separate bounding boxes for each body individually using the new Bounding Box command
    They can't do bounding boxes for separate bodies. :smiley:
    MB (I make FeatureScripts: view FS)
  • bruce_williamsbruce_williams Member, Developers Posts: 273 PRO
    @Jake_Rosenfeld

     @mbartlett21 Nice work! Choosing face is a good improvement and time saver. -  I continue to use this nearly daily and often multiple times/day.  And thanks for sharing about SW.  I knew they had added capability but did not realize the limitation.

    Onshape is making my work easier and fun!  
«1
Sign In or Register to comment.