Anyone have an idea how to find the center point through a model from start to end?
I can’t seem to find an API that supports this.
Alternative (a bit clearer / more technical):
Does anyone know a good way to compute a model’s centerline (center point path) from one end to the other?
I haven’t found an API that can do this out of the box.
I wonder, for example, where is the centerline of this model?
Where this model start and where is the end?
On what basis would anyone generate a centerline? How many of centerlines are there? Which ones are you talking about?
The API is there, but I don’t think there’s a method like “create_a_centerline_of_model”. You need to define more precisely what you want.. and create your own method.
ehm, i want to find the centerpoint trueout the pipe from start to finish, like the exact route, so i can reuse it in civil3d. so i have the centerline of the pipeline from a single click, i understand?
No, there is no such method. Basically, everything in Sketchup consists of edges and the faces they bound. So it will be quite difficult to determine which edges make up the tube and in what order…
Some ideas:
Edges can be part of (defined by) ArcCurves, for which there is a method for determining the center, for example. So you have to examine the model and search edge by edge based on certain properties..
Or you can also observe the bounding boxes of entities, or collection of entities.
I linked to another method in my previous post.
So i have been trying prob 10 different ways to get this done, ray tracing, edges, wireframe and what not. But i cant seem to get happy with the results, dosnt really work.. i think im might fucking it up myself haha
one of my approches way like, creating guide points from the ray trace, then making those “point clysters” in to one group, making a senterpoint from each selected groupes and then creating a line form start to finish from the points.. but i dosnt work on all models…
yeah, the api. Just cant wrap my head around what would accualy work on all models, not matter what. tried to diffent codes in one, like first finding all edges then doing the ray trace arpudn the model with x-sections.. but cant seem to make it work properly
There are multible selections like this, for this to work the best on pipes u can use the 3 point selection to accualy get the middle point of a circle.
But i want to automate this process from the begnning.
Appreciate all the input. Just to reset the scope: my goal is programmatic reconstruction of a pipe centerline in SketchUp Ruby, not manual modeling steps.
The pipe is typically imported/triangulated and can be made of multiple sections with bends/offsets, so bounding-box center or a single centroid/COM isn’t usable.
What I’m looking for is an approach like:
detect circular/near-circular cross-section “rings” along the tube (edge loops or face loops),
fit circles in 3D (least squares) to get ring centers + local axis,
connect those centers into a clean polyline (then optionally smooth).
Alternative approaches (ray casting to find local interior center, or any skeletonization/medial-axis approximation that’s feasible in Ruby) are also welcome.
If you’ve got sample code or known patterns for (a) ring detection, (b) 3D circle fitting, or (c) robust centerline tracing through mesh tubes in SketchUp’s API, that would be super helpful. I’ll share what I end up implementing once tested.
Added 2 .skp files with 2 different types of creation of the pipes, for example