Jump to content

Lisp for plates weight calculator.


eyal

Recommended Posts

Hi,

 

I have an idea for a lisp , but I don't know how to do it.

 

I want a lisp that first asks for polygon , then it asks for thickness (mm), and then the user can place the text with the result on the drawing.

 

the result should be : (the area of the closed polygon (mm)*7.85*thickness)/E6

E6 = for converting the weight to Kg.

 

I would be glad if someone could help me with this.

Link to comment
Share on other sites

Yes , the polygons already exists.

 

with the lisp I want :

1. to pick an existing polygon

2. input thickness

3. I want the list to let me place a text with the result.

 

Thank you!!

Link to comment
Share on other sites

Ok, i made something... I guess it ain't pretty, but it is pretty simple to modify.

Don't know if the calculations are correct, but changes should be pretty strait forward:"

 

(Defun C:calculate (/ Polygon Polyarea Thickness E6 PlacePoint Volume Mass)
;; Get the info
(setq Polygon (vlax-ename->vla-object(car(entsel "\nSelect Polygon:"))))
(setq Polyarea (vla-get-area Polygon))
(setq Thickness (getint "\nGive Thickness in MM: "))
(setq E6 (getint "\nGive E6 value: "))
(setq PlacePoint (getpoint "\nPick point of text placement:  "))
;; Do some calculations:
(setq Volume (* Polyarea 7.85 Thickness))
(setq Mass (/ Volume E6))
;debugging- Can be deleted!
(princ "\n *************** DEBUGGING *************** ")
(princ "\n Area of Polygon:")
(print Polyarea)
(princ "\n Thickness given:")
(print Thickness)
(princ "\n E6 given:")
(print E6)
(princ "\nCoordinates of text insertionpoint :")
(print PlacePoint)
(princ "\nVolume calculated:")
(print Volume)
(princ "\nMass Calculated:")
(print Mass)
(princ "\n ************* END DEBUGGING *************\n\n")
; End debug
;; Place the text
(command "_text" "J" "MC" PlacePoint "0" Mass "")
(princ)
)

 

Without the debugging part:

 

(Defun C:calculate (/ Polygon Polyarea Thickness E6 PlacePoint Volume Mass)
;; Get the info
(setq Polygon (vlax-ename->vla-object(car(entsel "\nSelect Polygon:"))))
(setq Polyarea (vla-get-area Polygon))
(setq Thickness (getint "\nGive Thickness in MM: "))
(setq E6 (getint "\nGive E6 value: "))
(setq PlacePoint (getpoint "\nPick point of text placement:  "))
;; Do some calculations:
(setq Volume (* Polyarea 7.85 Thickness))
(setq Mass (/ Volume E6))
;; Place the text
(command "_text" "J" "MC" PlacePoint "0" Mass "")
(princ)
)

Edited by OMEGA-ThundeR
Link to comment
Share on other sites

  • 3 years later...

Thank you Brian TFC. I'm currently having issues with the DLC not being recognized as being in the search path. But I'm sure I'll get it sooner or later. Thanks again. But does anybody know why JPS website is no longer working? or is it just me?

Link to comment
Share on other sites

 

btw how did you download the attachments? I found some that I want to download but it won't let me.

 

Link to comment
Share on other sites

I clicked on the link that you provided, downloaded the lsp & dcl files. cut and paste them into my lisp folder with all of my other lisp routines did the app load and nothing. I'm about to try a CAD shut down and reopen to see if that does it or not. 

 

the shut down and restart of CAD seems to have done it. 

Edited by jetxcc
Link to comment
Share on other sites

Hi @BrianTFC,

 

Thank you for the lisp.

but I can't fint the steel density 7.85 g/cm3 .

and I work with this density , where can I change it in the lisp?

 

Thank you

 

 

Link to comment
Share on other sites

Why not use the code by Omega-thunder ?

 

I had a bit of play with it added multi picks. It needs check picked a valid object pline or circle. And Material type say add Aluminimum. 

 

The code by Jeffery sanders has nearly any type of material which is good but adds overheads. 

 

(Defun C:calculate (/ Poly Thick sc Pt Vol)
(setq Thick (getreal "\nGive Thickness in MM: "))
(setq sc (getreal "\nGive scale value 1 0.1 0.001 : "))
(while (setq ent (entsel "\nSelect Polygon:"))
(setq Poly (vla-get-area (vlax-ename->vla-object (car ent))))
(setq Pt (getpoint "\nPick point of text placement:  "))
(setq Vol (rtos (* Poly 7.85 Thick sc) 2 3))
(command "_text" Pt 20 0.0 Vol)
)
(princ)
)
(C:calculate)

 

  • Like 1
Link to comment
Share on other sites

Hi BrianTFC,

I liked you lisp , that I can choose from a list the density, but as I said I use steel density of 7.85 g/cm3

 

I want to change values in your list for specific materials ( also I use mm units)

in your list I found this:

 "437.0"  ;  Iron, ferro-silicon
      "325.0"  ;  Iron ore, hematite
      "170.0"  ;  Iron ore, hematite in bank
      "145.0"  ;  Iron ore, hematite loose
      "237.0"  ;  Iron ore, limonite
      "315.0"  ;  Iron ore, magnetite
      "172.0"  ;  Iron slag
      "710.0"  ;  Lead
      "465.0"  ;  Lead ore, galena
      "112.0"  ;  Magnesium, alloys
      "475.0"  ;  Manganese
      "259.0"  ;  Manganese ore, pyrolusite
      "849.0"  ;  Mercury
      "556.0"  ;  Monel Metal
      "565.0"  ;  Nickel
      "1330.0" ;  Platinum, cast, hammered
      "656.0"  ;  Silver, cast, hammered
      "453.0"  ;  Steel, rolled
      "459.0"  ;  Tin, cast, hammered
      "418.0"  ;  Tin ore, cassiterite
      "440.0"  ;  Zinc, cast, rolled
      "253.0"  ;  Zinc ore, blende

as you can see steel rolled is 453 what is this value? , it supposed to be 7.85 g/cm3 

I don't understand the values here.

Can you change the density list to be in g/cm3

Density (near r.t.) 7.874 g/cm3

https://en.wikipedia.org/wiki/Iron

 

Thank you,

Eyal

 

Link to comment
Share on other sites

Metric v's imperial 

 

Also if working always in mm then you can put the 7.85 as a correct value to give Kg's as answer 

 

Found this 

Weight per sq. feet of hot rolles mild steel plates can be calculated as W = 40.8 t (1) where W = weight of steel plate (lb/ft2) t = plate thickness (in)

 

7.85kg / sq m. for 1mm plate so work out you mm x mm  x weight put in my code.

Edited by BIGAL
Link to comment
Share on other sites

Hi Bigal,

Sorry but I didn't understand what did you mean.

in your code: 

"453.0"  ;  Steel, rolled

what is this value.

 

I don't know where to change the values to 

7.85kg / sq m

Can you please fix the values for the steel rolled?

, and I fix the rest of the values according to your example.

I work in metric units , I don't know how to work with feet.

 

Regards.

Eyal

 

 

Link to comment
Share on other sites

You do not need to change nothing . 

 

as the lisp calculate   as VOL

(setq Vol (rtos (* Poly 7.85 Thick sc) 2 3))

 

so vol =  area [m2]  times thick [mm] times 7.85 kg/ 1 m2  1 mm thick 

 

If you want to calculate for Aluminum , change 7.85 for 2.71 . or whatever specific weight the material is 

 

 

 

Link to comment
Share on other sites

  • 3 years later...

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...