rcb007 Posted September 8, 2021 Posted September 8, 2021 I have a basic routine which will draw the cross section of a generic pond. How would I get a volume to show for the top of bank and the normal pool? I found a routine that can calculate a volume, just having trouble how to plug it in. Then again, I might be doing this all wrong. Maybe I would type the desired volume and it would project the top line down to create a bottom for that volume. The idea was to quickly get an idea of a volume if it would fit in a given area. Thank you for the help. (Defun C:Pond (/ p1 tob) (command "_.offset" 12 (setq tob (entsel)) (setq p1 (getpoint)) "" ) ;;Select Top of Bank, pick inside, offset 12' @ 3:1 (command "_.move" "_last" "" "0,0,0" "0,0,-6" ) (command "_.offset" 22 tob p1 "" ) ;;Use Top of Bank offset 22' @ 4:1 (command "_.move" "_last" "" "0,0,0" "0,0,-8.5" ) (command "_.offset" 46 tob p1 "" ) ;;Use Top of Bank offset 46' @ 3:1 (command "_.move" "_last" "" "0,0,0" "0,0,-16.5" ) (princ)) (defun c:volume (/ 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)) Quote
hosneyalaa Posted September 8, 2021 Posted September 8, 2021 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/calculate-volume-using-3d-polyine/m-p/10386919 Quote
BIGAL Posted September 9, 2021 Posted September 9, 2021 Another way is draw the 1 side in elevation, use rotate3d stand it up vertical use extrude path. so it makes the edge shape all round, note the path should be at the alignment of the bottom ie meet at centre pt of cnr radius, then add a rectang and extrude, union and that is volume, you can do sloping surface and subtract etc also. The obvious though is do in CIV3D etc. A roughy needs a 1mm rad Quote
rcb007 Posted September 17, 2021 Author Posted September 17, 2021 Thank you guys for your feedback. I found another way to do this from the post below. https://www.cadtutor.net/forum/topic/64976-selection-of-contours-automatically/ This works great with Polylines but i can figure out how to pull the elevation z from the feature line without exploding and converting the feature line from a 3d Poly to a 2D poly. Is there another way to look at this? thank you! ;getpoint w/ osnap (defun getpt (pt1 msg osnap / oos pt) (setq oos (getvar "osmode")) (setvar "osmode" osnap) (setq pt (if pt1 (getpoint pt1 msg) (getpoint msg))) (setvar "osmode" oos) pt) (defun c:vol ( / ss x pt1 pt2 a1 a2 z1 z2 vol adiff volinc) (setq pt1 (getpt nil "Select Top : " 512)) (setq pt2 (getpt pt1 "Select Water: " 512)) (setq ss (ssget "F" (list pt1 pt2)(list (cons 0 "*line")))) ;;Select Polyline or Feature line? (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq a1 (vla-get-area obj)) (setq z1 (vla-get-elevation obj)) (setq vol 0.0) (repeat x (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq z2 (vla-get-elevation obj)) (setq a2 (vla-get-area obj)) (setq diff (* (- z1 z2) -1)) (setq adiff (/ (+ a1 a2) 2.0)) (setq volinc (* diff adiff)) (setq vol (/ (+ vol volinc) 43560)) (princ (strcat "\nVolume (ac-ft): " (rtos vol 2 2 ) )) (setq a1 a2) (setq z1 z2) ) ) Quote
hosneyalaa Posted September 17, 2021 Posted September 17, 2021 Are you working on Civil 3D? Because it calculates quantities, there is no reason to use Lisp Please include an example drawing Quote
ronjonp Posted September 17, 2021 Posted September 17, 2021 (edited) Here's one for fun .. reports volume between each elevation change then a total: (defun c:volume (/ _foo _rtos a b r s v) ;; RJP » 2021-09-17 (defun _foo (e) (list (vlax-curve-getarea e) (cdr (assoc 38 (entget e))))) (defun _rtos (n) (rtos n (getvar 'lunits) 2)) (cond ((and (setq s (ssget '((0 . "*polyline") (-4 . "&=") (70 . 1)))) (setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) ) (setq s (mapcar '_foo s)) (setq s (vl-sort s '(lambda (r j) (> (car r) (car j))))) (while (cadr s) (setq a (car s) b (cadr s) s (cdr s) ) ;; Average of areas multiplied by height = volume (setq v (* (/ (apply '+ (mapcar 'car (list a b))) 2) (abs (apply '- (mapcar 'cadr (list a b))))) ) (princ (strcat "\nVolume Between (" (_rtos (cadr a)) " " (chr 187) " " (_rtos (cadr b)) ") = " (_rtos v) ) ) (setq r (cons v r)) ) (princ (strcat "\nVolume Total = " (_rtos (apply '+ r)))) (textscr) ) ) (princ) ) Edited September 17, 2021 by ronjonp Quote
rcb007 Posted September 20, 2021 Author Posted September 20, 2021 Thank you. I like the idea of this. As for Civil3D, you are right "creating a bounded volume' can create the number. I was looking for something more quicker to get a rough result rather than adding feature lines or polylines to surfaces, etc. Quote
hosneyalaa Posted September 20, 2021 Posted September 20, 2021 On 9/17/2021 at 2:55 PM, rcb007 said: how to pull the elevation z from the feature line without exploding and converting the feature line from a 3d Poly to a 2D poly. from GetPoints Method http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccLandFeatureLine__GetPoints@[in,defaultvalueaeccLandFeatureLinePointPI_aeccLandFeatureLinePointElevation]AeccLandFeatureLinePointType@[out,_retval]VARIANT__.htm Quote
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.