I am wondering if someone could help me with a lisp routine. I want to calculate GPM from two known factors. The formula I use is GPM = Q x √S, where Q is a factor and S is the slope. I want to be able to type a command, then be prompted to enter Q and then be prompted for S. I am not sure exactly how to go about this.
Solved! Go to Solution.
Perhaps the simplest routine would be:
(defun c:gpm ( / q s ) (initget 3) (setq q (getreal "\nSpecify Q: ")) (initget 7) (setq s (getreal "\nSpecify S: ")) (princ (* q (sqrt s))) (princ) )
Thanks alot! That works great. I hope to use this to learn a little more about AutoLisp, and perhaps modify it to accomplish other calcs. Thanks.
You're very welcome tommcgtx
As I say, the code I posted is probably the most simple way to construct the routine whilst still incorporating all the error trapping required - though it could be expanded a great deal further.
To help you understand the code, I would suggest that you study each of the functions being used - the best reference is the Visual LISP IDE Help Documentation - for information on how to access this documentation, see my short tutorial here.
If you aren't already using the Visual LISP IDE provided with AutoCAD to write your LISP programs, I would strongly recommend it, since it provides all the syntax highlighting for AutoLISP, Visual LISP and DCL, and the best debugging utilities for AutoLISP among code editors. To help you get started with it, I have also written an introductory tutorial which may be of some help.
I hope this helps,
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.