Problems arise after a large number of upward fusion operations
line = Sketchup.active_model.entities.add_line ORIGIN, ORIGIN.offset(X_AXIS, 10.m)
10.times do |i|
Sketchup.active_model.start_operation('', true, false, true)
line.set_attribute('DFC', 'index', i)
Sketchup.active_model.commit_operation
end
Undo, edge has been deleted.
line = Sketchup.active_model.entities.add_line ORIGIN, ORIGIN.offset(Y_AXIS, 10.m)
1000.times do |i|
Sketchup.active_model.start_operation('', true, false, true)
line.set_attribute('DFC', 'index', i)
Sketchup.active_model.commit_operation
end
Undo, edge cannot be revoked.
I think the Undo stack has a limit to around 100. This may explain the problem.
By the way, I am not sure why you need to have the start_operation INSIDE the loop, rather than OUTSIDE.
By the way, I am not sure why you need to have the
start_operationINSIDE the loop, rather than OUTSIDE.
Because of the EntitiesObserver. I need to listen to the added entities and perform some operations. Of course, it's rare for observers to be triggered hundreds of times, but this situation still exists.
I think mergers should always be done once, no matter how many times they occur
The undo stack has a limit, yet. Currently 1000, used to be 100 in older versions.
Transparent operations don't add to previous, but chain. Undo/redo will iterate over transparent operations until a non-transparent is reached.
I need to listen to the added entities and perform some operations. Why do you need an observer in this case? Observers are mainly useful when your own code isn't in control of the model changes. In this case you have control. Seems redundant to create a chain of transparent operations like this. (I'd advice against it)
I need to listen to the added entities and perform some operations. Why do you need an observer in this case? Observers are mainly useful when your own code isn't in control of the model changes. In this case you have control. Seems redundant to create a chain of transparent operations like this. (I'd advice against it) You are right. But
I have paused all observers within my controllable code. I am just a task merging operation, which should not be counted as one operation unless there are no operations that can be merged. That is to say, merging operations can only be counted as one operation at most after 100 times, so as not to occupy the entire undo stack