As a start try this. It will accept LWPolylines 2dPolylines and Lines. The lisp checks the "insunits" system variable and converts polyline lengths to metres. You are then asked to supply the number of items for each of "HEATER" "LAMP" "MOTOR" "SOCKET" & "TV" to calculate the total load. The default for each is 0 (zero) so a return will automatically default to this. If no polyline/Line is selected the lisp ends.
(defun c:vdrop ( / *error* sv_lst sv_vals a_lst RL I iu cu sv itxt load ipart sel obj p_len ld vd len)
(defun *error* ( msg )
(mapcar 'setvar sv_lst sv_vals)
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : ( " msg " ) occurred.")))
(princ)
);end_*error*_defun
(setq sv_lst (list 'osmode 'cmdecho 'dimzin)
sv_vals (mapcar 'getvar sv_lst)
a_lst '(("HEATER" . 8.3) ("LAMP" . 4.5) ("MOTOR" . 10.06) ("SOCKET" . 5.11) ("TV" . 3.2))
sv 24.0
RL 0.015
I 0.0
iu (getvar 'insunits)
);end_setq
(mapcar 'setvar sv_lst (list 0 0 8))
(cond ( (= iu 4) (setq cu 1000.0))
( (= iu 5) (setq cu 100.0))
( (= iu 6) (setq cu 1.0))
);end_cond
(foreach itm a_lst
(initget 4)
(setq itxt (car itm)
load (cdr itm)
ipart (cond ( (getint (strcat "\nEnter Number of " itxt " <0> : "))) (0))
);end_setq
(if (> ipart 0.0) (setq I (+ I (* ipart load))))
);end_foreach
(while (setq sel (entsel "\nSelect Polyline : "))
(setq obj (vlax-ename->vla-object (car sel)))
(if (vl-position (vlax-get obj 'objectname) (list "AcDbPolyline" "AcDb2dPolyline" "AcDbLine"))
(setq p_len (vlax-get obj 'length))
(alert "NOT a Polyline/Line")
);end_if
);end_while
(cond (p_len
(setq ld (- sv (setq vd (* RL I (setq len (/ p_len cu))))))
(alert (strcat "Constant Voltage : " (rtos sv 2 0) "\n\n"
"Polyline Length (m) : " (rtos len 2 3) "\n\n"
"Total Voltage Drop : " (rtos vd 2 6) "\n\n"
"Voltage @ Last Device : " (rtos ld 2 6)
);end_strcat
);end_alert
)
);end_cond
(mapcar 'setvar sv_lst sv_vals)
(princ)
);end_defun