Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/09/2021 in all areas

  1. You could try this and see what you think, the prompts in the command line should guide you. the output is a table of mtexts. You mentioned doing a recalculation if the selected wire gauge isn't quite right - that should be easy to do but for another day maybe As always if anyone wants to rip the LISP to pieces and let me know a better way to do things, always appreciated. So try this as a start, command is vdcalc ;;;Building Blocks copied from other stuff;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;http://www.turvill.com/t2/free_stuff/tlen.lsp ;;TLEN Sum line lengths (defun TLEN (/ ss tl n ent itm obj l) ;;;-GETS TOTAL LENGTH OF SELECTED LINES, POLYLINES AND SO ON-;;; (setq ss (ssget '((-4 . "<OR")(0 . "LINE")(0 . "LWPOLYLINE")(0 . "ELLIPSE")(0 . "LWPOLYLINE")(0 . "SPLINE")(-4 . "OR>")) ) tl 0 n (1- (sslength ss)) ) (while (>= n 0) (setq ent (entget (setq itm (ssname ss n))) obj (cdr (assoc 0 ent)) l (cond ((= obj "LINE") (distance (cdr (assoc 10 ent))(cdr (assoc 11 ent)))) ((= obj "ARC") (* (cdr (assoc 40 ent)) (if (minusp (setq l (- (cdr (assoc 51 ent)) (cdr (assoc 50 ent))))) (+ pi pi l) l))) ((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE") (= obj "LWPOLYLINE")(= obj "ELLIPSE")) (command "_.area" "_o" itm) (getvar "perimeter")) (T 0)) tl (+ tl l) n (1- n) ) ) tl ;;returns tl, total length ) (defun getfroment (ent listorstring entcodes / acount acounter mytext newtext stringtext) ;;;-Gets text string from a selected entity (text, mtext, block, dimension etc)-;;; ;;;-It won't remove formatting codes in for example mtexts.. which is why output table is mtexts....-;;; ;;get dotted pairs list (setq entlist (entget ent)) (setq acount 0) (while (< acount (length entlist)) (setq acounter 0) (while (< acounter (length entcodes)) (setq entcode (nth acounter entcodes)) (if (= (car (nth acount entlist)) entcode ) (progn (setq newtext (cdr (nth acount entlist))) (if (numberp newtext)(setq newtext (rtos newtext))) ;fix for real numbers (setq mytext (append mytext (list (cons (car (nth acount entlist)) newtext) )) ) );end progn );end if (setq acounter (+ acounter 1)) );end while (setq acount (+ acount 1)) );end while ;;get string from dotted pair lists (if (= listorstring "astring") ;convert to text (progn (if (> (length mytext) 0) (progn (setq acount 0) (setq temptext "") (while (< acount (length mytext)) (setq temptext (cdr (nth acount mytext)) ) (if (= stringtext nil) (setq stringtext temptext) (setq stringtext (strcat stringtext temptext )) );end if (setq acount (+ acount 1)) );end while );end progn );end if (if (= stringtext nil)(setq stringtext "")) (setq mytext stringtext) );end progn );end if mytext ) ;;get text (defun gettext( message / ent1 entlist1 entcodes1 text01) (setq ent1 (getent message)) (setq entlist1 (entget ent1)) (setq entcodes1 (list 3 4 1 172 304) ) ;list of ent codes containing text. (if (= (cdr (assoc 0 entlist1)) "DIMENSION") (setq entcodes1 (list 4 1 172 304) )) ;;if dimension (setq text01 (getfroment ent1 "astring" entcodes1) ) ;Text as string text01 ) ;;;;end of building blocks;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Only does loop for a single circuit (defun c:vdcalc( / mysource mystartvolts mycircuitname wireresistances mywiresize mycircuit mydevice mydevicecurrent nomuttvar linelengths acount nextdevice circuitcount myresults drop totvd) ;;initial conditions. Note no error checking and so on. (setq circuitcount 1) (setq acount 1) (setq nextdevice "Y") (setq mycircuit (list (list "Circuit Name" "From" "Circuit Volts" "Wire Size" "Circuit Length" "To" "Device Current" "Volt Drop" "End volts")) ) (setq totcurrent 0) (setq wireresistances (list (cons 12 2.01) (cons 14 3.19) (cons 16 5.08) (cons 18 8.08) (cons 22 16.14))) ;;Set up system details (setq mysource (gettext "\nSelect Panel Name")) (setq mystartvolts (getreal "\nEnter Supply Terminal Volts ")) ;;;- see below for mywiresize if you want to limit circuit voltage to a set amount how to do that-;;; ;;circuit details (setq mycircuitname (getstring t "\nEnter Circuit Name/Number ")) ;;;-wire sizes-;;; ;;;-assumes same wire size for the circuit-;;; (initget "12 14 16 18 22") (setq mywiresize (atof (getkword "\nEnter Circuit Wire Gauge [12/14/16/18/22] "))) ;;getkword so initget works ;;Loop for circuit (while (= nextdevice "Y") (setq nomuttvar (getvar "nomutt")) (princ (strcat "\nSelect Lines, to device " (rtos acount 2 0) ", then press enter " ))(setvar "nomutt" 1) (setq linelengths (tlen)) (setvar "nomutt" nomuttvar) (setq mydevice (gettext (strcat "\nSelect device " (rtos acount 2 0) " name"))) (setq mydevicecurrent (getreal "\nEnter Current Draw: ") ) (setq totcurrent (+ totcurrent mydevicecurrent )) (setq mycircuit (append mycircuit (list (list mycircuitname mysource (rtos mystartvolts 2 2) (rtos mywiresize 2 0) (rtos linelengths) mydevice (rtos mydevicecurrent 2 3) )) )) (initget "Y N YES NO") (setq nextdevice (strcase (getstring "\nSelect another device [Y/N]")) ) (setq acount (+ acount 1)) ) (setq myresults (list (nth 0 mycircuit))) (setq acount 1) (setq totvd 0) (while (< acount (length mycircuit)) (setq res (cdr (assoc (atof (nth 3 (nth acount mycircuit))) wireresistances) )) (setq dist (atof (nth 4 (nth acount mycircuit)))) ;;;-Calculation-;;; ;;;-from BigAl-;;; (setq drop (* totcurrent (* res (/ (* dist 2.0) 1000.0)))) (setq totvd (+ totvd drop)) (setq endvolts (- (atof (nth 2 (nth acount mycircuit))) totvd) ) (setq myresults (append myresults (list (append (nth acount mycircuit) (list (rtos drop 2 3)) (list (rtos endvolts 2 3))) ))) (setq acount (+ acount 1)) ) (setq myresults (append myresults (list (list "" "" "" "" "" "" "Total Volt Drop:" (rtos totvd) )) )) ;;Make up a table - just mtext, nothing fancy (setq pt (getpoint "Enter table Insertion Point")) (setq pt1 pt) (setq acount 0) (while (< acount (length myresults)) (setq acounter 0) (while (< acounter (length (nth acount myresults)) ) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (cons 10 pt1) '(40 . 2.5) (cons 1 (nth acounter (nth acount myresults))) )) (setq pt1 (list (+ (nth 0 pt1) 25) (nth 1 pt1) (nth 2 pt1))) (setq acounter (+ acounter 1)) ) (setq pt1 (list (nth 0 pt) (- (nth 1 pt1) 7.5) (nth 2 pt))) (setq acount (+ acount 1)) ) (princ) )
    1 point
  2. Something like this This is a line by line as if typing and adding each * / last line is the one actually used ((Distance (ft.) x 2) / 1000) x (User Defined Wire Resistance in Ohms (Ω)) x (Current draw of all appliances in circuit (V)) = Volts (V) dropped at D (setq drop (* dist 2.0)) (setq drop (/ (* dist 2.0) 1000.0)) (setq drop (* res(/ (* dist 2.0) 1000.0))) (setq drop (* totcurrent (* res(/ (* dist 2.0) 1000.0)))) Ok but need totcurrent which would be total of the current draw maybe from selecting a block/s. Do you just want a answer ? Then pick a AWG. There is no elec code backing this its an example of a answer choice. You need to post more info.
    1 point
×
×
  • Create New...