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
Hello TIG,
Thanks for your explainations : your example works.
Nevertheless, this is not my issue : the problem is the volume of a component within a group when group is scaled.
Please have a look to attached file.
If you run the code :
Sketchup.active_model.definitions[0].instances.each{|i| p i.volume }
You will have a volume which doesn't correspond with cube size !
Inteloide
Hello TIG,
Not sure to understand clearly your answer : I tried duplicating the group "The group", but volume still not good.
Inteloide
And stronger : if I select the component "The cube" in the model (by modifying "The group") and type in console : Sketchup.active_model.selection[0].volume
, then I get the correct volume...
And more stronger : if I select nothing and type this code :
Sketchup.active_model.selection.add Sketchup.active_model.definitions[1].instances[0] Sketchup.active_model.selection[0].volume
, then the volume is wrong again !
Hello,
I try to get the volume of a component, which is placed in a group and this group is scaled.
For example : I draw a 100010001000mm box, I make a component called "The cube".
On one face of "The cube" (not within the component), I draw a simple line.
Then with the line and the cube, I make a group called "The group".
Then I scale "The group" by factor 2 (double the size).
When I look at entity info inspector, the volume is correct (= it's taking into account the scaled), but when I try to get volume from code : it's wrong (= unscaled volume).
Here is the code :
volume=Sketchup.active_model.definitions[1].instances[0].volume
(NB : definitions[1] correspond to "The cube" 's definition).
=> then the results is the volume of the unscaled component "The cube" (may the definition's volume).
Do somebody has a any idea why and a simple workaround ?
By my side, the only way looks like getting the parent transformation of "The cube", but if I search for Sketchup.active_model.definitions[1].instances[0].parent, this doesn't return the Group, but the definition...
Thank in advance for your help.
Best regards.
Hello Gents !
Thank you for contacting me on this topic.
To be honest I was warned by users that errors can appear on older version of Sketchup but it's quite difficult to program on multiple version of a software...
But thanks to TIG analysis I'll correct the BGSketchup Library.
Inteloide
Hello,
Please download version 2.3.7 from the store or from the first post of this thread, and please tell me if solved your issue.
Best regards.
Inteloide
Hello,
thank you for translation : I added it to the plugin.
Please try attached version which should solve your issue, and let me know in order to officially post this version.
Improvements are :
2.3.7 Corrected : Avoid menu error
Optimized : Added chinese languages (thanks to chialiang168)
2.3.6: Updated : version of ckeditor update to 4.4.5
Added : Change tab key behavior to add spaces (4)
Corrected : enter key now make a simple return to line
Regards.
Inteloide
Hello,
I would like to propose you my new plugin : BGSketchup_RBZ_maker
The purpose of this plugin is to make the process of extension rbz creation easier.
Note : This plugin is for extension authors.
Once sketchup launched, click on the toolbar icon or through menu (Plugins >> BGSketchup >> RBZ maker)
You can then choose your extension, then choose wich files to scramble/encrypt, then destination file name (currently plugin propose you the plugin name + version), then generate !
May I have your help on :
The plugin :
Thank you.
Inteloide (BGSketchup)
Restrictions :
-You must have Sketchup 2015 (because of rubyzip gem installation, or is there another way ???)
-You must have the gem rubyzip installed (the rbz contains one version of it) to install it, just run in Ruby console Gem.install 'c:\toto\rubyzip', where c:\toto\ is the directory name of the gem file.
-Your extension file structure contain a sub-folder with the same name that root extension file. Example :
@unknownuser said:
extension_toto.rb
extension_toto/main.rb
extension_toto/second.rb
-This plugin require BGSketchup_Library extension (you can find it on the Pluginstore)
Informations :
This plugin send anonymous data to my website (just for statistic analysis). Data can be consult at BGSketchup website. If this is a problem, I can remove the feature. I include this to know how often my plugins are used, to keep motivation in creating new plugins.
Hello,
Just post version 1.0.1, which remember which file to encrypt.
(Hey I'm quite surprised plugin authors don't rush on it (only 3 downloads of 1.0.0) ! For me this is so much more easy to create extension using this plugin ! Or may be like driven, some of you developped your own solution to make it easier ??)
Inteloide