I am really confused about how the transaction start commit system is supposed to work when they are firing off like this. Here is the output from me opening a component, adding a single edge inside it, then closing it
If I remember correctly, the order in which observers are added can affect the order of their “reaction”.
I have no idea how your code is looks like…
Another experience I have is that there are mysteries (bugs) around some of them.
But I “played” with them a long time ago.
i read the PDF and it looks like mine is not behaving the way the PDF says it should. For loose geometry it behaves normally:
start operation>add/remove/modify>commit operation
but for geometry inside a component or group I get start>commit>add/remove/modify
class MyModelObserver < Sketchup::ModelObserver
def onActivePathChanged(model)
puts "onActivePathChanged: #{model}"
$current_entities_observer = MyEntitiesObserver.new
if Sketchup.active_model.active_path && ($current_path = Sketchup.active_model.active_path.last)
$current_path.definition.entities.add_observer($current_entities_observer)
else
Sketchup.active_model.entities.add_observer($current_entities_observer)
end
end
def onTransactionStart(model)
puts "onTransactionStart: #{model}"
end
def onTransactionCommit(model)
puts "onTransactionCommit: #{model}"
end
def onTransactionUndo(model)
puts "onTransactionUndo: #{model}"
end
def onTransactionRedo(model)
puts "onTransactionRedo: #{model}"
end
def onTransactionAbort(model)
puts "onTransactionAbort: #{model}"
end
def onTransactionEmpty(model)
puts "onTransactionEmpty: #{model}"
end
end
class MyEntitiesObserver < Sketchup::EntitiesObserver
def onElementAdded(entities, entity)
puts "onElementAdded: #{entity}"
end
def onElementModified(entities, entity)
puts "onElementModified: #{entity}"
end
def onElementRemoved(entities, entity_id)
puts "onRemoveEntities: #{entity_id}"
end
def onEraseEntities(entities)
puts "onEraseEntities: #{entities.map(&:entityID)}"
end
end