trying to do a lisp routine- help

I want to make a quick lisp routine that will take the cubic inches from a massprop command and calculate weight (lbs and kgs) from that. Anyone have
a quick solution? Thanks.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Show us the code you've got so far.
--


MichaelB
www.michaelbulatovich.ca
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
LISP ROUTINE IS:
(defun c:conv (/ input1 matx output)
(setq dcl_id (load_dialog "conv1"))
(new_dialog "conv1" dcl_id)
(action_tile "cubin" "(do_cubin)")
(action_tile "accept" "(done_dialog)")
(action_tile "cancel" "(done_dialog) (cuberr)")
(defun do_cubin ()
(setq cubin1 (get_tile "cubin"))
)
(start_dialog)
(setq output (* do_cubin 0.28355))
(unload_dialog dcl_id)
(princ "\nWeight in pounds is : " output)
)
DIALOG BOX IS:
dcl_settings : default_dcl_settings {audit_level = 0;}
conv1 : dialog
{
label = " converter";
width = 40;
spacer_1;
: text {
label = " Enter the cubic centimeters: ";
width = 40;
}
: boxed_column
{
fixed_width = true;
width = 17;
alignment = centered;
: edit_box {
label = "cubic-centimeters:";
key = "spout";
mnemonic = "D";
edit_width = 5;
}
}
spacer_1;
: text {
label = " Once your entry is made, select the OK";
}
: row {
width = 20;
alignement = centered;
spacer_0;
: ok_button {
label = "-OK-";
key = "accept";
fixed_width = true;
width = 8;
alignment = centered;
}
: cancel_button {
label = "CANCEL";
key = "cancel";
fixed_width = true;
width = 8;
alignment = centered;
}
spacer_0;
}
}
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
nevermind. all set. here is the code I ended up with:
(defun c:qw ()
cmdech (getvar "CMDECHO")
(setvar "CMDECHO" 0) ;turn echo off
(setq out1 0)
(setq outk 0)
(setq ptX 0)
(setq output 0)
(setq outk 0)
(setq thefile "tempx.mpr")
(command "massprop" pause "" "y" thefile)
(setq afile (open "tempx.mpr" "r"))
(setq cpt 1)
(while (setq aline (read-line afile))
(if (= (substr aline 1 4) "Mass")
(progn
(setq ismass 1)
(setq avalue 1)
(setq ptX (atof (substr aline 26)))
) ;progn
); if
)
(close afile)
(command "del" "tempx.mpr")
(setq out1 (+ 0.28355))
(setq outk (+ 0.4536))
(setq output (* out1 ptX))
(setq outputk (* output outk))
(setq wt1 (rtos (* out1 ptX)))
(setq wt2 (rtos (* output outk)))
(setvar "CMDECHO" 1) ;turn echo on
(princ "weight in pounds: ")
(princ output)
(princ " weight in kgs: ")
(princ outputk)
(princ)
)

have
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hi

This one does in metric...... ;Program written by Bill Le Couteur ;Auckland NZ ;Rev 0 date 3.11.04 ;This program INSERTS A MASS BLOCK ;WITH THE MASS DERIVED FROM ;PICKING A SOLID ;-DERIVED FROM A TEXT FILE
(defun c:GPM()
(setq oldosmode (getvar "osmode")) (setvar "osmode" 0) (setvar "attdia" 0)
(setvar "filedia" 0)
(command "massprop" pause "" "Y" "C:/mass")
;;;;now open the list of drawings file (setq sfile (open "C:/mass.mpr" "r"))
(setq count 5)
(while (> count 0)(setq the_volume (read-line sfile)) (progn; ;(print count)
;(print the_volume) (setq count (- count 1))
);end progn );end while
(setq howlong (strlen the_volume))
(setq the_actualvolume (substr the_volume 26 howlongdes))
(print the_actualvolume) (setq the_actualvolumef (atof the_actualvolume)) (print the_actualvolumef) (setq the_actualvolumefcm ( / the_actualvolumef 1000000000)) (setq the_mass (* the_actualvolumefcm 7850))
(setq the_masss (rtos the_mass 2 2)) (setq the_masss (strcat the_masss " kg"))
(close sfile) (setvar "tilemode" 0) (command "-insert" "mass" "300,250" "1" "1" "0" the_masss) ;;comment---mass is just a little block with one attribute... (setvar "filedia" 1) (setvar "osmode" oldosmode) (setvar "attdia" 1)
(princ) )
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.