Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change density of blocks 2

Status
Not open for further replies.

oijammu

Civil/Environmental
Jun 1, 2001
27
0
0
I am relatively new to Autocad.How can I change densities of a block so that when I list mass properties,Volumes and Mass give different values
 
Replies continue below

Recommended for you

Dear oijammu,

I think the BLOCK in your mind is 3DSOLID.
AutoCAD supposes the dfault density equal to 1 for all
3DSolids. You have to multiple the required density to
the calculated volume or mass (by the MASSPROP command) to
achieve the real mass.

The below VisualLISP code calculates the mass for 3DSolids.
The length units must be in millimeters and the material
is supposed to be steel. All you have to do is:
1. Copy and paste the below expressions into a file.
2. Save the file named WEIGHT.LSP
3. In AutoCAD environment load the file using the APPLOAD
command.
4. Type "WE" in the command line and press ENTER.
5. Select 3DSolid objects.
6. The exact weight will be calculated.



(defun c:WE( / ss TotVol TotMass n m e vla-e)
(if (null vlax-ename->vla-object)
(vl-load-com)
)
(setq ss (ssget '((0 . "3DSOLID"))))
(setq TotVol 0.0)
(setq n 0)
(setq m (sslength ss))
(while (< n m)
(setq e (ssname ss n))
(setq vla-e (vlax-ename->vla-object e))
(setq TotVol (+ TotVol (vla-get-volume vla-e)))
(setq n (1+ n))
)
(setq TotMass (* TotVol 7860e-9))
(terpri)(princ TotMass)(terpri)
(princ)
)




I have written a faster code in AutoCAD VBA. If you like I
can send it to you. My email address:
heydarif@yahoo.com


Regards,
Farzad
 
I didn't work in last period with new version of AutoCAD and I'm surprised by this situation. In SolidWorks, you can put for each solid the mass properties and finally you can have the real mass of an assembly.

The latest AutoCAD versions doesn't have this feature? This is what I understand from your excellent answer. Regards
Fernando
 
Dear fernando,

Your guess is true. AutoCAD does not include the mentioned feature, but in Autodesk Mechanical Desktop you can assign a density and other properties to each part.

Regards,
Farzad
 
Try this code. It won't allow you to assign different mass properties, but it will report them. Currently this lisp only report carbon steel, stainless steel, & aluminum. UHMW. Neoprene, & pine will be added soon.

If anyone wants to take a stab at creating a dialog for this, I would be greatful.

;This program draws a point at the centroid of a
;region or solid. The point is drawn on the current
;layer at the current settings. It creates a file
;called deleteme.mpr in c:\temp directory that can
;be deleted if wanted, otherwise the program will
;just overwrite it everytime it runs.

(defun c:CG2002 (/ ss mprfile title c-steel s-steel alumn UHMW Neoprene Pine )

(setq c-steel 0.2833
s-steel 0.286
alum 0.098
UHMW 0.0347
Neoprene 0.045
Pine 0.022)
(setvar &quot;filedia&quot; 0)
(setvar &quot;cmdecho&quot; 0)
(print &quot;Select solids or regions&quot;)
(setq ss (ssget))
(command &quot;massprop&quot; ss &quot;&quot; &quot;y&quot; &quot;c:/temp/deleteme&quot;)
(setvar &quot;filedia&quot; 1)

(setq mprfile (open &quot;c:/temp/deleteme.mpr&quot; &quot;r&quot;))
(read-line mprfile)
(setq title (read-line mprfile))
(close mprfile)
(if (= nil (wcmatch title &quot;*REGION*&quot;)) (CG-SOLID) (CG-REGION))
)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(defun CG-REGION (/ mprfile area-line x-line y-line x-coord
area-size y-coord point-coord old-osnap
weight-cs weight-ss weight-al weights)

(setq mprfile (open &quot;c:/temp/deleteme.mpr&quot; &quot;r&quot;))
(repeat 3 (read-line mprfile))
(setq area-line (read-line mprfile))
(repeat 3 (read-line mprfile))
(setq x-line (read-line mprfile))
(setq y-line (read-line mprfile))
(close mprfile)

(setq area-size (atof(substr area-line 25))
weight-cs (* area-size c-steel)
weight-ss (* area-size s-steel)
weight-al (* area-size alum)
weight-UHMW (* area-size UHMW)
x-coord (atof(substr x-line 25))
y-coord (atof(substr y-line 25))
point-coord (list x-coord y-coord)
old-osnap (getvar &quot;osmode&quot;)
)

(setvar &quot;osmode&quot; 0)
(command &quot;point&quot; point-coord)
(setvar &quot;osmode&quot; old-osnap)
(setq weights (strcat &quot;Weights at 1 inch thick: &quot; (rtos weight-cs 2 1) &quot;# cs, &quot;
(rtos weight-ss 2 1) &quot;# ss, &quot; (rtos weight-al 2 1) &quot;# al &quot; (rtos weight-UHMW 2 1) &quot;# UHMW &quot;))
(alert weights)
(print weights)
(princ)
)
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(defun CG-SOLID (/ mprfile vol-line x-line y-line z-line x-coord
y-coord z-coord vol-size point-coord old-osnap
weight-cs weight-ss weight-al weights)

(setq mprfile (open &quot;c:/temp/deleteme.mpr&quot; &quot;r&quot;))
(repeat 4 (read-line mprfile))
(setq vol-line (read-line mprfile))
(repeat 3 (read-line mprfile))
(setq x-line (read-line mprfile))
(setq y-line (read-line mprfile))
(setq z-line (read-line mprfile))
(close mprfile)

(setq vol-size (atof(substr vol-line 25))
weight-cs (* vol-size c-steel)
weight-ss (* vol-size s-steel)
weight-al (* vol-size alum)
weight-UHMW (* vol-size UHMW)
x-coord (atof(substr x-line 25))
y-coord (atof(substr y-line 25))
z-coord (atof(substr z-line 25))
point-coord (list x-coord y-coord z-coord)
old-osnap (getvar &quot;osmode&quot;)
)

(setvar &quot;osmode&quot; 0)
(command &quot;point&quot; point-coord)
(setvar &quot;osmode&quot; old-osnap)
(setq weights (strcat &quot;Weights: &quot; (rtos weight-cs 2 1) &quot;# cs, &quot; (rtos weight-ss 2 1)
&quot;# ss, &quot; (rtos weight-al 2 1) &quot;# al &quot; (rtos weight-UHMW 2 1) &quot;# UHMW &quot;))
(alert weights)
(print weights)
(princ)
)

 
Thanx FH & Andylaug, I shall try it out.Unfortunately weekdays I am working in the Tanzanian bush and can be online only on sundays.

Regards Mooslim

 
AndyLaug:

I tried your calculation and it works great! You should e-mail this to Autodesk. Since version 13 or before, they have never addressed this in later updates (?). Maybe their programmers can take a break from writing useless code and take the time to include something a little more valuable like this in the next AutoCad version, whenever that may be(?).

Mike Waugh
 
I'm going to try the code posted. Looks good!
But a simpler solution would be to find the mass vaule for a particular material and multiply the volume number you get back from the massprop command by that. For instance, I know that the value for steel is .2833 X the total cubic inches. That's it. Done.
Yes, sorry Adesk in their &quot;wisdom&quot; chose not to include that step in their code, but jeez! (I AM flummoxed by their including the mass line and the volume line in the massprop command report, with a factor of 1! Couldn't they have added the extra step to input a factor other than 1? oh well.)
Additionally, I'll also create a set of attributes for EACH PART,(YES EACH PART- especially in 3D design, but also in 2D) one of which includes the answer I got for that part when I did the weight step above. I can then click on a part and (re)learn things about it down the road, or run an extract using std acad out to an excel sheet and perform a composite weight takeoff.
Writing values to an external text file that will be overwritten each time seems an interesting if cumbersome approach, but the code seems imaginative!I'll give it a try.
GOOD LUCK!
 
Oh by the way, your RYERSON STEEL supplier book (catalog)
-or other- will have various standard materials used in everyday production, including Steel in various flavors, SST similarly, Brass, Bronze, Aluminum etc., and even some plastics. Material variations not necessarily listed are likely very close to materials that ARE listed, especially for reasonable composite estimates.
Just find a 1&quot; sq. bar of any material, find the minimum value listed (usually 1') and divide the bar weight by 12. You'll be surprised how cose the value will be. I've never encountered one that didn't come out correct to 3+ dec plcs.
If your needs are more precise, call a materials vendor. In about 5 minutes you can have values for dozens of materials.
GOOD LUCK!
 
Status
Not open for further replies.
Back
Top