@anderson51 ,
Ok, well until further refinements can be made, this code gets the 'height' and the 'area' of the solid, then calculates for the radius (perhaps there are rounding errors somewhere because I saw some 2 unit radius pipes being calculated as 1.99999 units). Then your items are returned as a list of radius/length pairs.
For the items I mentioned above, about not having height property, if they are selected then the function will error out.
(defun c:PIPES ( / ss pipeData)
;Get pipes
(prompt "\nSelect Cylindrical Pipes Only: ")
(if (setq ss (ssget '((0 . "3DSOLID"))))
(progn
(setq pipeData (GetPipeData ss)) ;<-- returned format: ((rad length) (rad length) ...)
(prompt "\nHere is your pipe data as a list:\n")
(princ pipeData)
);progn
;else
(prompt "\nNo 3D Solids selected..")
);if
(princ)
);defun
(defun GetPipeData (ss / e height area radius dataList)
;loop through to get lengths ('height') and radius
(repeat (setq cnt (sslength ss))
(setq e (ssname ss (setq cnt (1- cnt))))
(setq height (getpropertyvalue e "Height"))
(setq area (getpropertyvalue e "Area"))
;using.. Cylinder Area = 2*pi*r*h + 2*pi*(r^2)
;..to find radius, we get.. r = (-h + (sqrt (h^2) + (2a / pi)) / 2
(setq radius (/ (+ (- height) (sqrt (+ (expt height 2) (/ (* 2 area) pi)))) 2))
(setq dataList (cons (list radius height) dataList))
);repeat
);defun
Again, this process would be much easier if they were created as cylinders to begin with.
EDIT: Please take note that the Radii and Lengths will be in the same units!
Best,
~DD