I know this is a really simple routine, if someone could help me out I'd be very appreciative. Here is the formula I would like to use:
(166.24 / X squared) * area of selected polyline. An example for clarity, if X is 12 and the area of the selected polyline was 100, it would be (166.24 / 144) * 100 = 115.
I would like to issue the command, enter the number for X, pick the polyline, and have the resultant whole number (no decimals) output on the command line. I would like it to remember whatever X is (for that drawing session) until I change it so that I can enter past that question if I'm not changing it.
Thanks again if you can help!
Solved! Go to Solution.
Solved by mid-awe. Go to Solution.
@mid-awe wrote:I've been studying your "Object Align" code. I see you used "oa|rot" & "oa|off", two globals.
I thought it was good practice to wrap globals in **?
It is good practice to enclose global variables inside asterisks in so much as the resulting symbols are more obscure and less likely to conflict with other symbols defined in the document namespace; however, this is the only purpose of the asterisks - it is not mandatory to use asterisks for all global variables.
In general, you can use any global variable naming convention which ensures a low probability that the symbol is not already defined in the document namespace by another program. The suggestion of using asterisks is a good tip for beginners when first introduced to global variables, without getting into the details.
I have used several variations for globals in the past - some with asterisks, some with vertical bars (as you have noted), and most recently I now tend to use the function symbol as a prefix, followed by a semi-colon, e.g.:
(defun c:af ( / a e ) (setq af:x (cond ((getreal (strcat "\nX-Value <" (rtos (cond(af:x)(100)) 2) ">: ")))(af:x)(100))) (if (setq e (car (entsel))) (if (vl-catch-all-error-p (setq a (vl-catch-all-apply 'vlax-curve-getarea (list e)))) (princ "\nInvalid object.") (princ (strcat "\nResult: " (itoa (fix (* a (/ 166.24 af:x af:x)))))) ) ) (princ) ) (vl-load-com) (princ)
@Anonymous wrote:
Hi Lee_Mac,
Special Thanks to you.
You will always have another way of coding which is out of Box.
Thank you aliensinearth