• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Exploding Using Ruby Script

Scheduled Pinned Locked Moved Developers' Forum
9 Posts 3 Posters 1.5k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    simonstaton
    last edited by 12 Aug 2009, 13:33

    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 explode

    Now is there a syntax for explodeing as I have checked everywhere and
    cant find one maybe somtyhing like this
    Sketchup.send_action “explode:”

    1 Reply Last reply Reply Quote 0
    • S Offline
      simonstaton
      last edited by 12 Aug 2009, 14:30

      no ideas?

      1 Reply Last reply Reply Quote 0
      • T Offline
        tbd
        last edited by 12 Aug 2009, 14:44

        Sketchup.active_model.selection[0].explode
        

        you need to add some error testing to see if a component is selected

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0
        • S Offline
          simonstaton
          last edited by 12 Aug 2009, 15:58

          that still isnt exploding it selects it all. also what do you mean by error testing

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 12 Aug 2009, 17:18

            {Sketchup.send_action(21101)} ### scrap it... no need to 'select' anything

            Use this line put inside your {}

            Sketchup.active_model.active_entities).each{|e|e.explode if e.class==Sketchup;;ComponentInstance}
            

            TIG

            1 Reply Last reply Reply Quote 0
            • S Offline
              simonstaton
              last edited by 13 Aug 2009, 08:56

              @tig said:

              {Sketchup.send_action(21101)} ### scrap it... no need to 'select' anything

              Use 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}
                                                         ^
              
              1 Reply Last reply Reply Quote 0
              • S Offline
                simonstaton
                last edited by 13 Aug 2009, 10:50

                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
                
                
                
                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 13 Aug 2009, 12:50

                  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

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    simonstaton
                    last edited by 13 Aug 2009, 13:16

                    @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 😃

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      1/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement