noyjoreb 发表于 2022-7-6 10:11:02

Area & Volume of closed polyli

hi to all, i have a question... what lisp routine for computing the volume of closed polyline? example, i will get the area of a close polyline then by entering the thickness of depth, it will show a volume.. and put it on the table... any help is appreciated,... tnx

Lee Mac 发表于 2022-7-6 10:33:31

In future please name your threads in a more appropriate manner so that they may found by the search utility.

Cad64 发表于 2022-7-6 10:35:55

Thread renamed.
 
You can Extrude your closed Polyline and then use the MASSPROP command to calculate volume.

Lee Mac 发表于 2022-7-6 10:53:29

Not sure if its what you want as I don't completely understand your request, but it was fun to write:
 

(defun c:V2Cell ( / tables ent dep pt doc ) (vl-load-com) ;; Lee Mac~17.05.10 (while   (progn   (cond       (         (not         (or tables             (setq tables               (ss->vla               (ssget "_X" '((0 . "ACAD_TABLE")))               )             )         )         )         (princ "\n** No Tables in Drawing **") nil       )       (         (not         (or ent             (setq ent               (CurveifFoo               (lambda ( x )                   (vlax-property-available-p                     (vlax-ename->vla-object x) 'Area                   )               )               "\nSelect Object to Retrieve Volume: "               )             )         )         )      nil       )       (         (not         (or dep             (setq dep               (getdist "\nSpecify Depth: ")             )         )         )      nil       )       (         (not         (and             (setq pt               (getpoint "\nPick Cell for Volume: ")             )             (TextinCell tables pt               (strcat "%% * "               (vl-princ-to-string dep) " \\f \"%lu6%qf1\">%"               )             )         )         )      (princ "\n** Cell Not Found **")       )   )   ) ) (princ))   (defun TextinCell ( tables pt str / data ) ;; Lee Mac~17.05.10 (if   (setq data   (vl-some       (function         (lambda ( table )         (if             (eq :vlax-true               (vla-hittest table (vlax-3D-point (trans pt 1 0))               (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0)) 'row 'col               )             )             (list table row col)         )         )       )       tables   )   )   (not   (apply (function vla-setText)       (append data (list str))   )   ) ))(defun ss->vla ( ss ) (if ss   (   (lambda ( i / e l )       (while (setq e (ssname ss (setq i (1+ i))))         (setq l         (cons             (vlax-ename->vla-object e) l         )         )       )       l   )   -1   ) ))(defun CurveifFoo ( foo str / sel ent ) ;; Lee Mac~17.05.10 (while   (progn   (setq sel (entsel str))          (cond       (         (vl-consp sel)         (if (not (foo (setq ent (car sel))))         (princ "\n** Invalid Object Selected **")         )       )   )   ) ) ent)(defun GetObjectID ( obj doc ) ;; Lee Mac~17.05.10 (if   (eq "X64"   (strcase       (getenv "PROCESSOR_ARCHITECTURE")   )   )   (vlax-invoke-method   (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false   )   (itoa (vla-get-Objectid obj)) ))

Oliver 发表于 2022-7-6 10:59:53

hi..Lee,
 
Command: v2cell
** No Tables in Drawing **
Command:

 
what does it mean..
 

Lee Mac 发表于 2022-7-6 11:21:57

The function is designed to place the result of the calculation into a table cell - as per the OP's request.
页: [1]
查看完整版本: Area & Volume of closed polyli