Calculate volume from contour?

Calculate volume from contour?

Anonymous
Not applicable
1,414 Views
1 Reply
Message 1 of 2

Calculate volume from contour?

Anonymous
Not applicable

Hello everyone,

Is any possibilites to calculate volume from some contour data with autolisp??

The formula should be like this. [Attached]

Thanks for your help. 

0 Likes
1,415 Views
1 Reply
Reply (1)
Message 2 of 2

hmsilva
Mentor
Mentor

@Anonymous wrote:

Hello everyone,

Is any possibilites to calculate volume from some contour data with autolisp??

The formula should be like this. [Attached]

Thanks for your help. 


Hello anggarevramadhan and welcome to the Autodesk Community!

 

Quick and dirty, untested and using your formula...

 

(defun c:demo (/ area dist hnd i n obj ss)
    (if (and (setq ss (ssget '((0 . "*polyline") (-4 . "&=") (70 . 1))))
             (setq dist (getdist "\nEnter contour interval: "))
        )
        (progn
            (setq n    0
                  area 0.0
            )
            (repeat (setq i (sslength ss))
                (setq hnd (ssname ss (setq i (1- i)))
                      obj (vlax-ename->vla-object hnd)
                )
                (if (vlax-property-available-p obj 'Area)
                    (setq area (+ area (vla-get-area obj))
                          n    (1+ n)
                    )
                    (progn (command "_.area" "_O" hnd)
                           (setq area (+ area (getvar 'area)))
                    )
                )
            )
            (princ (strcat "\n Area Total = " (rtos (* (/ area n) (* (1- n) dist)))))
        )
    )
    (princ)
)

 

Hope this helps,
Henrique

EESignature

0 Likes