[Plugin] Eclate_Deplace (fragmentation-exploded view)
-
Hi all,
just a little precision
plugin Pilou
model = Sketchup.active_model entities = model.entities selection = model.selection xp=100 # Pivot Point (as you want) yp=100 zp=100 q=50 # Measure of translation (as you want) selection.each do |e| # update! # Skip all entities that aren't groups or components (replace follow "ComponentInstance" by "Group" if you have groups next unless e.is_a? Sketchup;;ComponentInstance # Now we process the component or group center = e.bounds.center #Center Point of the grouped object xc= center.x yc= center.y zc= center.z xe=xc #End Point of the grouped object ye=yc ze=zc if xc<xp xe =xc - q end if xc>xp xe =xc + q end if yc<yp ye =yc - q end if yc>yp ye =yc + q end if zc<zp ze =zc - q end if zc>zp ze =zc + q end point = Geom;;Point3d.new xe,ye,ze t = Geom;;Transformation.new point # Apply the transformation e.transform!(t) end
plugin modified by me
# Designed December 2009 by C.plassais + Pilou # Permission to use this software for any purpose and without fee is hereby granted # Distribution of this software for commercial purpose is forbidden; # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #----------------------------------------------------------------------------- # Name ; Eclate_Deplace # Original Date ; 03 Juil 2009 version 0.0 (thx to TIG, Thomthom) # Type ; Plugin # Description ; Exploding movements of groups or/and components # Usage ; Right Click - Context Menu # Version 0.3.2 #--------------------------------------------------------------------------------------- # petit plug d'explosion deplacement" de groupes ou de composants require 'sketchup.rb' def pilou_explose myModel = Sketchup.active_model myEntities = myModel.entities selection = myModel.selection if selection.empty? UI.messagebox "Veuillez Selectionner des\nComposants ou des Groupes" end myModel.start_operation "Deplacement Eclate",true group = myModel.active_entities.add_group(selection) centre_selec = group.bounds.center point_ligne = UI.messagebox "Voulez-matérialiser les déplacement \npar des points et des lignes de construction", MB_YESNO (point_ligne == 6) ? (myEntities.add_cpoint (centre_selec)) ;() resultat1 = UI.messagebox "Voulez vous faire une copie de l'original", MB_YESNO if resultat1 == 6 group2 = group.copy group2.explode end selection = group.explode cent_selec_x = centre_selec[0].to_i # determination cent_selec_y = centre_selec[1].to_i # du centre de cent_selec_z = centre_selec[2].to_i # la selection prompts = ["Ecarter ou centrer/par rapport au pivot", "Deplacement pivot x", "Deplacement pivot y", "Deplacement pivot z", "Coef translation x de 0 a...", "Coef translation y de 0 a...", "Coef translation z de 0 a...", "Groupe Composant les 2"] val_defaut = ["Centrer", cent_selec_x, cent_selec_y, cent_selec_z, 1.00, 1.00, 1.00, "Les 2"] liste_val = ["Centrer|Ecarter", "", "", "", "", "", "" , "Groupe|Composant|Les 2"] results = UI.inputbox prompts, val_defaut, liste_val, "Parametres" return if not results decent_pivot, deplac_pivot_x, deplac_pivot_y, deplac_pivot_z, coef_trans_x, coef_trans_y, coef_trans_z, group_ou_comp = results # Translation des axes suivant unites convertit = [] convertit[0]= 1.inch convertit[1]= 1.feet convertit[2]= 1.mm convertit[3]= 1.cm convertit[4]= 1.m/100 uniteCourante = myModel.options["UnitsOptions"]["LengthUnit"] coef_trans_x = coef_trans_x.to_f * convertit[uniteCourante] coef_trans_y = coef_trans_y.to_f * convertit[uniteCourante] coef_trans_z = coef_trans_z.to_f * convertit[uniteCourante] # Calcul de la distance entre le centre d'origine de la selection et le nouveau nouv_pivot_x = cent_selec_x-deplac_pivot_x nouv_pivot_y = cent_selec_y-deplac_pivot_y nouv_pivot_z = cent_selec_z-deplac_pivot_z case decent_pivot when "Ecarter" (point_ligne == 6) ? ( myEntities.add_cpoint [(cent_selec_x + nouv_pivot_x), (cent_selec_y + nouv_pivot_y), (cent_selec_z + nouv_pivot_z)] myEntities.add_cline [cent_selec_x, cent_selec_y, cent_selec_z],[(cent_selec_x + nouv_pivot_x), (cent_selec_y + nouv_pivot_y), (cent_selec_z + nouv_pivot_z)]) ; () when "Centrer" nouv_pivot_x = - nouv_pivot_x nouv_pivot_y = - nouv_pivot_y nouv_pivot_z = - nouv_pivot_z (point_ligne == 6) ? ( myEntities.add_cpoint [deplac_pivot_x,deplac_pivot_y,deplac_pivot_z] myEntities.add_cline [cent_selec_x, cent_selec_y, cent_selec_z],[deplac_pivot_x, deplac_pivot_y, deplac_pivot_z]) ; () end case group_ou_comp when "Groupe" group_ou_comp = comp_ou_group = Sketchup;;Group when "Composant" group_ou_comp = comp_ou_group = Sketchup;;ComponentInstance else group_ou_comp = Sketchup;;Group comp_ou_group = Sketchup;;ComponentInstance end selection.each do |e| # debut de la transformation next unless (e.is_a? group_ou_comp) or next unless(e.is_a? comp_ou_group) centre_objet = e.bounds.center centre_objet_x = centre_objet[0].to_i # Determination centre_objet_y = centre_objet[1].to_i # du centre centre_objet_z = centre_objet[2].to_i # de l'objet (centre_objet_x == cent_selec_x) ? (nouv_centobj_x = nouv_pivot_x) ; (nouv_centobj_x = ((centre_objet_x-cent_selec_x) * coef_trans_x) + nouv_pivot_x) (centre_objet_y == cent_selec_y) ? (nouv_centobj_y = nouv_pivot_y) ; (nouv_centobj_y = ((centre_objet_y-cent_selec_y) * coef_trans_y) + nouv_pivot_y) (centre_objet_z == cent_selec_z) ? (nouv_centobj_z = nouv_pivot_z) ; (nouv_centobj_z = ((centre_objet_z-cent_selec_z) * coef_trans_z) + nouv_pivot_z) point_trans = Geom;;Point3d.new nouv_centobj_x,nouv_centobj_y,nouv_centobj_z t = Geom;;Transformation.new point_trans e.transform!(t) (point_ligne == 6) ? ( nouv_centobj = e.bounds.center myEntities.add_cpoint (nouv_centobj) myEntities.add_cpoint (centre_objet) constline = myEntities.add_cline [centre_objet_x, centre_objet_y, centre_objet_z],nouv_centobj constline.stipple = ".") ; () myModel.selection.add e end myModel.commit_operation end # pilou_explose if( not file_loaded?("Eclate_Deplace.rb") ) UI.add_context_menu_handler do |context_menu| context_menu.add_separator context_menu.add_item("Eclate_Deplace") { pilou_explose } end file_loaded("Eclate_Deplace.rb") end
Thanks
Christophe
-
No problem
Idea Pilou for training Ruby 5%
Realisation Ruby C.Plassais 95% -
I'm using the latest version of sketchup and I get a bug splat every time I try to use Eclate.
Even with a simple cube. As soon as you click yes or no on the copy dialog it shuts down and goes to bug splat.
-
@box said:
I'm using the latest version of sketchup and I get a bug splat every time I try to use Eclate.
Even with a simple cube. As soon as you click yes or no on the copy dialog it shuts down and goes to bug splat.
you should only use Eclate_Deplace with components or groups
-
@unknownuser said:
Anyone experiencing Bugsplats with SU7.1 and this plugin?
Haven't used since last SU update now it Bugsplat everytime. I've attached the model if anyone want to see if it's just me?
I know i have the components nested in a component but use this plugin when not nested
It doesn't bug splat for me, but I am still using SU v7.0.10247. It doesn't do much with that file either, except add one guide point?
I tried it on an ungrouped 3D pushpulled rectangle and also not bug splat. So could be something not compatable with the latest version of sketchup.
-
@kyyu said:
... It doesn't do much with that file either, except add one guide point?
I tried it on an ungrouped 3D pushpulled rectangle and also not bug splat. So could be something not compatable with the latest version of sketchup.
Why would you use it on an "ungrouped 3D push/pulled rectangle"? The plugin is intended to move components away from each other to create an exploded view of this sort.
-
@dave r said:
@kyyu said:
... It doesn't do much with that file either, except add one guide point?
I tried it on an ungrouped 3D pushpulled rectangle and also not bug splat. So could be something not compatable with the latest version of sketchup.
Why would you use it on an "ungrouped 3D push/pulled rectangle"? The plugin is intended to move components away from each other to create an exploded view of this sort.
Because a few post up, Box said he was getting bug splats on everything; even with a simple cube. So I tested it, but maybe he meant a cube made of grouped sides? Anyways, I was checking for bug splats and didn't find any. But, like I noted, I'm using v7.0 of sketchup.
-
Yes I was using a cube of grouped faces, and at first I was getting a bug spat every time, now it is random.
I have rebooted and added updates and a few other bits and pieces since then, sorry that's not a very useful bit of diagnostic information but I've been doing too many things at once.So to put it simply, It does work for me but it is unstable and I have yet to work out what, if any, conditions cause the bug splat.
-
Two versions of the plugin that can be corrected bug
I've written a 3.0.2 version and also a rewritten version by the genius Fredo. Thanks FredoSorry I can not insert in the original post ...
The limitation of this plugin is that it does not take into account the size of groups or components.
It moves only the elements from their center. Perhaps a future versionChristophe
Eclate_Deplace english version 3.0.2
version 3.0.2 rewritten by fredo ChrisP_RadialMove -
Added to the first post
-
Thank Pilou
-
-
dear guys,
is there any possibility of this plugin have crashed with other plugin?
ok, here is what i did:
- i copy the newest version 3.0.2
- then rename it so its just Eclate_Deplace.rb
- i create simple cube, and then group it
- when i right click on the group and choose eclate_deplace, no dialog box showed up and i got this messages
please,somebody help me to solved this issue, thank you..
regards,
-
Finally it's back working
Thanks Pilou....C.Plassais....TIG....Thomthom....Chris Fullmer....Fredo!
Hope i left no one out?
-
Maybe cats and dogs and birds...
It's a big familly -
About
Facegroup by Gavvy (seems there a is little problem with this facegroup plugin) Thomthom is look it! and seems found the errorAnd I have found another one who works
Make_components by Matt666 at Crai Ruby depot!And a third solution by Tig! (face selected ---> groups)
Put this in the Ruby console!m=Sketchup.active_model;n=m.active_entities;m.selection.to_a.each{|e|n.add_group(e)if e.class==Sketchup;;Face}
-
thanks pilou for the fast reply, i will try it and report it soon..
regards,
-
With newest version 3.0.2
@unknownuser said:
is there any possibility of this plugin have crashed with other plugin?
I don't believe that
@unknownuser said:
- i create simple cube, and then group it
- when i right click on the group and choose eclate_deplace, no dialog box showed up and i got this messages
Normal : a simple cube must be composed of a 6 faces themself a group!!!
(so for a cube: 6 faces who are each a group) !
in this image i have selected one face for you show that is a group
(each face is a group)
Select them then call the plug!
If you want transform automatically each 6 faces of a simple cube on 6 groups maybe exist a plug
(or any faces selected)
Facegroup by Gavvy (seems there a little problem with this facegroup plugin) Thomthom is look it!
And I have found another one who works
Make_components by Matt666 at Crai Ruby depot!Ps Menu of "Radial Move" or "Eclate_displace" Appear by Right Click on the selection of the groups or components!
-
How do you use the ChrisP_RadialMove_EN.rb plugin? can anyone show an example?
-
No problem
Advertisement