ryankevin15 Posted April 6, 2017 Share Posted April 6, 2017 Okay, here's the deal. I need a LISP that calculates phase balance which is basically percent error between two numbers in the following form. However, we need it to take a selection and find the largest number, smallest number and make the following calculation, regardless of the numbers in the set. (Big - Small)/Big * 100 = X.X% Currently, we use an ADD.LSP which takes a selection and adds up the numbers. I am not familiar enough with the programming in order to take this relatively simple arithmetic and make it a working LSP. I have attached the ADD command if anyone is able to do something like this. add.LSP It should work by making a selection, then prompting the user to select where to place the phase balance (By adjusting the selected text to the updated value X.X%). Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted April 6, 2017 Author Share Posted April 6, 2017 In the image above. This program, if I can ever get it to work, would work by selecting all three numbers, hitting spacebar and then selecting the number next to phase balance, and then hitting spacebar again. Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 6, 2017 Share Posted April 6, 2017 If you look in the lower right hand corner of the post you want to edit you should see the words Edit Post. Click on the phrase. Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 6, 2017 Share Posted April 6, 2017 That option is not available to me. Ah...the ten post minimum strikes again. Sorry. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted April 7, 2017 Share Posted April 7, 2017 Try this: (defun KGA_Conv_Pickset_To_ObjectList (ss / i ret) (if ss (repeat (setq i (sslength ss)) (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret)) ) ) ) (defun c:PhaseBalance ( / ss numLst numMin numMax res trg) (if (and (princ "\nSelect source entities: ") (setq ss (ssget '((0 . "TEXT") (1 . "~*[~-.0-9]*") (1 . "~*`.*`.*") (1 . "~?*-*")))) (setq trg (car (entsel "\nSelect target entity: "))) (= "AcDbText" (vla-get-objectname (setq trg (vlax-ename->vla-object trg)))) ) (progn (setq numLst (mapcar '(lambda (obj) (read (vla-get-textstring obj))) (KGA_Conv_Pickset_To_ObjectList ss) ) ) (setq numMin (apply 'min numLst)) (setq numMax (apply 'max numLst)) ;; Formula: (Big - Small)/Big * 100 = X.X% (setq res (strcat (rtos (/ (- numMax numMin) numMax 0.01) 2 1) "%")) (princ (strcat "\nPhase Balance: " res)) (vla-put-textstring trg res) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted April 7, 2017 Author Share Posted April 7, 2017 Can you make one that takes a total wattage from a panel and divides it by 360 to find the amperage? I'd call it like 360 or something. Wow, still very amazed that you coded that! Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted April 22, 2017 Author Share Posted April 22, 2017 (edited) Roy_043, Could you potentially make a lisp that takes a value (total demand in Watts) and divide by 360 for 208V for total demand amps? Also, when using 480V we divide by 831. These two lisps will make things much quicker. And also, in the phase balance lips, is there any rounding applied to that value? Did you make the phase balance one yourself or just happened to already have it? Edited April 26, 2017 by ryankevin15 Quote Link to comment Share on other sites More sharing options...
BKT Posted April 25, 2017 Share Posted April 25, 2017 Roy_043, Could you potentially make a lisp that takes a value (total demand in Watts) and divide by 360 for 208V for total demand amps? Also, when using 480V we divide by 831. These two lisps will make things much quicker. And also, in the phase balance lips, is there any rounding applied to that value? Did you make the phase balance one yourself or just happened to already have it? If you just want to change the decimal place accuracy of the output, take a look at the RTOS function in Roy_043's code. http://ronleigh.com/autolisp/afude12.htm#rtos Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.