# Get Volume of Graphics Object

I would like to know if there is any way to get the volume of an object, even something easy as a box.
That is, say I want to randomly create boxes of different sizes and then sort them by size. I would like to use some sort of volume sensor for this.
I've been searching for a smart component that can get the sides of a box but with no sucess.
Tagged:

• So measure it not calculate in code?
• You could make use of the line sensor since it will give you the point where the sensed object is. The setup for such a solution could be done in various ways. You could make us of a squaring table to slide the component to a known position using two sensors to measure the sides of boxes, then a third sensor either on a fixed position over the box or on the robot measuring the height of the cube. If the cycle time isn't that critical you could simply use a single sensor on the robot sliding it over the top of the cube to detect the edges and calculate the volume based on the positions of the edges. This will give both the position and volume of the cube and depending on the number of points you measure you could also get the rotation of the cube.

If you don't really need to simulate any measuring you could simply save the measurements used when generating the boxes and calculate the volume based on the values for each box.
• dnilsson said:
You could make use of the line sensor since it will give you the point where the sensed object is. The setup for such a solution could be done in various ways. You could make us of a squaring table to slide the component to a known position using two sensors to measure the sides of boxes, then a third sensor either on a fixed position over the box or on the robot measuring the height of the cube. If the cycle time isn't that critical you could simply use a single sensor on the robot sliding it over the top of the cube to detect the edges and calculate the volume based on the positions of the edges. This will give both the position and volume of the cube and depending on the number of points you measure you could also get the rotation of the cube.

If you don't really need to simulate any measuring you could simply save the measurements used when generating the boxes and calculate the volume based on the values for each box. 