Commit_operation takes too long

You might even squeeze more out of that. You create the same string 3 times there - creating objects is slow in Ruby. And composing strings out of + is the slowest of them all. Fastest string creating is using string literals: "#{name}##{cnt}"

1 Like

According to my testing groups do not experience this same problem.

1 Like

Using
Class: Sketchup::DefinitionList — SketchUp Ruby API Documentation
should return a unique definition name based on your ‘root’ name.
So that’s probably even quicker ?

name = Sketchup.active_model.definitions.unique_name("test")
# e.g.  "test#22"
cd = Sketchup.active_model.definitions.add(name)
# etc

I just tested it and that is in fact the method that is the problem. I’m sure SU runs that same method when you try to create a new component.

1 Like

Indeed - it performs a linear search.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.