Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

MASS PROP

Status
Not open for further replies.

chicopee

Mechanical
Joined
Feb 15, 2003
Messages
6,199
Location
US
WOULD ANYONE HAVE A LISP PROGRAM ON CONVERTING MASSPROP FROM A VOLUME UNIT TO A WEIGHT UNIT BY INTRODUCING A DENSITY FACTOR RELATING TO MATERIAL OF THE OBJECT DRAWN.
 
If someone answers this question, please forward it to me. I am also looking for a very similar lisp routine to return region section properties and place the data into a table/block that I've created. enclad@sbcglobal.net
 
Hey guys checkout thread555-27590! This is right up your creek.Good Luck
 
if your looking for a lisp that allows you to select a solid or group of solids then report the weight and center of gravity, then this is your lisp for autocad 2000 and up

;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)
)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top