white_ca Posted November 21, 2014 Share Posted November 21, 2014 Hi to all,not a programer, just a simple drafter , wondering if anyone can help me combine these two programs I found them online don´t know the source but use them on a daily basis. Tried several attempts combining but never worked.One program calculates the weight of material the other the area of the oject in m2 witch I multiply by 10.76 to get it in square feet. what I was looking was when I get the result of the weight of the material I would also get the result of the area in square feet. I work in scale 1:1 ( milimiters ) and when I use the area program I get the result sort version and would like to keep that but in square feet (m2 x 3.28X3.2. Can anybody help me Thank you all Weight Lsp: ;;; Lisp function for calculating weight per metre length of section (profile) with ;;; choice to assign material. ::: Option to extend materials list. ;;; By Cadtutor poster Petkovski with help from Cadtutor poster PBE. ;;; http://www.cadtutor.net/forum/showthread.php?50384 ;;; Modified by Manila Wolf. Added my own material and density values. ;;; Figure is density in g/cm3 divided by 1000 then multiply by 0.671968975 ===================================================================================== (defun C:CalcWtin (/ area en ent obj ospace prefix pt remd resp suffix) ;;;------------------------------------------------------------------------------------- ;;;error trap (defun *error* (msg) (command "._undo" "_end") (setvar 'dynmode old_Dyn) ) ;_ end_defun ;;;------------------------------------------------------------------------------------- ;;;initalize (setq old_Dyn (getvar 'dynmode)) (setvar 'dynmode 3) (command "._undo" "_begin") ;;local defun (defun density (mat) (cond ((eq "Aluminium-Extrusion" mat) 0.001821) ((eq "Aluminium-Sheet-3003" mat) 0.001834) ((eq "Plain-Carbon-Steel" mat) 0.005275) ((eq "Stainless-Steel-304" mat) 0.005309) ((eq "Stainless-Steel-316" mat) 0.005376) ((eq "Glass" mat) 0.001693) ((eq "EPDM-Silicone" mat) 0.000786) ((eq "Rigid-PVC" mat) 0.000974) ((eq "Granite" mat) 0.00180 ((eq "Isobar-pa66-gf25" mat) 0.000907) ((eq "Terracotta" mat) 0.001445) ((eq "Wood-average" mat) 0.00045022) ((eq "Pultrusion" mat) 0.0012297) ;; add other materials similarly (T nil) ) ) ;;main part ;;(setvar "dynmode" 3) ;;(setvar "dynprompt" 1) (setq ospace (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))) ) (setq prefix "Weight = " suffix " lb/ft" ) (while (setq ent (entsel "\nSelect a closed polyline or region (or press Enter to Exit) >>")) (setq en (car ent)) (if (wcmatch (cdr (assoc 0 (entget en))) "REGION,*POLYLINE,CIRCLE,ELLIPSE") (progn (setq obj (vlax-ename->vla-object en)) (initget "Aluminium-Extrusion Aluminium-Sheet-3003 Plain-Carbon-Steel Stainless-Steel-304 Stainless-Steel-316 Glass EPDM-Silicone Rigid-PVC Granite Isobar-pa66-gf25 Terracotta Wood-average Pultrusion"); (setq resp (getkword "\Choose material [Aluminium-Extrusion/aLuminium-sheet-3003/Plain-carbon-steel/Stainless-Steel-304/sTainless-Steel-316/Glass/EPDM-silicone/Rigid-pvc/GRanite/Isobar-pa66-gf25/Terracotta/Wood-average/PUltrusion] : ")) (setq area (strcat prefix (rtos (* (vla-get-area obj) (density resp)) 2 ; 3 ; ) suffix ) ) (setq pt (getpoint "\nPick text point: ")) (vla-addtext ospace area (vlax-3d-point (trans pt 1 0)) (getvar 'Textsize) ;; ) ) ) ) (*error* "") (princ) ) (prompt "\n\t\t>>>\tType CALCWTIN or calcwtin to calc mass\t (prin1) (vl-load-com) Area Lsp: (defun c:sarea(/ aSum cSet) (vl-load-com) (setq aSum 0) (if(setq cSet(ssget '((0 . "*POLYLINE,SPLINE,CIRCLE,ELLIPSE")))) (foreach c(vl-remove-if 'listp(mapcar 'cadr(ssnamex cSet))) (setq aSum(+ aSum(vlax-curve-GetArea c))) ); end foreach ); end if (princ(strcat "\nTotal area = " (rtos(/ aSum 1000000)) " m2")) (princ) ); end of c:sarea Quote Link to comment Share on other sites More sharing options...
SLW210 Posted November 21, 2014 Share Posted November 21, 2014 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 21, 2014 Share Posted November 21, 2014 Simple but I would do a IF for M or F ; (rtos (* (vla-get-area obj) (rtos (* (* 10.76391 (vla-get-area obj))(density resp)) ; do IF M or F here then no 10.76 To fix code problem type [ code ] at start and [ / code ] at end with no spaces. Quote Link to comment Share on other sites More sharing options...
Manila Wolf Posted November 26, 2014 Share Posted November 26, 2014 I do not have the ability to combine your lisps. What I can do, is suggest a replacement lisp for the Area lisp you are using. See the attached AreaPerim.lsp I draw in millimetres and use this lisp to show both metric and imperial units. I select the resultant value I want using Ctrl C then paste into the drawing using Ctrl V The precision is set to 3 decimal places. This can be adjusted if required. AreaPerim.lsp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.