Eslam mansour Posted December 8, 2019 Share Posted December 8, 2019 Hi every one, I am jonir an electrical engineer. I have a small idea that I like to implement .. I need a lot to calculate the length of a polyline or line that represents In my work the power consumtion next step, I calculate how meny loads on it on exel sheet and then the output is the value of the voltage drop by this equation ( 24 - I*(R/Length)* Length from drawing) 24 : Constant voltege I : sumition carrunt from different loads I choose it. R/Length : constant L: length of line or polyline from drawing. Is that possible by lisp? Best regards, Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 8, 2019 Share Posted December 8, 2019 Polyline Length as what Metres, Millimetres, Feet, Inches ....? Do you want the lisp to calculate the voltage drop? If so please provide the R/Length Constant or do you want the lisp to prompt for this as well as I ? If you just want the polyline length in the current units then try this (defun c:plen ( / sel ent) (while (setq sel (entsel "\nSelect Polyline : ")) (setq ent (car sel)) (alert (strcat "Polyline Length : " (rtos (vlax-curve-getdistatpoint ent (vlax-curve-getendpoint ent)) 2 3))) );end_while (princ) );end_defun Quote Link to comment Share on other sites More sharing options...
Eslam mansour Posted December 8, 2019 Author Share Posted December 8, 2019 11 minutes ago, dlanorh said: Polyline Length as what Metres, Millimetres, Feet, Inches ....? Do you want the lisp to calculate the voltage drop? If so please provide the R/Length Constant or do you want the lisp to prompt for this as well as I ? If you just want the polyline length in the current units then try this (defun c:plen ( / sel ent) (while (setq sel (entsel "\nSelect Polyline : ")) (setq ent (car sel)) (alert (strcat "Polyline Length : " (rtos (vlax-curve-getdistatpoint ent (vlax-curve-getendpoint ent)) 2 3))) );end_while (princ) );end_defun Thanks for your reply. Polyline in Millimetres, yes I need Calc. Voltege drop in cad, by select Polyline and item on it(like 2 lamps, 3 kitchen machines and 5 TV), Evry item have current like : Lamp: 1 Ampir Kitchin machine : 5.5 Ampir Tv: 0.25 ampir R/length= 0.015 The voltage drop calculation like that: polyline length (from cad) * ( no. Lamps + no. Kitchen machines + no. TV) Is it difficult? Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 8, 2019 Share Posted December 8, 2019 For Mr. Dlanor... If you have closed curves, sometimes end point can be equal as start point... Thus, I would avoid your syntax you used and instead use more reliable classic approach via parameters : (vlax-curve-getdistatparam curve (vlax-curve-getendparam curve)) Regards, M.R. Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2019 Share Posted December 8, 2019 Please upload both , sample.dwg and currentvalues.xls Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 8, 2019 Share Posted December 8, 2019 2 hours ago, Eslam mansour said: Thanks for your reply. Polyline in Millimetres, yes I need Calc. Voltege drop in cad, by select Polyline and item on it(like 2 lamps, 3 kitchen machines and 5 TV), Evry item have current like : Lamp: 1 Ampir Kitchin machine : 5.5 Ampir Tv: 0.25 ampir R/length= 0.015 The voltage drop calculation like that: polyline length (from cad) * ( no. Lamps + no. Kitchen machines + no. TV) Is it difficult? No, not difficult. Do you need to enter individual appliances etc, or are you going to select blocks etc; in which case I would need a full list including loads. Quote Link to comment Share on other sites More sharing options...
Eslam mansour Posted December 8, 2019 Author Share Posted December 8, 2019 1 hour ago, devitg said: Please upload both , sample.dwg and currentvalues.xls here you are Drawing1.dwg voltage drop.xlsx Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2019 Share Posted December 8, 2019 (edited) Please clear me as per your data Total current will be Lamps 2 * 1 = 2 amp Kitchen 3 * 5.5 = 16.5 amp Tv 5 * 0.25 = 1.25 Total current 2 + 16.5 + 1.25 = 19.75 coefficient = 0.015 Then Volt drop will be = total current * length * coefficient I think that cable length shall be in meters. Or please give me such formula source Edited December 8, 2019 by devitg check Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 8, 2019 Share Posted December 8, 2019 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 1 Quote Link to comment Share on other sites More sharing options...
devitg Posted December 8, 2019 Share Posted December 8, 2019 LOAD is a reserved word in LISP , replace it by LOAD# Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 8, 2019 Share Posted December 8, 2019 Can do this add more items, Dlanorh then use your list of power items to work out load. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter Qty" "Lamp " 5 4 "0" "Heater" 5 4 "0" "Socket"5 4 "0" "TV" 5 4 "0" "Oven"5 4 "0" "Aircon" 5 4 "0" ))) (setq pload 0.0) (setq pload (+ (* (atof (nth 0 ans)) 8.3) pload)) (setq pload (+ (* (atof (nth 1 ans)) 5.11) pload)) (setq pload (+ (* (atof (nth 2 ans)) 3.2) pload)) (setq pload (+ (* (atof (nth 3 ans)) 8.0) pload)) (setq pload (+ (* (atof (nth 4 ans)) 8.0) pload)) (alert (strcat "Power load is " (rtos pload 2 1))) 1 Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 9, 2019 Share Posted December 9, 2019 (edited) 11 hours ago, marko_ribar said: For Mr. Dlanor... If you have closed curves, sometimes end point can be equal as start point... Thus, I would avoid your syntax you used and instead use more reliable classic approach via parameters : (vlax-curve-getdistatparam curve (vlax-curve-getendparam curve)) Regards, M.R. Hi Marko, I would agree with the above if it wasn't an electrical circuit. However IF there is a closed polyline, the power drop at the end would be the same as at the start, and the max drop, in theory, would be at the mid point. Edited December 9, 2019 by dlanorh Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 9, 2019 Share Posted December 9, 2019 1 hour ago, BIGAL said: Can do this add more items, Dlanorh then use your list of power items to work out load. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter Qty" "Lamp " 5 4 "0" "Heater" 5 4 "0" "Socket"5 4 "0" "TV" 5 4 "0" "Oven"5 4 "0" "Aircon" 5 4 "0" ))) (setq pload 0.0) (setq pload (+ (* (atof (nth 0 ans)) 8.3) pload)) (setq pload (+ (* (atof (nth 1 ans)) 5.11) pload)) (setq pload (+ (* (atof (nth 2 ans)) 3.2) pload)) (setq pload (+ (* (atof (nth 3 ans)) 8.0) pload)) (setq pload (+ (* (atof (nth 4 ans)) 8.0) pload)) (alert (strcat "Power load is " (rtos pload 2 1))) Hi Al. I don't have "Multi Getvals.lsp" on my laptop. Can you attach? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 9, 2019 Share Posted December 9, 2019 (edited) Its in the download section as well as a radio buttons and toggle buttons. Working on a "image multi getvals" as well as a Vector version as image is a slide which quality and image creation can be a problem. There are example calling code in the lisp. Basically the screen size is the limitation I add a double space when only a few lines. Multi GETVALS Img.lsp Edited December 9, 2019 by BIGAL 2 Quote Link to comment Share on other sites More sharing options...
Eslam mansour Posted December 9, 2019 Author Share Posted December 9, 2019 3 hours ago, BIGAL said: Its in the download section as well as a radio buttons and toggle buttons. Working on a "image multi getvals" as well as a Vector version as image is a slide which quality and image creation can be a problem. There are example calling code in the lisp. Basically the screen size is the limitation I add a double space when only a few lines. Multi GETVALS Img.lsp 2.57 kB · 2 downloads Hi Mr. BIGAL, I really appreciate your work , but i can't find (alantest.dcl) , the lisp didn't work . Quote Link to comment Share on other sites More sharing options...
Eslam mansour Posted December 9, 2019 Author Share Posted December 9, 2019 13 hours ago, dlanorh said: 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 Hi Mr. dlanorh, amazing ^_^ , I really appreciate your work , that nearest idea for my work, Can add more length ? the device located in more places on same wire ( polyline ). for Example TV it is in your bed room , 5 m from Plug and another TV in leving room 10 m from Plug , two pluges have same wire strat from panel to first Plug 5m Then, 10 m between to pluges , the wire is 15 m in total lenght ( 1st tv after 5m and 2nd tv 10m ). Quote Link to comment Share on other sites More sharing options...
dlanorh Posted December 9, 2019 Share Posted December 9, 2019 1 hour ago, Eslam mansour said: Hi Mr. dlanorh, amazing ^_^ , I really appreciate your work , that nearest idea for my work, Can add more length ? the device located in more places on same wire ( polyline ). for Example TV it is in your bed room , 5 m from Plug and another TV in leving room 10 m from Plug , two pluges have same wire strat from panel to first Plug 5m Then, 10 m between to pluges , the wire is 15 m in total lenght ( 1st tv after 5m and 2nd tv 10m ). Can you post another example drawing saved in AutoCAD 2010 format as I am unable to open the attached drawing above Quote Link to comment Share on other sites More sharing options...
Eslam mansour Posted December 9, 2019 Author Share Posted December 9, 2019 (edited) 44 minutes ago, dlanorh said: Can you post another example drawing saved in AutoCAD 2010 format as I am unable to open the attached drawing above here you are ^_^ Drawing2.dwg Edited December 9, 2019 by Eslam mansour Quote Link to comment Share on other sites More sharing options...
devitg Posted December 9, 2019 Share Posted December 9, 2019 (edited) Hi BigAl, please clear me , what extension shall be the image sent to AH:getvalsimg (setq img_name (getfiled "select img " "" "???" 8)) I try with a ICON from ICONS ACAD folder. Edited December 9, 2019 by devitg add Quote Link to comment Share on other sites More sharing options...
devitg Posted December 9, 2019 Share Posted December 9, 2019 Like it 3 point.bmp 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.