×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to change density of blocks
2

How to change density of blocks

How to change density of blocks

(OP)
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

RE: How to change density of blocks

2
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

RE: How to change density of blocks

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

RE: How to change density of blocks

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

RE: How to change density of blocks

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 "filedia" 0)
(setvar "cmdecho" 0)
(print "Select solids or regions")
(setq ss (ssget))
(command "massprop" ss "" "y" "c:/temp/deleteme")
(setvar "filedia" 1)

(setq mprfile (open "c:/temp/deleteme.mpr" "r"))
(read-line mprfile)
(setq title (read-line mprfile))
(close mprfile)
(if (= nil (wcmatch title "*REGION*")) (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 "c:/temp/deleteme.mpr" "r"))
(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 "osmode")
)

(setvar "osmode" 0)
(command "point" point-coord)
(setvar "osmode" old-osnap)
(setq weights (strcat     "Weights at 1 inch thick: " (rtos weight-cs 2 1) "# cs, "
        (rtos weight-ss 2 1) "# ss, " (rtos weight-al 2 1) "# al " (rtos weight-UHMW 2 1) "# UHMW "))
(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 "c:/temp/deleteme.mpr" "r"))
(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 "osmode")
)

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

RE: How to change density of blocks

(OP)
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

RE: How to change density of blocks

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

RE: How to change density of blocks

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 "wisdom" 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!

RE: How to change density of blocks

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" 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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources