Estimate time taken to explode a model

Hi,

I am working on a plug-in for ScketchUp that requires to explode the model. Since exploding is a slow procedure I would like to estimate the time it takes to warn the users of the plug-in about it.

I tried to estimate the time a explode operation takes by counting the time taken by the whole explode operation divided by the number of the export operations performed (which is done following this thread Counting explode operations to be performed in a model). After exploding 20-30 models I could see the average time for a explode operation is not very consistent, for most of the models it ranges from 0.5 to 3 seconds, but I have seen cases were it was as quick as 5e-3 seconds and others as slow as 25 seconds.

Is there a better way to estimate how long would take the explode of a model?

best regards, Carlos
.

The amount of geometry within the group or component has a large (perhaps linear) impact on the time required to perform the explode operation. Components with thousands or tens of thousands of edges and faces take much longer to explode than do simple components.

Dear TDahl,

thanks for your reply. That’s very interesting perhaps I could try to estimate the averaged time per explode operation per entity in the exploded group/component. If this is stable across the tested models then it could be used to estimate the total time taken to explode the whole model.

I will try this and post my conclusion here

regards, Carlos

I think it is worse than that. SketchUp has to process any interaction between loose edges and faces generated by the explode and any pre-existing ungrouped edges and faces in the model - including ones from the previous explodes! Maybe some complicated combinatorial rather than linear.

@slbaumgartner makes a good point: the time to explode is a function of both the object being exploded, and the geometry within the context into which it is being exploded. My comment about linearity did not take the context’s geometry into account.

Dear slbaumgertner

thanks for your reply, seems that the time estimation I seek is not going to be easy.

Anyway, is it even possible to count the number of faces and edges in a group/component without exploding it?

regards, Carlos

You can access the group or ComponentDefinition’s Entities collection and do something like

num_edges = ents.grep(Sketchup::Edge).count
num_faces = ents.grep(Sketchup::Face).count

… and then multiply those numbers by the definition’s used instances …

edge_count = 0
face_count = 0
model.definitions.each do |compdef|
  num_used = compdef.count_used_instances
  if num_used > 0
    edge_count += compdef.entities.grep(Sketchup::Edge).count * num_used
    face_count += compdef.entities.grep(Sketchup::Face).count * num_used
  end
end
edge_count += model.entities.grep(Sketchup::Edge).count
face_count += model.entities.grep(Sketchup::Face).count

1 Like

Dear DanRathbun,

thanks for the script!, I have been studying the time spent in exploding a model divided by the number of faces + edges contained in Groups/Components for 15 different models resulting in ratios ranging from 5e-5 to 1.5e-3 seconds. As commented above we should not expect a linear response, still this is much more stable that just taking the time and divide by the number of Groups + Components

regards, Carlos