Autodesk Technology Managers Forum
Share your knowledge, ask questions, and engage with fellow CAD/BIM Managers.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

plate weigth calculator

3 REPLIES 3
Reply
Message 1 of 4
luismestre
460 Views, 3 Replies

plate weigth calculator

Hi,
I've been try to contact the author with out sucess.
This routine lisp is a very a helpfull program to calculate plate weights.
But when I load it give all the time the same problem.
first, Says that " is not possible to find ihi2.dcl file", after that I rename the file

"plate.dcl" to "ihi2.dcl", and after loading again show me this message "Command:
Command: plate
Error: quit / exit abort
Command:"

I have my settings on the autocad options all correct (support and working support file

search path).
Can any one with help me with this.

Regards
Luis Mestre

p.s.:
Below you can see the code for the "plate.lsp & plate.dcl" files.









LISP ROUTINE
PLATE.LSP



deem S. Legaspi Jr.
;; Saturday, March 06, 1999
;; Pasig, Manila, Philippines

(defun plate_error (s)
(if (/= s "console break")
(princ (strcat "Error: " s))
)
(done_dialog)
(unload_dialog dcl_id)
(setq *error* olderr)
(princ)
)

;;----------------------------------------------------------
;; Main function
(defun c:plate (/ cmd input rewind dia arya dum_lst mod pos1 com_secret_link)

(defun dimzin (val / digit return j)
(setq digit (rtos val 2 15) j 0)
(while (< j (strlen digit))
(if (= (setq return (substr digit (- (strlen digit) j) 1)) "0")
(setq j (1+ j))
(if (= return ".")
(progn
(setq return (substr digit 1 (- (strlen digit) (1- j))))
(setq j (strlen digit))
)
(progn
(setq return (substr digit 1 (- (strlen digit) j)))
(setq j (strlen digit))
)
)
)
)
(cond
((zerop (- val (fix val))) (rtos val 2 0))
(t return)
)
)

(defun calculate (/ val fn)
(setq fn (findfile "com.lsp"))
(cond
(fn (if (null dem_com_link) (load "com.lsp"))
(setq com_secret_link t)
(setq val (dem_com_link))
(if (eval val) (set_tile prev_key (dimzin (eval val))))
)
(t (alert "Cannot load COM.LSP (Calculator)."))
)
)

(defun reject (/ vl str)
(setq str (nth mt mat_typ) vl $value)
(if (/= str vl)
(progn
(alert "Cannot modify that data !\nYou must pick material button.")
(set_tile "mat" str)
(mode_tile "mtb" 2)
(data_select)
)
)
)

(defun user ( / plt)
(if (not (new_dialog "user_data" dcl_id)) (exit))
(setq dum_lst nil)
(mapcar '(lambda (a)
(setq dum_lst (append dum_lst (list (strcat "Plate " a))))) thk_lst)
(start_list "thk_list")
(mapcar 'add_list dum_lst)
(end_list)
(action_tile "thk_list" "(setq plt (atoi $value))")
(action_tile "cancel" "(setq plt nil) (done_dialog)")
(action_tile "accept" "(setq plt (read (get_tile \"thk_list\"))) (done_dialog)")
(start_dialog)
(if plt (set_tile "thk" (setq dtk (nth plt thk_lst))))
(compute mod)
)

(defun data_select (/ mtt)
(if (not (new_dialog "data_select" dcl_id)) (exit))
(start_list "data")
(mapcar 'add_list mat_des)
(end_list)
(set_tile "data" (itoa mt))
(action_tile "data" "(setq mtt (atoi $value))")
(action_tile "cancel" "(done_dialog)")
(action_tile "accept" "(setq mt (atoi (get_tile \"data\"))) (done_dialog)")
(start_dialog)
(set_tile "mat" (nth mt mat_typ))
(compute mod)
)

(defun about_me ()
(alert (strcat
"The author: Engr. Redem Legaspi Jr."
"\nProfession: Civil Engineer"
"\nHome/Tel.: Cebu City, Celphone - (063)0917 965 1030"
"\n\nNotes: "
"\n__________________________________________"
"\n\tThis program is undergoing neccesary"
"\n\tupdates. Any update made to this program"
"\n\twill be available to all legitimate users."
"\n\tInformation regarding such updates will"
"\n\tbe relayed by this programmer himself."
"\n__________________________________________"

)
)
)

(defun compute (md)
(if (= md 1) (compute_wt1))
(if (= md 2) (compute_wt2))
)
(defun pick_area (/ e ent enty)
(command "area" "0,0" "")
(setq e (entsel "\nPick a closed polyline: "))
(if e
(progn
(setq ent (entget (car e)))
(setq enty (cdr (assoc 0 ent)))
(if (or (= enty "POLYLINE") (= enty "LWPOLYLINE") (= enty "REGION")(= enty

"CIRCLE")(= enty "ELLIPSE"))
(if e (command "area" "o" e))
(alert (strcat "Sorry, but " enty " does'nt have an area !"))
)
)
(alert "No entity picked !")
)
)
(defun is_dot_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (= ch ".") (setq m (+ m 1)))
(setq n (+ n 1))
)
(if (> m 1) nil t)
)
(defun is_alp_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (not (equal ch ".")) (if (= (type (read ch)) 'SYM) (setq m (+ m 1))))
(setq n (+ n 1))
)
(if (> m 0) nil t)
)
(defun compute_wt2 ()
(setq area (atof (get_tile "area")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk area))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun compute_wt1 (/)
(setq len (atof (get_tile "len")))
(setq wd (atof (get_tile "wd")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk len wd))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun printv (val) (set_tile prev_key val))
(defun get_value (md / tmp)
(setq tmp $value)
(if (and (is_dot_valid tmp) (is_alp_valid tmp))
(cond
((not (distof tmp)) (setq input nil))
(t (setq input tmp))
)
(progn
(alert "Invalid input!\nPlease check...")
(setq input nil) (set_tile $key "")
)
)
(compute md)
)
;; Digit eraser function
(defun erase (mode)
(defun real_input ()
(setq ssnv (strlen input))
(if (or (= ssnv 1) (and (= ssnv 2) (minusp (atof input))))
(progn
(printv "0.")
(setq input nil)
)
(progn
(if (= (substr input (- ssnv 1) 1) (chr 46))
(setq ssnv (strlen
(setq input (substr input 1 (- ssnv 2)))
))
(setq input (substr input 1 (- ssnv 1)))
)
(if (= (type (read input)) 'INT)
(printv (strcat input (chr 46)))
(printv input)
)
)
)
(setq temp input)
)
(setq chlst nil n 1)
(if input
(while (/= (setq ch (substr input n 1)) "")
(setq chlst (append chlst (list (strcase ch))))
(setq n (+ n 1))
)
)
(if input (real_input))
)

(defun input_value (arg)
(if num
(if (or (numberp (read arg)) (= arg "dot"))
;;(if (<= lenv 20) (num_input arg))
(num_input arg)
)
)
)

(defun num_input (num)
(if (not input)
(if (and (/= num (chr 48)) (= num "dot"))
(setq input (strcat (chr 48) (chr 46)))
(setq input num)
)
(if (= num "dot")
(if (= (type (read input)) 'INT)
(setq input (strcat input (chr 46)))
)
(cond
((and (zerop (read num)) (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input (chr 48))
)
(t (if (and (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input num)
(setq input (strcat input num))
)
)
)
)
)
(printv input)
)

(defun get_dtk () (if (= prev_key "thk")(setq dtk (get_tile "thk"))))

;;;---------------------------------------------------------------------

(graphscr)
(setq olderr *error* *error* plate_error)
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq mat_data
(list
(list "Mild Carbon Steel\tC 0.35\tSS41,SM41,SF45,SS400,SM400\t7.85e-6" "Mild

Carbon Steel" 7.85e-6) ;1
(list "Forced Carbon Steel\tC 0.51~0.50\tSF55,S45C\t7.84e-6" "Forced Carbon

Steel" 7.84e-6) ;2
(list "Hard Steel\tC 0.51\tS55C\t7.83e-6" "Hard Steel" 7.83e-6)

;3
(list "Low Alloy Steel\t- \tSNC836,SCM432\t7.83e-6" "Low Alloy Steel"

7.83e-6) ;4
(list "NI.Mo Steel\t-\tSNCM439\t7.83e-6" "NI.Mo Steel" 7.83e-6)

;5
(list "Carbon Steel Casting\t-\tSC46\t7.84e-6" "Carbon Steel Casting"

7.84e-6) ;6
(list "Iron Casting\t-\tFC25\t7.25e-6" "Iron Casting" 7.25e-6)

;7
(list "Stainless Steel(1)\t13 Cr\tSUS403,420J2\t7.75e-6" "Stainless Steel(1)"

7.75e-6) ;8
(list "Stainless Steel(2)\t18 Cr, 8 Ni\tSUS304\t7.93e-6" "Stainless Steel(2)"

7.93e-6) ;9
(list "Stainless Steel(3)\t-\tSUS329JI\t7.80e-6" "Stainless Steel(3)"

7.80e-6) ;10
(list "Stainless Steel(4)\t-\tSUS316\t7.98e-6" "Stainless Steel(4)" 7.98e-6)

;11
(list "Bronze(1)\t70 Cu, 30 Zn\tC2600P\t8.53e-6" "Bronze(1)" 8.53e-6)

;12
(list "Bronze(2)\t60 Cu, 40 Zn\tC2801P\t8.39e-6" "Bronze(2)" 8.39e-6)

;13
(list "Bronze Casting\t-\tBC3\t8.80e-6" "Bronze Casting" 8.80e-6)

;14
(list "Leaded Bronze Casting\t-\tLBC3\t8.90e-6" "Leaded Bronze Casting"

8.90e-6) ;15
)
)
(setq mat_des nil mat_typ nil mat_uwt nil)
(foreach item mat_data
(progn
(setq mat_des (append mat_des (list (nth 0 item))))
(setq mat_typ (append mat_typ (list (nth 1 item))))
(setq mat_uwt (append mat_uwt (list (nth 2 item))))
)
)
(if (not (setq dcl_id (load_dialog "plate"))) (exit))
(setq rewind t)
(while rewind
(if (not mod) (setq mod 1))

(if (not (numberp mod)) (setq mod 1))

(if (= mod 3)
(progn
(setq mod 2)
(setq arya (getvar "area"))
)
)
(if (= mod 1) (setq dia "mode1"))
(if (= mod 2) (setq dia "mode2"))

(cond
(pos1 (if (not (new_dialog dia dcl_id "" pos1))(exit)))
(t (if (not (new_dialog dia dcl_id)) (exit)))
)

(if (not mt)(setq mt 0))

(if (not (numberp mt)) (setq mt 0))

(set_tile "mat" (nth mt mat_typ))
(start_list "prc")
(mapcar 'add_list
(list "0" "0.0" "0.00" "0.000" "0.0000" "0.00000"
"0.000000" "0.0000000" "0.00000000"
)
)
(setq thk_lst
(list "4.5" "6" "9" "12" "14" "16" "19" "22" "25" "28" "32" "36" "40"
"50" "55" "60" "65" "70" "75" "80" "85" "90" "95" "100")
)
(end_list)

(if (not prc)
(progn
(setq prc (getvar "luprec"))
(set_tile "prc" (itoa prc))
)
(progn
(if (not (numberp prc)) (setq prc 0))

(set_tile "prc" (itoa prc))
)
)
(if (not dtk) (setq dtk "6"))

(if (not (numberp (distof dtk))) (setq dtk "6"))

(set_tile "thk" dtk)
(if (= mod 1) (mode_tile "wd" 2))
(if (= mod 2) (mode_tile "area" 2))
(if arya
(progn
(set_tile "area" (rtos arya 2 prc))
(compute mod)
(setq arya nil)
)
)
(setq num t)
(foreach n
(list "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "dot")
(action_tile n "(input_value $key) (compute mod)(get_dtk)")
)
(action_tile "back" "(erase mod) (compute mod) (get_dtk)")
(action_tile "wd"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile \"len\" 2))")
(action_tile "len"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile \"thk\" 2))")
(action_tile "thk"
"(setq dtk $value prev_key $key) (get_value mod)
(if (= $reason 1) (progn (mode_tile \"wd\" 2)(mode_tile \"area\" 2)))")
(action_tile "area"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile \"thk\" 2))")
(action_tile "clear" "(setq input nil) (printv \" \") (compute mod) (get_dtk)")
(action_tile "prc" "(compute mod)")
(action_tile "dummy" "(compute mod)")
(action_tile "wt" "(compute mod)")
(action_tile "pla" "(setq pos1 (done_dialog 3))")
(action_tile "exit" "(setq pos1 (done_dialog 10))")
(action_tile "mode1" "(setq pos1 (done_dialog 1))")
(action_tile "mode2" "(setq pos1 (done_dialog 2))")
(action_tile "about" "(about_me)")
(action_tile "ptb" "(user)")
(action_tile "mat" "(reject)")
(action_tile "mtb" "(data_select)")
(action_tile "calc" "(calculate)(compute mod)")
(setq mod (start_dialog))
(if (= mod 3) (pick_area))
(if (= mod 10) (setq rewind nil))
)
(unload_dialog dcl_id)
(setvar "cmdecho" cmd)
(setq *error* olderr)
(princ)
)
;;;------------------------------------------------------


















DCL FILE
PLATE.DCL

dcl_settings : default_dcl_settings { audit_level = 3; }
@include "ihi2.dcl"

mode1 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate width"; width = 15; }
: edit_box { key = "wd"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate length"; width = 15; }
: edit_box { key = "len"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : button { label = "Weight";
key = "dummy";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = "kg"; }
}
}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
//fixed_width = true;
//width = 8;
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode2";
key = "mode2";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}

////////////////////////////////////////////////////////
mode2 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : button { label = " Area < ";
key = "pla";
mnemonic = "A";
fixed_width = true;
width = 6;

}
: edit_box { key = "area"; edit_width = 16; }
: text_part { label = "mm2"; }
}

: row
{ : button { label = "Weight";
key = "dummy1";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = " kg "; }
}
}
//: spacer {width = 2;}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode1";
key = "mode1";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About me";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}


/////////////



user_data : dialog
{ label = "Plate Data: ";
initial_focus = "ht";
: boxed_row
{

: list_box
{ label = "Std. Plate Thickness:" ;
//height = 10;
//width = 20;
key = "thk_list";
allow_accept = true;
}
}
spacer;
ok_cancel;
spacer;
}

////////////////////


data_select : dialog {
label = "Select Data : ";
initial_focus = "data";
: row {
: column {
spacer;
: concatenation {
: text_part {
label = "Material Name";
width = 25;
}
: text_part {
label = "Composition";
width = 15;
}
: text_part {
label = "Representative Material";
width = 30;
}
: text_part {
label = "Unit Wt.";
}
}
: list_box {
tabs = "25 40 70";
width = 80;
height = 12;
key = "data";
fixed_width = true;
allow_accept = true;
tab_truncate = true;
}
}
}
ok_cancel;
}
Luis Mestre
Oil&Gas Sr.3D & Subsea/Structural Designer
"Autodesk Autocad/Inventor & 3D Studio Max"
Email:lmsmestre@gmail.com
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: luismestre

there is a website you can use...

http://www.jindalstainless.com/toolkit/weight-calculator.html

aw



wrote in message news:5799180@discussion.autodesk.com...
Hi,
I've been try to contact the author with out sucess.
This routine lisp is a very a helpfull program to calculate plate weights.
But when I load it give all the time the same problem.
first, Says that " is not possible to find ihi2.dcl file", after that I
rename the file

"plate.dcl" to "ihi2.dcl", and after loading again show me this message
"Command:
Command: plate
Error: quit / exit abort
Command:"

I have my settings on the autocad options all correct (support and working
support file

search path).
Can any one with help me with this.

Regards
Luis Mestre

p.s.:
Below you can see the code for the "plate.lsp & plate.dcl" files.









LISP ROUTINE
PLATE.LSP



deem S. Legaspi Jr.
;; Saturday, March 06, 1999
;; Pasig, Manila, Philippines

(defun plate_error (s)
(if (/= s "console break")
(princ (strcat "Error: " s))
)
(done_dialog)
(unload_dialog dcl_id)
(setq *error* olderr)
(princ)
)

;;----------------------------------------------------------
;; Main function
(defun c:plate (/ cmd input rewind dia arya dum_lst mod pos1
com_secret_link)

(defun dimzin (val / digit return j)
(setq digit (rtos val 2 15) j 0)
(while (< j (strlen digit))
(if (= (setq return (substr digit (- (strlen digit) j) 1)) "0")
(setq j (1+ j))
(if (= return ".")
(progn
(setq return (substr digit 1 (- (strlen digit) (1- j))))
(setq j (strlen digit))
)
(progn
(setq return (substr digit 1 (- (strlen digit) j)))
(setq j (strlen digit))
)
)
)
)
(cond
((zerop (- val (fix val))) (rtos val 2 0))
(t return)
)
)

(defun calculate (/ val fn)
(setq fn (findfile "com.lsp"))
(cond
(fn (if (null dem_com_link) (load "com.lsp"))
(setq com_secret_link t)
(setq val (dem_com_link))
(if (eval val) (set_tile prev_key (dimzin (eval val))))
)
(t (alert "Cannot load COM.LSP (Calculator)."))
)
)

(defun reject (/ vl str)
(setq str (nth mt mat_typ) vl $value)
(if (/= str vl)
(progn
(alert "Cannot modify that data !\nYou must pick material
button.")
(set_tile "mat" str)
(mode_tile "mtb" 2)
(data_select)
)
)
)

(defun user ( / plt)
(if (not (new_dialog "user_data" dcl_id)) (exit))
(setq dum_lst nil)
(mapcar '(lambda (a)
(setq dum_lst (append dum_lst (list (strcat "Plate " a)))))
thk_lst)
(start_list "thk_list")
(mapcar 'add_list dum_lst)
(end_list)
(action_tile "thk_list" "(setq plt (atoi $value))")
(action_tile "cancel" "(setq plt nil) (done_dialog)")
(action_tile "accept" "(setq plt (read (get_tile \"thk_list\")))
(done_dialog)")
(start_dialog)
(if plt (set_tile "thk" (setq dtk (nth plt thk_lst))))
(compute mod)
)

(defun data_select (/ mtt)
(if (not (new_dialog "data_select" dcl_id)) (exit))
(start_list "data")
(mapcar 'add_list mat_des)
(end_list)
(set_tile "data" (itoa mt))
(action_tile "data" "(setq mtt (atoi $value))")
(action_tile "cancel" "(done_dialog)")
(action_tile "accept" "(setq mt (atoi (get_tile \"data\")))
(done_dialog)")
(start_dialog)
(set_tile "mat" (nth mt mat_typ))
(compute mod)
)

(defun about_me ()
(alert (strcat
"The author: Engr. Redem Legaspi Jr."
"\nProfession: Civil Engineer"
"\nHome/Tel.: Cebu City, Celphone - (063)0917 965 1030"
"\n\nNotes: "
"\n__________________________________________"
"\n\tThis program is undergoing neccesary"
"\n\tupdates. Any update made to this program"
"\n\twill be available to all legitimate users."
"\n\tInformation regarding such updates will"
"\n\tbe relayed by this programmer himself."
"\n__________________________________________"

)
)
)

(defun compute (md)
(if (= md 1) (compute_wt1))
(if (= md 2) (compute_wt2))
)
(defun pick_area (/ e ent enty)
(command "area" "0,0" "")
(setq e (entsel "\nPick a closed polyline: "))
(if e
(progn
(setq ent (entget (car e)))
(setq enty (cdr (assoc 0 ent)))
(if (or (= enty "POLYLINE") (= enty "LWPOLYLINE") (= enty
"REGION")(= enty

"CIRCLE")(= enty "ELLIPSE"))
(if e (command "area" "o" e))
(alert (strcat "Sorry, but " enty " does'nt have an area
!"))
)
)
(alert "No entity picked !")
)
)
(defun is_dot_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (= ch ".") (setq m (+ m 1)))
(setq n (+ n 1))
)
(if (> m 1) nil t)
)
(defun is_alp_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (not (equal ch ".")) (if (= (type (read ch)) 'SYM) (setq m (+ m
1))))
(setq n (+ n 1))
)
(if (> m 0) nil t)
)
(defun compute_wt2 ()
(setq area (atof (get_tile "area")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk area))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun compute_wt1 (/)
(setq len (atof (get_tile "len")))
(setq wd (atof (get_tile "wd")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk len wd))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun printv (val) (set_tile prev_key val))
(defun get_value (md / tmp)
(setq tmp $value)
(if (and (is_dot_valid tmp) (is_alp_valid tmp))
(cond
((not (distof tmp)) (setq input nil))
(t (setq input tmp))
)
(progn
(alert "Invalid input!\nPlease check...")
(setq input nil) (set_tile $key "")
)
)
(compute md)
)
;; Digit eraser function
(defun erase (mode)
(defun real_input ()
(setq ssnv (strlen input))
(if (or (= ssnv 1) (and (= ssnv 2) (minusp (atof input))))
(progn
(printv "0.")
(setq input nil)
)
(progn
(if (= (substr input (- ssnv 1) 1) (chr 46))
(setq ssnv (strlen
(setq input (substr input 1 (- ssnv 2)))
))
(setq input (substr input 1 (- ssnv 1)))
)
(if (= (type (read input)) 'INT)
(printv (strcat input (chr 46)))
(printv input)
)
)
)
(setq temp input)
)
(setq chlst nil n 1)
(if input
(while (/= (setq ch (substr input n 1)) "")
(setq chlst (append chlst (list (strcase ch))))
(setq n (+ n 1))
)
)
(if input (real_input))
)

(defun input_value (arg)
(if num
(if (or (numberp (read arg)) (= arg "dot"))
;;(if (<= lenv 20) (num_input arg))
(num_input arg)
)
)
)

(defun num_input (num)
(if (not input)
(if (and (/= num (chr 48)) (= num "dot"))
(setq input (strcat (chr 48) (chr 46)))
(setq input num)
)
(if (= num "dot")
(if (= (type (read input)) 'INT)
(setq input (strcat input (chr 46)))
)
(cond
((and (zerop (read num)) (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input (chr 48))
)
(t (if (and (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input num)
(setq input (strcat input num))
)
)
)
)
)
(printv input)
)

(defun get_dtk () (if (= prev_key "thk")(setq dtk (get_tile "thk"))))

;;;---------------------------------------------------------------------

(graphscr)
(setq olderr *error* *error* plate_error)
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq mat_data
(list
(list "Mild Carbon Steel\tC
0.35\tSS41,SM41,SF45,SS400,SM400\t7.85e-6" "Mild

Carbon Steel" 7.85e-6) ;1
(list "Forced Carbon Steel\tC 0.51~0.50\tSF55,S45C\t7.84e-6"
"Forced Carbon

Steel" 7.84e-6) ;2
(list "Hard Steel\tC 0.51\tS55C\t7.83e-6" "Hard Steel"
7.83e-6)

;3
(list "Low Alloy Steel\t- \tSNC836,SCM432\t7.83e-6" "Low Alloy
Steel"

7.83e-6) ;4
(list "NI.Mo Steel\t-\tSNCM439\t7.83e-6" "NI.Mo Steel"
7.83e-6)

;5
(list "Carbon Steel Casting\t-\tSC46\t7.84e-6" "Carbon Steel
Casting"

7.84e-6) ;6
(list "Iron Casting\t-\tFC25\t7.25e-6" "Iron Casting"
7.25e-6)

;7
(list "Stainless Steel(1)\t13 Cr\tSUS403,420J2\t7.75e-6"
"Stainless Steel(1)"

7.75e-6) ;8
(list "Stainless Steel(2)\t18 Cr, 8 Ni\tSUS304\t7.93e-6"
"Stainless Steel(2)"

7.93e-6) ;9
(list "Stainless Steel(3)\t-\tSUS329JI\t7.80e-6" "Stainless
Steel(3)"

7.80e-6) ;10
(list "Stainless Steel(4)\t-\tSUS316\t7.98e-6" "Stainless
Steel(4)" 7.98e-6)

;11
(list "Bronze(1)\t70 Cu, 30 Zn\tC2600P\t8.53e-6" "Bronze(1)"
8.53e-6)

;12
(list "Bronze(2)\t60 Cu, 40 Zn\tC2801P\t8.39e-6" "Bronze(2)"
8.39e-6)

;13
(list "Bronze Casting\t-\tBC3\t8.80e-6" "Bronze Casting"
8.80e-6)

;14
(list "Leaded Bronze Casting\t-\tLBC3\t8.90e-6" "Leaded Bronze
Casting"

8.90e-6) ;15
)
)
(setq mat_des nil mat_typ nil mat_uwt nil)
(foreach item mat_data
(progn
(setq mat_des (append mat_des (list (nth 0 item))))
(setq mat_typ (append mat_typ (list (nth 1 item))))
(setq mat_uwt (append mat_uwt (list (nth 2 item))))
)
)
(if (not (setq dcl_id (load_dialog "plate"))) (exit))
(setq rewind t)
(while rewind
(if (not mod) (setq mod 1))

(if (not (numberp mod)) (setq mod 1))

(if (= mod 3)
(progn
(setq mod 2)
(setq arya (getvar "area"))
)
)
(if (= mod 1) (setq dia "mode1"))
(if (= mod 2) (setq dia "mode2"))

(cond
(pos1 (if (not (new_dialog dia dcl_id "" pos1))(exit)))
(t (if (not (new_dialog dia dcl_id)) (exit)))
)

(if (not mt)(setq mt 0))

(if (not (numberp mt)) (setq mt 0))

(set_tile "mat" (nth mt mat_typ))
(start_list "prc")
(mapcar 'add_list
(list "0" "0.0" "0.00" "0.000" "0.0000" "0.00000"
"0.000000" "0.0000000" "0.00000000"
)
)
(setq thk_lst
(list "4.5" "6" "9" "12" "14" "16" "19" "22" "25" "28" "32" "36"
"40"
"50" "55" "60" "65" "70" "75" "80" "85" "90" "95" "100")
)
(end_list)

(if (not prc)
(progn
(setq prc (getvar "luprec"))
(set_tile "prc" (itoa prc))
)
(progn
(if (not (numberp prc)) (setq prc 0))

(set_tile "prc" (itoa prc))
)
)
(if (not dtk) (setq dtk "6"))

(if (not (numberp (distof dtk))) (setq dtk "6"))

(set_tile "thk" dtk)
(if (= mod 1) (mode_tile "wd" 2))
(if (= mod 2) (mode_tile "area" 2))
(if arya
(progn
(set_tile "area" (rtos arya 2 prc))
(compute mod)
(setq arya nil)
)
)
(setq num t)
(foreach n
(list "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "dot")
(action_tile n "(input_value $key) (compute mod)(get_dtk)")
)
(action_tile "back" "(erase mod) (compute mod) (get_dtk)")
(action_tile "wd"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"len\" 2))")
(action_tile "len"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"thk\" 2))")
(action_tile "thk"
"(setq dtk $value prev_key $key) (get_value mod)
(if (= $reason 1) (progn (mode_tile \"wd\" 2)(mode_tile \"area\"
2)))")
(action_tile "area"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"thk\" 2))")
(action_tile "clear" "(setq input nil) (printv \" \") (compute mod)
(get_dtk)")
(action_tile "prc" "(compute mod)")
(action_tile "dummy" "(compute mod)")
(action_tile "wt" "(compute mod)")
(action_tile "pla" "(setq pos1 (done_dialog 3))")
(action_tile "exit" "(setq pos1 (done_dialog 10))")
(action_tile "mode1" "(setq pos1 (done_dialog 1))")
(action_tile "mode2" "(setq pos1 (done_dialog 2))")
(action_tile "about" "(about_me)")
(action_tile "ptb" "(user)")
(action_tile "mat" "(reject)")
(action_tile "mtb" "(data_select)")
(action_tile "calc" "(calculate)(compute mod)")
(setq mod (start_dialog))
(if (= mod 3) (pick_area))
(if (= mod 10) (setq rewind nil))
)
(unload_dialog dcl_id)
(setvar "cmdecho" cmd)
(setq *error* olderr)
(princ)
)
;;;------------------------------------------------------


















DCL FILE
PLATE.DCL

dcl_settings : default_dcl_settings { audit_level = 3; }
@include "ihi2.dcl"

mode1 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate width"; width = 15; }
: edit_box { key = "wd"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate length"; width = 15; }
: edit_box { key = "len"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : button { label = "Weight";
key = "dummy";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = "kg"; }
}
}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
//fixed_width = true;
//width = 8;
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode2";
key = "mode2";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}

////////////////////////////////////////////////////////
mode2 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : button { label = " Area < ";
key = "pla";
mnemonic = "A";
fixed_width = true;
width = 6;

}
: edit_box { key = "area"; edit_width = 16; }
: text_part { label = "mm2"; }
}

: row
{ : button { label = "Weight";
key = "dummy1";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = " kg "; }
}
}
//: spacer {width = 2;}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode1";
key = "mode1";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About me";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}


/////////////



user_data : dialog
{ label = "Plate Data: ";
initial_focus = "ht";
: boxed_row
{

: list_box
{ label = "Std. Plate Thickness:" ;
//height = 10;
//width = 20;
key = "thk_list";
allow_accept = true;
}
}
spacer;
ok_cancel;
spacer;
}

////////////////////


data_select : dialog {
label = "Select Data : ";
initial_focus = "data";
: row {
: column {
spacer;
: concatenation {
: text_part {
label = "Material Name";
width = 25;
}
: text_part {
label = "Composition";
width = 15;
}
: text_part {
label = "Representative Material";
width = 30;
}
: text_part {
label = "Unit Wt.";
}
}
: list_box {
tabs = "25 40 70";
width = 80;
height = 12;
key = "data";
fixed_width = true;
allow_accept = true;
tab_truncate = true;
}
}
}
ok_cancel;
}
Message 3 of 4
Anonymous
in reply to: luismestre

In plate.dcl remove this line:
@include "ihi2.dcl"

and everything works...except the Calculator button.

Josh

wrote in message news:5799180@discussion.autodesk.com...
Hi,
I've been try to contact the author with out sucess.
This routine lisp is a very a helpfull program to calculate plate weights.
But when I load it give all the time the same problem.
first, Says that " is not possible to find ihi2.dcl file", after that I
rename the file

"plate.dcl" to "ihi2.dcl", and after loading again show me this message
"Command:
Command: plate
Error: quit / exit abort
Command:"

I have my settings on the autocad options all correct (support and working
support file

search path).
Can any one with help me with this.

Regards
Luis Mestre

p.s.:
Below you can see the code for the "plate.lsp & plate.dcl" files.









LISP ROUTINE
PLATE.LSP



deem S. Legaspi Jr.
;; Saturday, March 06, 1999
;; Pasig, Manila, Philippines

(defun plate_error (s)
(if (/= s "console break")
(princ (strcat "Error: " s))
)
(done_dialog)
(unload_dialog dcl_id)
(setq *error* olderr)
(princ)
)

;;----------------------------------------------------------
;; Main function
(defun c:plate (/ cmd input rewind dia arya dum_lst mod pos1
com_secret_link)

(defun dimzin (val / digit return j)
(setq digit (rtos val 2 15) j 0)
(while (< j (strlen digit))
(if (= (setq return (substr digit (- (strlen digit) j) 1)) "0")
(setq j (1+ j))
(if (= return ".")
(progn
(setq return (substr digit 1 (- (strlen digit) (1- j))))
(setq j (strlen digit))
)
(progn
(setq return (substr digit 1 (- (strlen digit) j)))
(setq j (strlen digit))
)
)
)
)
(cond
((zerop (- val (fix val))) (rtos val 2 0))
(t return)
)
)

(defun calculate (/ val fn)
(setq fn (findfile "com.lsp"))
(cond
(fn (if (null dem_com_link) (load "com.lsp"))
(setq com_secret_link t)
(setq val (dem_com_link))
(if (eval val) (set_tile prev_key (dimzin (eval val))))
)
(t (alert "Cannot load COM.LSP (Calculator)."))
)
)

(defun reject (/ vl str)
(setq str (nth mt mat_typ) vl $value)
(if (/= str vl)
(progn
(alert "Cannot modify that data !\nYou must pick material
button.")
(set_tile "mat" str)
(mode_tile "mtb" 2)
(data_select)
)
)
)

(defun user ( / plt)
(if (not (new_dialog "user_data" dcl_id)) (exit))
(setq dum_lst nil)
(mapcar '(lambda (a)
(setq dum_lst (append dum_lst (list (strcat "Plate " a)))))
thk_lst)
(start_list "thk_list")
(mapcar 'add_list dum_lst)
(end_list)
(action_tile "thk_list" "(setq plt (atoi $value))")
(action_tile "cancel" "(setq plt nil) (done_dialog)")
(action_tile "accept" "(setq plt (read (get_tile \"thk_list\")))
(done_dialog)")
(start_dialog)
(if plt (set_tile "thk" (setq dtk (nth plt thk_lst))))
(compute mod)
)

(defun data_select (/ mtt)
(if (not (new_dialog "data_select" dcl_id)) (exit))
(start_list "data")
(mapcar 'add_list mat_des)
(end_list)
(set_tile "data" (itoa mt))
(action_tile "data" "(setq mtt (atoi $value))")
(action_tile "cancel" "(done_dialog)")
(action_tile "accept" "(setq mt (atoi (get_tile \"data\")))
(done_dialog)")
(start_dialog)
(set_tile "mat" (nth mt mat_typ))
(compute mod)
)

(defun about_me ()
(alert (strcat
"The author: Engr. Redem Legaspi Jr."
"\nProfession: Civil Engineer"
"\nHome/Tel.: Cebu City, Celphone - (063)0917 965 1030"
"\n\nNotes: "
"\n__________________________________________"
"\n\tThis program is undergoing neccesary"
"\n\tupdates. Any update made to this program"
"\n\twill be available to all legitimate users."
"\n\tInformation regarding such updates will"
"\n\tbe relayed by this programmer himself."
"\n__________________________________________"

)
)
)

(defun compute (md)
(if (= md 1) (compute_wt1))
(if (= md 2) (compute_wt2))
)
(defun pick_area (/ e ent enty)
(command "area" "0,0" "")
(setq e (entsel "\nPick a closed polyline: "))
(if e
(progn
(setq ent (entget (car e)))
(setq enty (cdr (assoc 0 ent)))
(if (or (= enty "POLYLINE") (= enty "LWPOLYLINE") (= enty
"REGION")(= enty

"CIRCLE")(= enty "ELLIPSE"))
(if e (command "area" "o" e))
(alert (strcat "Sorry, but " enty " does'nt have an area
!"))
)
)
(alert "No entity picked !")
)
)
(defun is_dot_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (= ch ".") (setq m (+ m 1)))
(setq n (+ n 1))
)
(if (> m 1) nil t)
)
(defun is_alp_valid (val / m n ch)
(setq n 1 m 0)
(while (/= (setq ch (substr val n 1)) "")
(if (not (equal ch ".")) (if (= (type (read ch)) 'SYM) (setq m (+ m
1))))
(setq n (+ n 1))
)
(if (> m 0) nil t)
)
(defun compute_wt2 ()
(setq area (atof (get_tile "area")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk area))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun compute_wt1 (/)
(setq len (atof (get_tile "len")))
(setq wd (atof (get_tile "wd")))
(setq mat (nth mt mat_uwt))
(setq thk (atof (get_tile "thk")))
(setq weight (* mat thk len wd))
(setq prc (atoi (get_tile "prc")))
(set_tile "wt" (rtos weight 2 prc))
)
(defun printv (val) (set_tile prev_key val))
(defun get_value (md / tmp)
(setq tmp $value)
(if (and (is_dot_valid tmp) (is_alp_valid tmp))
(cond
((not (distof tmp)) (setq input nil))
(t (setq input tmp))
)
(progn
(alert "Invalid input!\nPlease check...")
(setq input nil) (set_tile $key "")
)
)
(compute md)
)
;; Digit eraser function
(defun erase (mode)
(defun real_input ()
(setq ssnv (strlen input))
(if (or (= ssnv 1) (and (= ssnv 2) (minusp (atof input))))
(progn
(printv "0.")
(setq input nil)
)
(progn
(if (= (substr input (- ssnv 1) 1) (chr 46))
(setq ssnv (strlen
(setq input (substr input 1 (- ssnv 2)))
))
(setq input (substr input 1 (- ssnv 1)))
)
(if (= (type (read input)) 'INT)
(printv (strcat input (chr 46)))
(printv input)
)
)
)
(setq temp input)
)
(setq chlst nil n 1)
(if input
(while (/= (setq ch (substr input n 1)) "")
(setq chlst (append chlst (list (strcase ch))))
(setq n (+ n 1))
)
)
(if input (real_input))
)

(defun input_value (arg)
(if num
(if (or (numberp (read arg)) (= arg "dot"))
;;(if (<= lenv 20) (num_input arg))
(num_input arg)
)
)
)

(defun num_input (num)
(if (not input)
(if (and (/= num (chr 48)) (= num "dot"))
(setq input (strcat (chr 48) (chr 46)))
(setq input num)
)
(if (= num "dot")
(if (= (type (read input)) 'INT)
(setq input (strcat input (chr 46)))
)
(cond
((and (zerop (read num)) (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input (chr 48))
)
(t (if (and (zerop (read input))
(= (type (read input)) 'INT)
)
(setq input num)
(setq input (strcat input num))
)
)
)
)
)
(printv input)
)

(defun get_dtk () (if (= prev_key "thk")(setq dtk (get_tile "thk"))))

;;;---------------------------------------------------------------------

(graphscr)
(setq olderr *error* *error* plate_error)
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq mat_data
(list
(list "Mild Carbon Steel\tC
0.35\tSS41,SM41,SF45,SS400,SM400\t7.85e-6" "Mild

Carbon Steel" 7.85e-6) ;1
(list "Forced Carbon Steel\tC 0.51~0.50\tSF55,S45C\t7.84e-6"
"Forced Carbon

Steel" 7.84e-6) ;2
(list "Hard Steel\tC 0.51\tS55C\t7.83e-6" "Hard Steel"
7.83e-6)

;3
(list "Low Alloy Steel\t- \tSNC836,SCM432\t7.83e-6" "Low Alloy
Steel"

7.83e-6) ;4
(list "NI.Mo Steel\t-\tSNCM439\t7.83e-6" "NI.Mo Steel"
7.83e-6)

;5
(list "Carbon Steel Casting\t-\tSC46\t7.84e-6" "Carbon Steel
Casting"

7.84e-6) ;6
(list "Iron Casting\t-\tFC25\t7.25e-6" "Iron Casting"
7.25e-6)

;7
(list "Stainless Steel(1)\t13 Cr\tSUS403,420J2\t7.75e-6"
"Stainless Steel(1)"

7.75e-6) ;8
(list "Stainless Steel(2)\t18 Cr, 8 Ni\tSUS304\t7.93e-6"
"Stainless Steel(2)"

7.93e-6) ;9
(list "Stainless Steel(3)\t-\tSUS329JI\t7.80e-6" "Stainless
Steel(3)"

7.80e-6) ;10
(list "Stainless Steel(4)\t-\tSUS316\t7.98e-6" "Stainless
Steel(4)" 7.98e-6)

;11
(list "Bronze(1)\t70 Cu, 30 Zn\tC2600P\t8.53e-6" "Bronze(1)"
8.53e-6)

;12
(list "Bronze(2)\t60 Cu, 40 Zn\tC2801P\t8.39e-6" "Bronze(2)"
8.39e-6)

;13
(list "Bronze Casting\t-\tBC3\t8.80e-6" "Bronze Casting"
8.80e-6)

;14
(list "Leaded Bronze Casting\t-\tLBC3\t8.90e-6" "Leaded Bronze
Casting"

8.90e-6) ;15
)
)
(setq mat_des nil mat_typ nil mat_uwt nil)
(foreach item mat_data
(progn
(setq mat_des (append mat_des (list (nth 0 item))))
(setq mat_typ (append mat_typ (list (nth 1 item))))
(setq mat_uwt (append mat_uwt (list (nth 2 item))))
)
)
(if (not (setq dcl_id (load_dialog "plate"))) (exit))
(setq rewind t)
(while rewind
(if (not mod) (setq mod 1))

(if (not (numberp mod)) (setq mod 1))

(if (= mod 3)
(progn
(setq mod 2)
(setq arya (getvar "area"))
)
)
(if (= mod 1) (setq dia "mode1"))
(if (= mod 2) (setq dia "mode2"))

(cond
(pos1 (if (not (new_dialog dia dcl_id "" pos1))(exit)))
(t (if (not (new_dialog dia dcl_id)) (exit)))
)

(if (not mt)(setq mt 0))

(if (not (numberp mt)) (setq mt 0))

(set_tile "mat" (nth mt mat_typ))
(start_list "prc")
(mapcar 'add_list
(list "0" "0.0" "0.00" "0.000" "0.0000" "0.00000"
"0.000000" "0.0000000" "0.00000000"
)
)
(setq thk_lst
(list "4.5" "6" "9" "12" "14" "16" "19" "22" "25" "28" "32" "36"
"40"
"50" "55" "60" "65" "70" "75" "80" "85" "90" "95" "100")
)
(end_list)

(if (not prc)
(progn
(setq prc (getvar "luprec"))
(set_tile "prc" (itoa prc))
)
(progn
(if (not (numberp prc)) (setq prc 0))

(set_tile "prc" (itoa prc))
)
)
(if (not dtk) (setq dtk "6"))

(if (not (numberp (distof dtk))) (setq dtk "6"))

(set_tile "thk" dtk)
(if (= mod 1) (mode_tile "wd" 2))
(if (= mod 2) (mode_tile "area" 2))
(if arya
(progn
(set_tile "area" (rtos arya 2 prc))
(compute mod)
(setq arya nil)
)
)
(setq num t)
(foreach n
(list "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "dot")
(action_tile n "(input_value $key) (compute mod)(get_dtk)")
)
(action_tile "back" "(erase mod) (compute mod) (get_dtk)")
(action_tile "wd"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"len\" 2))")
(action_tile "len"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"thk\" 2))")
(action_tile "thk"
"(setq dtk $value prev_key $key) (get_value mod)
(if (= $reason 1) (progn (mode_tile \"wd\" 2)(mode_tile \"area\"
2)))")
(action_tile "area"
"(setq prev_key $key) (get_value mod)(if (= $reason 1) (mode_tile
\"thk\" 2))")
(action_tile "clear" "(setq input nil) (printv \" \") (compute mod)
(get_dtk)")
(action_tile "prc" "(compute mod)")
(action_tile "dummy" "(compute mod)")
(action_tile "wt" "(compute mod)")
(action_tile "pla" "(setq pos1 (done_dialog 3))")
(action_tile "exit" "(setq pos1 (done_dialog 10))")
(action_tile "mode1" "(setq pos1 (done_dialog 1))")
(action_tile "mode2" "(setq pos1 (done_dialog 2))")
(action_tile "about" "(about_me)")
(action_tile "ptb" "(user)")
(action_tile "mat" "(reject)")
(action_tile "mtb" "(data_select)")
(action_tile "calc" "(calculate)(compute mod)")
(setq mod (start_dialog))
(if (= mod 3) (pick_area))
(if (= mod 10) (setq rewind nil))
)
(unload_dialog dcl_id)
(setvar "cmdecho" cmd)
(setq *error* olderr)
(princ)
)
;;;------------------------------------------------------


















DCL FILE
PLATE.DCL

dcl_settings : default_dcl_settings { audit_level = 3; }
@include "ihi2.dcl"

mode1 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate width"; width = 15; }
: edit_box { key = "wd"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : text_part { label = " Plate length"; width = 15; }
: edit_box { key = "len"; edit_width = 16; }
: text_part { label = "mm "; }
}
: row
{ : button { label = "Weight";
key = "dummy";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = "kg"; }
}
}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
//fixed_width = true;
//width = 8;
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode2";
key = "mode2";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}

////////////////////////////////////////////////////////
mode2 : dialog
{ label = "Plate Weight Calculator";
initial_focus = "wd";
: boxed_row
{ : boxed_column
{ : row
{ : text_part { label = " Precision"; width =5; }
: popup_list { key = "prc"; edit_width = 20; }
}
: row
{ : button
{ label = "Material...";
key = "mtb";
mnemonic = "M";
fixed_width = true;
width = 7;
}
: edit_box { key = "mat"; edit_width = 20; }
}
: row
{ : button
{ label = "Thickness";
key = "ptb";
mnemonic = "P";
fixed_width = true;
width = 6;
}
: edit_box { key = "thk"; edit_width = 15; }
: text_part { label = "mm "; }
}
: row
{ : button { label = " Area < ";
key = "pla";
mnemonic = "A";
fixed_width = true;
width = 6;

}
: edit_box { key = "area"; edit_width = 16; }
: text_part { label = "mm2"; }
}

: row
{ : button { label = "Weight";
key = "dummy1";
mnemonic = "W";
fixed_width = true;
width = 6;

}
: edit_box { key = "wt"; edit_width = 16; }
: text_part { label = " kg "; }
}
}
//: spacer {width = 2;}
: boxed_column
{
: row
{ fixed_width = true;
: button
{ label = "7";
key = "7";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "8";
key = "8";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "9";
key = "9";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "4";
key = "4";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "5";
key = "5";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "6";
key = "6";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "1";
key = "1";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "2";
key = "2";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "3";
key = "3";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ fixed_width = true;
: button
{ label = "0";
key = "0";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = ".";
key = "dot";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
: button
{ label = "<-";
key = "back";
fixed_width = true;
width = 6;
aspect_ratio = 0;
}
}
: row
{ //fixed_width = true;
: button
{ label = "Clear";
key = "clear";
aspect_ratio = 0;
}
}
}
}
spacer;
: row
{ //fixed_width = true;
: button
{ label = "Mode1";
key = "mode1";
aspect_ratio = 0;
}
: button
{ label = "Calculator";
key = "calc";
aspect_ratio = 0;
}
: button
{ label = " Exit ";
key = "exit";
is_cancel = true;
aspect_ratio = 0;
}
: button
{ label = "About me";
key = "about";
aspect_ratio = 0;
}
}

spacer;
}


/////////////



user_data : dialog
{ label = "Plate Data: ";
initial_focus = "ht";
: boxed_row
{

: list_box
{ label = "Std. Plate Thickness:" ;
//height = 10;
//width = 20;
key = "thk_list";
allow_accept = true;
}
}
spacer;
ok_cancel;
spacer;
}

////////////////////


data_select : dialog {
label = "Select Data : ";
initial_focus = "data";
: row {
: column {
spacer;
: concatenation {
: text_part {
label = "Material Name";
width = 25;
}
: text_part {
label = "Composition";
width = 15;
}
: text_part {
label = "Representative Material";
width = 30;
}
: text_part {
label = "Unit Wt.";
}
}
: list_box {
tabs = "25 40 70";
width = 80;
height = 12;
key = "data";
fixed_width = true;
allow_accept = true;
tab_truncate = true;
}
}
}
ok_cancel;
}
Message 4 of 4
Anonymous
in reply to: luismestre

Hello Luis,

You need to include "ihi2.dcl" to run the program. The author missed to include this files in the package... but this can be found on his other programs. PLEASE TRY TO DOWNLOAD HIS AUTOCAD SCIENTIFIC CALCULATOR. "ihi2.dcl" is included there...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Administrator Productivity


Autodesk Design & Make Report