New: Sketchup::Entities#weld instance method - quick look

Disclaimer: Nothing special, I’m just thinking out loud to see if it will be useful for someone …

I recently noticed that a new method has appeared in the latest version of Sketchup (20.1.235):

#weld(edges) ⇒ Array<Sketchup::Curve>

The #weld method takes a set of edges and find all possible chains of edges and connect them with a Curve.
A curve will not cross another curve. They will split where multiple curves meet.

There are several plugins (extension) currently in EW and PluginsSore, for example by Eneroth, Fredo, s4u, TIG, Smustard Team… etc. which was made for similar reasons.

I was wondering how this new method works, so I compared it to a randomly selected existing plugin:

The comparison was made on this file:
weld_test.skp (118.4 KB)

#I assume that the edges are preselected:
start_time =
edges = TIG.weld
end_time =
puts "TIG-weld converted #{edges.length} edges to curve in #{end_time -start_time} sec"
#> TIG-weld converted 2002 edges to curve in 8.827291 sec

Then I created a test Extension:
Dezmo_SU_weld_Beta 2020_0719_1219.rbz (11.0 KB)

And run on the same edges with this result:

#> SU weld by Dezmo: 2002 edges converted to 1 curve in 0.054669 sec

Pretty impressive!
However the example in the documentation is quite incomplete, i.e.
model = Sketchup.active_model”
is missing.

Happy wedding!

Welding <-> Wedding

Both are about the unbreakable connection, aren’t they? :stuck_out_tongue_winking_eye:


The speed is not really a surprise since the new API method is using compiled code.

Of course not… and the comparison is not the most accurate either. :blush:
I just wanted to point out with my simple extension, that it’s much easier and quicker to weld now. :+1:t4:

However I’m curious what kind of logic used sorting the edges (vertices) with the new method? Is that similar that used by TIG (Rick Wilson ) or something completely different?

Is that the tool icon?

Of course! :blush:

That’s not the main thing that makes it fast. Remember the Ruby API is just a thin wrapper on top of our C++ core anyway.

They key difference is that the new Weld API only needs to resolve the set of edges making up a curve and assign the appropriate Curve reference for the edges.

Compare that to the workaround ways of the past where a temp group was created in order to create temporary edges using entities.add_curve and then exploding the temp group relying to internal details of how entities are merged together.

It’s not so much of Ruby vs C++ as it is doing a whole lot less work.

1 Like

Ooops! Thanks for spotting that - logged: Example for weld incomplete · Issue #521 · SketchUp/api-issue-tracker · GitHub


Good point! :+1: