Script for adding groups slows down

Good Afternoon All

I found the script below which is working fine for the first 1,000 surfaces to groups. After that it is slowing selection each further selection. The add_group function seem to be the issue. After the script slowed down, I tried to add a group to a surface manually and that also works slow now
I have searched the Internet extensively to find a solution but no luck. Is any expert able to help me ?

The surfaces are in various layers, the script is run in every layer individually

I have tried the following;
• Window- Model Info - Statistic - Purge unused frequently
• save and restart (in case the Undo function is slowing it down)

model = Sketchup.active_model
active = m.active_entities
c = 0
m.commit_operation;puts "Made #{c} face groups"

SketchUp layers are a display property. They do not have entities collections.

Generally geometric primitives (edges, faces, arcs, curves, polygons) should be assigned to use “Layer0” (or be “Untagged” in recent SketchUp versions.)

P.S. - Please update your forum profile to show your SketchUp version.

Thanks for your reply. I will create the surfaces in layer 0 and then create the groups in layer 0 and split them in layers after completion.

Good evening Dan

I have tried the suggested and read the links but I am prob too much of newby to understand it all. I created all lines and faces in Layer 0 but whein I run the script the PC is getting in the “not responding” mode and after 24 hr I abandoned the operation. When selecting 500 faces it works ok, when selecting the next 500 the speeds halves. I copied a part into a new drawings and ran the same script it is fast again, but when then importing it is also takes ages.

I had a look at this script Entities.add_group takes about 9 seconds when adding a face but it gives an error with the label

Perhaps any other suggestion before I need to give up?

Error: #<NoMethodError: undefined method `label_face' for main:Object>
<main>:3:in `block in <main>'
<main>:2:in `each'
<main>:2:in `each_with_index'
<main>:2:in `<main>'
SketchUp:in `eval'

I bought the extension s4u_tocomponents and it did the trick 48,000 faces converted to components in less then an hour

1 Like