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:
TIG-weld

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

#I assume that the edges are preselected:
start_time = Time.now
edges = TIG.weld
end_time = Time.now
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!
weld

Welding <-> Wedding

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

1 Like

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: