Problem on insert many component

advice

#1

Hello every-one

I try to insert many components (i try with 1000 and more) but it’s take to many time to insert all components. How can I make it more faster pleaz :slight_smile:

Actually i use this :

foreach (components)
_ #I Inititalise component before but i test it and there is no time problem with this._
transf = Geom::Transformation.new insertion_point
new_instance = entities.add_instance component.componentDefinition , transf

end

The problem is just on this line
new_instance = entities.add_instance component.componentDefinition , transf

that work quicly with 10 component but with 1000 and more that to long (approximatly 15 minutes)
Thanks for help


#2

Have you wrapped your code in an operator? The operator makes all changes performed by the code use the same slot in the undo stack (which means undoing once undos them all) and can also be used to prevent SketchUp from redrawing the view between each change.

Sketchup.active_model.start_operation("Name", true)
# code goes here...
Sketchup.active_model.commit_operation

#3

Thank you so much, it’s work

I put this and now i can insert many component in some seconds.

Really, thank you


#4

No problems.

You can read more about the uno stack and operators here: http://www.thomthom.net/thoughts/2014/06/sketchup-extensions-ux-dont-break-undo/


#5

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