Monday, November 9, 2009

Finding the mass of a solid using Autocad

You may know of the Autocad command "MASSPROP". A very useful command when you have drawn an item in a 3D solid and wish to calculate the volume or mass of it. If your model is made up of many solids you might have to take a copy of them and run the union command on them, to make them all one piece.

Unfortunately, all it gives is the volume, and in my case in cubic millimetres, so you have to usually convert it to cubic metres and then multiply that by 7850 which is the density of steel in kg/cubic metre.

To shortcut all this I have written a lisp that does all this for you.

Before running the routine, which can be found at my website, http://bilrocad.com ,please make a directory called "bilro" off your c: drive, ie c:\bilro, othewise it won't work. If you want to put it somewhere else, fine, but be sure to alter the two places in the routine where it reads and writes to a file-have a look, they are easy to spot!

How it works:
1. It issues the Autocad command MASSPROP and when asked if it wants to write to a file, it does so, putting it at c:\bilro
2. It then opens up this file and using a counter skips down the first five lines to locate the volume.
3. The final part just multiplies the volume x 7850 to give an aswer in kg on the command line.

You will see that in the process of doing it's thing it sets filedia to 0, which suppresses file dialog boxes. If this routine ever crashes, to set things back to normal, type filedia at the command prompt and set it to 1, otherwise you have to use the command line to open drawings.

Happy massing!

No comments: