Hi , I am looking for a hook before deleting an entity or is there a way where i can figure out entity details before deleting that .
Basically i am looking for just before deleting a function/event .
Thanks
@DanRathbun @Aerilius @TIG need help
An Observer ?
e.g. Class: Sketchup::EntitiesObserver — SketchUp Ruby API Documentation
Class: Sketchup::EntitiesObserver — SketchUp Ruby API Documentation
Class: Sketchup::EntitiesObserver — SketchUp Ruby API Documentation
But note its limitations - what do you want to do exactly ?
hi . when user manually press DELETE key from keyboard after selecting an entity , then in “MyEntitiesObserver < Sketchup::EntitiesObserver” there is one method called “onElementRemoved” .
But this method called when after entity deleted.
I want something on before deleting an entity so that i can check whether user is able to delete it or not.
just a method/event when user press DELETE key.
(a)
It is not necessary to ping most of us as we are “watching” this category. I am always shown new posts here.
(b)
You cannot prevent a native Delete. However Group and Component Instances can be locked and they have a #locked?
query method that can tell you ahead of time whether they can be deleted or not. (These objects can also not be modified by other tools when locked.)
(c)
Most all of the API observer event callback methods have a default post-event firing. Only those with name prefixes onBefore...
or onPre...
are specifically pre-event firing.
All that said … you can use the Sketchup::SelectionObserver
to watch what the user selects, and cache the desired data, and then as TIG said also watch what the user deletes.
thanks @DanRathbun
thanks @TIG