I often find that I wished I had a way to generate a center-line for objects previously created and then modified. This would help in recreating the object after modification back to the original location.
Do VolumeCentroid or BoundingBox help? These will both make it relatively easy to draw a center line but I may be misunderstanding the type of references you want. Post a file to explain more if you can.
I have a complex curved tube for which I want to construct a center-line along the long axis.tube.3dm (139.1 KB)
In this case you can use ExtractSrf on one of the end caps and then use AreaCentroid on the extracted surface. If you then use Offset picking the srf edge as the curve to offset and defining the distance by clicking between the edge end point and the area centroid point, you’ll get a center line. Your object is very very small in this model though which will require you to adjust the offset tolerance for the best result.
I know you want this automatically but this is how I would do it now.
See attached file. tube_DC1.3dm (245.3 KB)
The object is about 12 millimeters long but the units are meters. Absolute tolerance is 0.001 units or 1 mm. I switched the units to millimeters while keeping the absolute tolerance as 0.001 units or 0.001 mm.
Tube is a polysurface and appears to have constant cross section, probably created using a sweep.
Cross-section curves at ends created using DupEdges
Area centroids of cross section end curves found using AreaCentroid
Curve along tube surface created using ExtractIsocurve
Centerline curve created with Sweep1 with Point option using curve along tube as rail and end centroids as sections
Additional sections at random locations along tube created using ExtractIsocurve
Centroid of each additional section found using AreaCentroid
PointDeviation used to check deviation of centerline curve from centroids. Maximum deviation is zero.
Brian, I just tried your method and the offset curve isn’t on the centerline, presumable because the tube is tilted slightly and with the ends not exactly perpendicular to the CPlane.
Good points, your method sounds like it will be more accurate. I’m not sure what the purpose for the center line is though so maybe a partial result is also helpful. I didn’t scale the model up either so the tolerance used in the offset also matters.
Here’s a thought.
Why not initially build the geometry by sweeping the cross section along a curve whose start point is positioned in the center of the cross section?
That way the centreline itself drives the final output and you don’t have to extract it out of the result.
Alternatively you could arrange the cross section multiple times along the curve on perp-frames and then generate a loft.
When I build it I do it around a CL. My objects get scaled, twisted and bent in many different ways and copied to multiple locations. I do not bring the CL along in the copies. There are occasions where I want to change the size or place a different configuration and it would be helpful to be able to easily create a CL so that the new object can be placed in the original objects position and orientation. To be able to easily generate a CL would be helpful to me and that is why I placed it on my “wish list”
You can find attached a simple Grasshopper definition for finding the center-line of a tube-like surface. Please note the definition needs surfaces, not polysurfaces.
SimpleCenterline_Of_Pipe.ghx (79.7 KB)
EDIT: Oh dear, I just tried the file that you uploaded, and this definition doesn’t work at all. It’s definitely optimized for tubes of a circular cross-section persuasion.
Nowadays, however, when sculpting a tube element, I’ll manipulate the center-line curve and use a Grasshopper definition to preview the resulting tube surface. This method is useful if you want to maintain an undistorted cross section on the tube. The second definition is what I use for this method.
TubeFromCL.gh (8.4 KB)
Hope this helps.