Well, a start of explaination and solution, here :
http://forums.sketchup.com/t/edge-change-observer/8184 :
Put an observer on edge.start and edge.end
Thanks TT !
Well, a start of explaination and solution, here :
http://forums.sketchup.com/t/edge-change-observer/8184 :
Put an observer on edge.start and edge.end
Thanks TT !
Hello,
For one of my plugin, I want to catch when a component is modified (ie entities inside the component are moved, stretched, erased, added, etc).
My problem is to trigger an observer when moving an edge (single edge not attached to a face) using moving tool.
Do do so, I placed an observer on model to catch when the active path is changed, and then add on observer on entities within active_entities :
class MyModelObserver < Sketchup;;ModelObserver
@@observers = {}
@@previous_path=nil
def onActivePathChanged(model)
puts "onActivePathChanged "+Sketchup.active_model.active_entities.to_s
#remove previous observer if exist
if @@previous_path!=nil then
puts "Remove observers of "+@@previous_path.to_s
p @@previous_path.remove_observer(@@observers[@@previous_path])
@@previous_path=nil
end
#Quit if active_path is nill (no group or component is opened)
return if !Sketchup.active_model.active_path
#define observer object and try to add it to active_entities
#if it is successfully added, update class variable @@observers
observer = MyEntitiesObserver.new()
if Sketchup.active_model.active_entities.add_observer(observer)
#Save observers data
@@observers[Sketchup.active_model.active_entities] = observer
@@previous_path=Sketchup.active_model.active_entities
#Add observers to each entity of active_entities
for entity in Sketchup.active_model.active_entities
entity.add_observer(MyEntityObserver.new)
end
end
end
end
class MyEntityObserver < Sketchup;;EntityObserver
def onEraseEntity(entity)
puts "onEraseEntity; #{entity}"
end
def onChangeEntity(entity)
puts "onChangeEntity; #{entity}"
end
end
class MyEntitiesObserver < Sketchup;;EntitiesObserver
def onElementAdded(entities, entity)
puts "onElementAdded "
end
def onElementModified(entities, entity)
puts "onElementModified "
end
def onElementRemoved(entities, entity_id)
puts "onElementRemoved"
end
def onEraseEntities(entities)
puts "onEraseEntities"
end
def onChangeEntity(entity)
puts "onChangeEntity; #{entity}"
end
end
Then running the script :
Sketchup.active_model.add_observer(MyModelObserver.new)
I cannot see any "modification" observer triggers when when moving a simple edge not attached to a face, within a component...
If someone can help me...
Inteloide
Hello there !
I take benefit of this post to say that I have an example of one file with 2 components instances from 2 different definitions but with the same GUID.
So of course GUID is not unique.
My question : is the EntityID unique, but really unique within the same model ?
I mean, it may be a random number but the random number is checked to be sure that it's really unique.
Best regards.
Inteloide
Hello Greenskp,
Everything is working fine on my computer.
According your screen recorder, you have an issue "$ not defined" : it looks like jquery is not working correctly. Also, the height of the area where to enter text is smaller than expected.
Please try to install again the plugin. Sometimes it works.
If you have the same error, replace the pt-br.js file you send me by the previous version.
Keep me informed.
Inteloide
Hello Greenskp,
Please find here a new version that include requested improvements.
Please, keep me informed if it's ok for you.
Best regards
Inteloide
Hello,
New version 2.3.9 should correct this issue.
Please download it from the store (with new version of BGSketchup Library)
Inteloide
Hello !
Is there any way to link Sketchup to a MySQL database in pure ruby ?
I look for in history of posts, I only see answers from years now, and I guess new version of Sketchup (with ruby core update) can do it more easily.
I know that I can link through javascript/php code. I wonder if a pure ruby code can be simply written to do so.
This may required installation of Gem and DevKit, but please if somebody can explain step by step how to proceed, it would help me a lot !
Thank you for your help.
Best regards.
Inteloide
Bonjour,
Il vous faut télécharger la dernière version de BGSketchup_Library (la version 2.3.2).
Pour cela, vous pouvez allez, dans Sketchup, dans le menu Extension puis BGSketchup puis BGSketchup update manager.
Là vous tomberez sur l'interface qui vous permettra de mettre à jour vos plugins.
Sinon, vous pouvez passer par le PluginStore de SketchUcation.
Cordialement
Inteloide
Hello Lê,
Please download the latest update of BGSketchup Library from the store (version 2.3.1).
It may solve your issue.
To answer your question, comments are saved inside Model (let's say Inside skp file).
If you loose some comment, you can send me your file (even if you delete everyhting inside) and I will try to recover it.
Inteloide
Hello TIG,
Thank you for the explainations. It's what I was thinking when I had the error...
The problem is that the group/component to duplicate can be huge and take time to copy.
If think I will take the problem in this opposite way, making a loop in entities, from model to the component instance collecting each time the transformation of each group/component.
Do you think there is an opportunity to find an easiest solution with the Sketchup.active_model.selection (when selecting component in model, the ruby gives good volume, but when selecting component through ruby code, the ruby gives bad volume?
Inteloide