That is awesome, me likey, me likey....one last quick favor, can you make the output
be in KG. Your a lifesaver, I do this calculation daily.
Printable View
That is awesome, me likey, me likey....one last quick favor, can you make the output
be in KG. Your a lifesaver, I do this calculation daily.
I have modified the code. Just download the attachment in this post again.Quote:
Originally Posted by rhall.72202
I have the command line autohide. Is there a way to display an autocad
text window at the end of this routine? I have to keep checking the
command line after running the routine.
At the end of the lisp routine there is a section of code that looks like this
If you change where it says prompt to alert then this will display an autocad message box with the weight calculations. Code should look like below for autocad message box to display.Code:(prompt ; return calculated weight
(strcat "Weight (for "
inpMat
"; density "
(rtos usedDensity 2 4)
") is estimated to be:\n"
(rtos (getvar "UserR2") 2 4)
" pounds, "
(rtos (getvar "UserR3") 2 4)
" kilograms.\n"))))
(princ))
Code:(alert ; return calculated weight
(strcat "Weight (for "
inpMat
"; density "
(rtos usedDensity 2 4)
") is estimated to be:\n"
(rtos (getvar "UserR2") 2 4)
" pounds, "
(rtos (getvar "UserR3") 2 4)
" kilograms.\n"))))
(princ))
That works, however, if I click ok, then it is gone. I would have to run the routineQuote:
Originally Posted by Lions60
again. It is still nice to scroll back through the command line if I want to look
up the numbers again. Is there a way to invoke the Autocad command window?
What about
Could this be used somehow? I am not sure what to do here.Code:(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
Change the (alert) back to (prompt) and add this code to the end of your routine...
That will bring up the text screen when the routine finishes.Code:(command "_.textscr")
Edit: Misunderstood the request... Changed from command line to text screen coming up...
Thanks. That works out nicely. I will have to remember that for some of my other routines.
Note Some time you need to click to get the status line to up dateCode:;;John W. Anstaett 06/28/2007
;;Tested in ADT 2007 should work in other rev.
;; this list add 3 commands to Autocad
;;command Setth
;; set the Theckness
;;command Startarea
;; start the Weight program
;; it display the weight and theckness on the status line
;; using the last area command you use
;; and change each time you do a area command
;;command endarea
;; set the status line back to the way it was
(vl-load-com)
;;this should be the first line in all program that use ActiveX
;;This function loads the extended AutoLISP functions
;;provided with Visual LISP. The Visual LISP extensions implement
;;ActiveX and AutoCAD reactor support through AutoLISP, and also
;;provide ActiveX utility and data conversion functions,
;;dictionary handling functions, and curve measurement functions.
(DEFUN C:SETTH()
(setvar "userr1" (distof (INPUTBOX "Enter Stell Thickness mm" "John W. Anstaett InputBox")))
)
(defun c:StartArea()
(setq SaveModemacro (getvar "mademacro"))
(setvar "MODEMACRO" "$(*,$(/,$(getvar,area), $(getvar,userr1)) , 0.2833):th=$(getvar,userr1)")
)
(defun c:EndArea()
(if modemacro
(setvar "modemacro" saveModemacro)
(setvar "modemacro" "")
)
)
;;Functuion inputbox
;;input
;; myprompt is the text for the prompt
;; mytitle is the text for the title
;; system variable users1 is used for the default input
;; return the text enter in the box
;; and system variable users1 is set then the same
(defun inputbox (myprompt mytitle / myapp)
(setq myapp (vlax-get-acad-object))
(vla-eval myapp "myappz = ThisDrawing.GetVariable( \"users1\")")
(vla-eval myapp (strcat "myappy = inputbox(\"" myprompt "\",\"" mytitle "\", myappz)"))
(vla-eval myapp "ThisDrawing.SetVariable \"users1\", myappy")
(getvar "users1")
)
Hello, I am needing something very similar to this. I copied and pasted into my lsp file and it won't run the command. I need it to calculate steel weight, using inches and pounds. Any help will be greatly appreciated. I am very low level in programming so something simple to your eye I may not be able to catch. When i load the lisp file i get:
Command: ; error: no function definition: POUNDS
Thanks.
Witch code did you copy and pasted.
If the error come up when you are loading the lisp file the you did not copy and pasted the code right.Try to save the file and load it, no need to copy and past. You my be missing a ( ) or " in the code you copped.
If it was my code to display the weight and theckness on the status line.
The command is Startarea. Then you need to do a area command.
Use the command Setth to set the Theckness
Use the command endarea to set the status line back to the way it was.
If it was the CalcWt.lsp by Written by: R. Robert Bell the command is CalcWt.