Exploding Using Ruby Script
-
Basicly I want to explode all the components on the page using a ruby script. I have a
component inside of a component and the component that is inside the
main one has attributes so I do not want to explode it completly but
only explode it once as if I was right clicking then selecting
explode.So far I have made a toolbar that when you press selects everything on
the page then next I want it to explode this is my code so far.toolbar = UI::Toolbar.new "Action 3D Toolbar" cmd = UI::Command.new("Explode All") { Sketchup.send_action(21101) } cmd.small_icon = "3dtoolbar.png" cmd.large_icon = "3dtoolbar.png" cmd.tooltip = "Action 3D Toolbar" cmd.status_bar_text = "Testing the toolbars class" cmd.menu_text = "Test" toolbar = toolbar.add_item cmd toolbar.show
now the only important part here is the Sketchup.send_action(21101)
and 21101 is the syntax for select all. so all I need to do now is explode as if I am right clicking then selecting explodeNow is there a syntax for explodeing as I have checked everywhere and
cant find one maybe somtyhing like this
Sketchup.send_action “explode:” -
no ideas?
-
Sketchup.active_model.selection[0].explode
you need to add some error testing to see if a component is selected
-
that still isnt exploding it selects it all. also what do you mean by error testing
-
{Sketchup.send_action(21101)}
### scrap it... no need to 'select' anythingUse this line put inside your {}
Sketchup.active_model.active_entities).each{|e|e.explode if e.class==Sketchup;;ComponentInstance}
-
@tig said:
{Sketchup.send_action(21101)}
### scrap it... no need to 'select' anythingUse this line put inside your {}
Sketchup.active_model.active_entities).each{|e|e.explode if e.class==Sketchup;;ComponentInstance}
that just gave me this error
C;/Documents and Settings/Administrator/Desktop/action3d/Plugins/Utilities/Toolbar.rb;5; syntax error Sketchup.active_model.active_entities).each{|e|e.explode if e.class==Sketchup;;ComponentInstance} ^Error Loading File LoadToolbar.rb C;/Documents and Settings/Administrator/Desktop/action3d/Plugins/Utilities/Toolbar.rb;5; syntax error Sketchup.active_model.active_entities).each{|e|e.explode if e.class==Sketchup;;ComponentInstance} ^
-
I have just been playing around with the bomb.rb plugin however this does explode it but it explodes it completly and I only want it to explode once. This is the code that explodes all the components complely.
Sketchup.send_action(21101) def bomb_groups model = Sketchup.active_model defs = model.definitions return nil if UI.messagebox("Are You Finished Building Your Climbing Frame This Will Colapse The Model", MB_YESNO) == 7 if Sketchup.version[0,1].to_i >= 7 model.start_operation("bomb groups",true) puts "Using enhanced speed mode" else model.start_operation "bomb groups" end defs.each do |d| puts "exploding #{(itotal = d.instances.length)} instances of #{d.name}" d.instances.each do |e| e.explode end Sketchup.set_status_text "Collapseing Your Action 3D Model" end model.commit_operation Sketchup.set_status_text("Your Model Has Been Collapsed And You Can Now View The Models Price") UI.messagebox("Your Model Has Been Collapsed And You Can Now View The Models Price",MB_OK) end unless file_loaded?("bomb.rb") # BEGIN CHANGES BY organizerEdit.rb file_loaded("bomb.rb") if $submenu!=nil $submenu.add_item("Bomb All") { bomb_groups } end # END CHANGES BY organizerEdit.rb end bomb_groups
-
Sorry - I made a typo, try this... there was loose ) after entities !
Sketchup.active_model.active_entities.each{|e|e.explode if e.class==Sketchup::ComponentInstance}
-
@tig said:
Sorry - I made a typo, try this... there was loose ) after entities !
Sketchup.active_model.active_entities.each{|e|e.explode if e.class==Sketchup::ComponentInstance}
wewt! thanks man that worked a dream. ive spent so long on this thanks
Advertisement