trying to do a lisp routine- help
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
trying to do a lisp routine- help

 
Post new topic   Reply to topic    CADForums.net Forum Index -> AutoCAD
Author Message
mdsc
Guest





Posted: Wed Oct 19, 2005 8:10 pm    Post subject: trying to do a lisp routine- help Reply with quote

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.

Back to top
mdsc
Guest





Posted: Wed Oct 19, 2005 8:10 pm    Post subject: Re: trying to do a lisp routine- help Reply with quote

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;

}

}
Back to top
Michael Bulatovich
Guest





Posted: Wed Oct 19, 2005 8:10 pm    Post subject: Re: trying to do a lisp routine- help Reply with quote

Show us the code you've got so far.
--


MichaelB
www.michaelbulatovich.ca

"mdsc" <mdsc@comcast.net> wrote in message
news:QpGdnfPEB883AcveRVn-rQ@comcast.com...
Quote:
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.



Back to top
mdsc
Guest





Posted: Thu Oct 20, 2005 4:10 pm    Post subject: Re: trying to do a lisp routine- help Reply with quote

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)

)

"mdsc" <mdsc@comcast.net> wrote in message
news:QpGdnfPEB883AcveRVn-rQ@comcast.com...
Quote:
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.

Back to top
Bill Le Couteur
Guest





Posted: Fri Oct 21, 2005 8:10 am    Post subject: Re: trying to do a lisp routine- help Reply with quote

Hi
"mdsc" <mdsc@comcast.net> wrote in message
news:QpGdnfPEB883AcveRVn-rQ@comcast.com...
Quote:
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.



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)
)
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> AutoCAD All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB