4 Replies Latest reply on Nov 3, 2014 1:17 PM by Daniel Seaman

# How to get the height of a cylinder using IFace::ISurface::CylinderParams ?

I'm creating a MacroFeature and I'm using a selection filter to get cylindrical faces only, but once I got such face, I want to calculate the height of the cylinder. Any ideas?

• ###### Re: How to get the height of a cylinder using IFace::ISurface::CylinderParams ?

Hi Edgar,

The ISurface object defines the infinite cylinder from which your cylindrical face is trimmed. To calculate the height of the cylinder you need to look at the edges which terminate the cylinder at the top and bottom.

The exact process will vary considerably depending on how the cylinder is terminated. For the simple case of finding the distance between to parallel circular edges you would use IFace2:GetEdges to get hold of the two edges, pick a point on one edge and then use IEdge::GetClosestPointOn to find the closest point on the other edge. You then need to subtract one point from the other to get the vector distance between them.

If your cylinder is terminated by multiple circular and elliptical section edges then you might find it easier to start from IFace2::GetFirstLoop to group together the edges which make up each end of the cylinder.

Regards,

Dan

• ###### Re: How to get the height of a cylinder using IFace::ISurface::CylinderParams ?

Assuming your cylinder is complete (like not a half-cylinder), you can take the face area and divide by the circumference.  It's a little bit short-cutty, but worked pretty well for me once.

• ###### Re: How to get the height of a cylinder using IFace::ISurface::CylinderParams ?

I wish i could make both answer correct !!!

• ###### Re: How to get the height of a cylinder using IFace::ISurface::CylinderParams ?

Josh's answer is much better than mine for a full cylinder with parallel ends. It will be quicker to implement and execute too.

Josh, have some mention points as compensation. Josh Brady

Dan