Jump to content

Voltage drop calculator lisp - help


Recommended Posts

Eslam mansour

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, 

Link to post
Share on other sites
  • CADTutor changed the title to Voltage drop calculator lisp - help
  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

  • BSmiths1544

    11

  • Steven P

    10

  • Eslam mansour

    9

  • BIGAL

    9

Top Posters In This Topic

Popular Posts

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

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 o

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 "

Posted Images

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

 

 

Link to post
Share on other sites
Eslam mansour
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?

 

Link to post
Share on other sites
marko_ribar

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.

Link to post
Share on other sites
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.

Link to post
Share on other sites

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 by devitg
check
Link to post
Share on other sites

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

 

  • Like 1
Link to post
Share on other sites

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)))

 

image.png.21401aee3e67cbc8d0d6ab38602c2d22.pngimage.png.3a3ab74b4922b9e04ed5c5f0d22ce5e5.png

  • Like 1
Link to post
Share on other sites
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 by dlanorh
Link to post
Share on other sites
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)))

 

image.png.21401aee3e67cbc8d0d6ab38602c2d22.pngimage.png.3a3ab74b4922b9e04ed5c5f0d22ce5e5.png

 

Hi Al. I don't have "Multi Getvals.lsp" on my laptop. Can you attach?

Link to post
Share on other sites

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 by BIGAL
  • Like 2
Link to post
Share on other sites
Eslam mansour
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 .
 

Link to post
Share on other sites
Eslam mansour
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 ).

Link to post
Share on other sites
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

Link to post
Share on other sites
Eslam mansour
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 by Eslam mansour
Link to post
Share on other sites

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 by devitg
add
Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...