SketchUcation Plugin Store

 

 

[observer issue] onEraseEntities not working?

[observer issue] onEraseEntities not working?

Postby dereeei » Wed Nov 24, 2010 2:30 am

I made some tests with EntityObserver and EntitiesObserver classes and it looks like onEraseEntities method doesn't work, or I don't know how to use it?
I tried the same thing with onEraseEntity and it works.

This didn't worked. Nothing happens
Code: Select all
class MyEntitiesObserver < Sketchup::EntitiesObserver
   def onEraseEntities(entities)
      puts "Erased: " + entities.to_s
   end
end

begin
x = 0
   Sketchup.active_model.entities.each do |e|
         e.add_observer(MyEntitiesObserver.new)
         x += 1
   end
   puts 'Observer was added to ' + x.to_s + ' elements.'
end


This told me what I wanted to see:
Code: Select all
class MyEntityObserver < Sketchup::EntityObserver
   def onEraseEntity(ent)
      puts "Erased: " + ent.to_s
   end
end

begin
x = 0
   Sketchup.active_model.entities.each do |e|
      e.add_observer(MyEntityObserver.new)
      x += 1
   end
   puts 'Observer was added to ' + x.to_s + ' elements.'
end
dereeei
 
Posts: 564
Joined: Tue Nov 16, 2010 1:48 pm
Name: derei

Re: [observer issue] onEraseEntities not working?

Postby thomthom » Wed Nov 24, 2010 9:20 am

I've not had that event working either. The EntitiesObserver has been trouble since the beginning.
What SketchUp version are you testing on? There has been some changes in SU8.

See this chart where I've tried to map the functionality of each event in the various SU versions: http://www.thomthom.net/software/sketch ... esObserver
(Note that the chart is probably not 100% accurate so if you have more info I'd be very interested in this.)
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17556
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: [observer issue] onEraseEntities not working?

Postby morph » Wed Mar 14, 2012 6:54 pm

to thomthom

I interest to use EntitiesObserver.onElementModified or EntityObserver.onChangeEntity to check face entity has modified or not?

But after I read the illustrate under both method from https://developers.google.com/sketchup/docs/ourdoc/entitiesobserver ("The onElementModified method is invoked whenever one or more elements in the collection are modified.") and https://developers.google.com/sketchup/docs/ourdoc/entityobserver ("The onChangeEntity method is invoked when your entity is modified.")

I can not understand the scope of meaning of modified state of face entity. The word "modified" mean scaling, moving, reverse, split or more. I am new in programming, please suggestion.

Hope you will understand my question?
morph
 
Posts: 3
Joined: Sun Aug 07, 2011 3:50 am

Re: [observer issue] onEraseEntities not working?

Postby Dan Rathbun » Thu Mar 15, 2012 12:10 am

That's interesting.. I did not realize we could make code blocks have smaller text.
User avatar
Dan Rathbun
Top SketchUcator
 
Posts: 4069
Joined: Tue Oct 06, 2009 3:06 am
Location: Florida, USA
Name: Dan Rathbun
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: education
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Artisan Organic Toolset - a set of powerful organic modeling tools.

Premium Members get 20% discount!

Ad Machine
Robot
 
Posts: 2012


Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 3 guests