I have 3d models (stl-files) of irregular cylinder-like objects that I would like to measure at set intervals along the long axis. The result should be a distribution of diameters (or of the lengths of the long and short axes of the elliptical cross-section). Is there a way to do this using built-in functions of one of the standard pieces of 3d software (Geomagic, Meshlab, Solidworks)?
-
1perhaps you would get a response at http://forums.solidworks.com – AndrewK Aug 30 '17 at 15:05
-
1If you know the axis of the cylindre, you get estimates of the radius by taking the distances from the vertices to the axis. For the elliptic axe lengths, you can reset the cylindre axis to vertical and compute the ellipse of inertia of the projected points (or just the points in a slice). – Aug 31 '17 at 09:05
-
If you are willing to to a bit of coding I can point you in the right direction with Solidworks API – Vlad Sep 05 '17 at 04:35
-
The cylindrical objects have curved axes, so these have to be calculated as well. Yes, I was going to try it with a VBA macro in Solidworks. – Dmitri Ponomarenko Sep 06 '17 at 10:38
1 Answers
Here's Solidworks API approach that I would take :
1 Collect all the edges of your body, convert them to vectors. If it's a curve just take endPoint - startPoint. IPartDoc::GetBodies2 IBody2::GetEdges
2 Using those vectors as potential axes figure out the smallest box that your body fits into using IBody2::GetExtemePoint.
3 Largest dimension of the box will be your long axis.
**If you know orientation of your body beforehand (ie top of the cylinder always looks towards x/-x) you can skip first three steps
4 Take 4 faces of the box that you found that are parallel to the longest dimension. For example if your box is x,y,z axes and x is the longest you must take 2 faces parallel to xy plane and 2 faces parallel to xz plane.
5 For each of those 4 faces generate a grid of points that will evenly cover the face, number of points depends on the accuracy of the result that you want, I'd suggest to start with 100 points per face.
6 Shoot rays from those points though the body with IModelDoc2::RayIntersections.
7 Disregard rays that don't intersect the body, those that do will give you 2 points - an entry and an exit, calculating the distance between them will give you your diameter.
8 Because your rays will be intersecting cylinder across the surface not only in the thickest part use only biggest diameter per row of grid points.
This is the most generic approach that would work for any 'irregular cylinder-like object' given that height of the cylinder is bigger than its diameter.
Let me know if you need clarification on any of the steps, I can draw some sketches.

- 793
- 6
- 15
-
Thanks for the suggestions! The problem is that some of the cylinders are curved, so that the long axis of the bounding box would not be codirectional with the long axis. The simplest case is when the object consists of two relatively straight segments connected by a 45 degree turn. – Dmitri Ponomarenko Sep 14 '17 at 06:26
-
-
Sorry, wasn't sure how to upload at the time, ended up using the VMTK library (designed for measuring arteries) to solve the problem. Would be interested to know if a curved axis can be obtained directly through Solidworks API though. Here is a sample STL file: https://www.dropbox.com/s/g4j08bdmd26nvrs/Burrow_Simplified.stl?dl=0 – Dmitri Ponomarenko May 31 '21 at 09:24