sketchucation logo sketchucation
    • Login
    βŒ› Sale Ending | 30% Off Profile Builder 4 ends 30th September

    [Plugin] ComponentScenes v0.3 UPDATE

    Scheduled Pinned Locked Moved Plugins
    17 Posts 6 Posters 12.5k Views 6 Watching
    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.
    • T Offline
      tim
      last edited by

      Version 0.2 updated to-

      • wrap the routine in start/commit_operation. This noticeably speeds up dealing with many components. It should also make 'undo' work better but Pages do not get removed by undo so something ain't raht.
      • zoom to the extent of each component when creating the page for it
        See first post for download.
      1 Reply Last reply Reply Quote 0
      • Rich O BrienR Offline
        Rich O Brien Moderator
        last edited by

        Thanks for this Tim

        It's somewhat similar to this....

        http://forums.sketchucation.com/viewtopic.php?t=39152

        Download the free D'oh Book for SketchUp πŸ“–

        1 Reply Last reply Reply Quote 0
        • T Offline
          tim
          last edited by

          @rich o brien said:

          It's somewhat similar to this....

          http://forums.sketchucation.com/viewtopic.php?t=39152

          Yes, it has some important similarities to both the viewports and Comp2Layer plugins including the fact that they jointly inspired me to try something oblong the same lines but more suited to my own needs. ComponentScenes works with nested components though, which viewports seems not to handle. Comp2Layer actually moves the chosen components to new layers, which I found annoying.

          Most importantly to me the process of writing the plugin is a learning experience; the possibility that it may result in something useful to other people is a nice bonus πŸ˜„

          1 Reply Last reply Reply Quote 0
          • T Offline
            tim
            last edited by

            @tim said:

            something oblong the same lines

            Hunh? Damn you auto cockerel. That should be oolong

            1 Reply Last reply Reply Quote 0
            • T Offline
              tim
              last edited by

              New version uploaded 15 Jun 2012; try to make the zoom setting for each component scene actually work. Yet again, the API does't do what it says in the docs.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @tim said:

                Pages seem to be happy to share names whereas Layers seem to prefer unique names and there shouldn't be any clashes.

                I think your asking for trouble.

                What will happen when code tries to get a reference to a page with: pages["name"] ??

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  It is daft that Definitions, Layers, Materials etc must have unique names - set automatically, BUT every Scene-tab could be called 'foo' !
                  You can 'uniquify' your page names... before falling foul of the potential for duplicated names...

                  ### assuming that 'pages' is reference to the Model's Pages object
                  names = []; pages.each{|page| names << page.name }
                  used = []; names.each{|name|
                    unless used.include?(name)
                      used << name
                    else ### already used !
                      name = name+"#1"
                      name.next! while used.include?(name)
                      used << name
                    end
                  }
                  used.each_with_index{|name, i| pages[i].name = name }
                  
                  

                  NOW the Scene-tabs will have unique names !

                  foo, foo#1, foo#2, foo#3 etc...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    kostiaarh
                    last edited by

                    Can anyone help me? please add icons for this plugin. I tried to do it, but could not get the plugin to work. Thanks


                    ComponentScenes.rar

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      When you join strings into a file-path it's best NOT to use a separator.
                      So NOT
                      cmd.large_icon = File.join(imgdir, "/cs_l.png")
                      but
                      cmd.large_icon = File.join(imgdir, "cs_l.png")
                      Although Ruby should usually fix it for you.

                      However, I don't think that is the issue - I suspect it is with your PNG files themselves.
                      PNGs for buttons need not be that big, also your PNGs are in 'Indexed Colors' - try converting them to 'RGB' with something like Gimp.
                      Your larger PNG is 1.5kb, my toolbar equivalents are usually considerably smaller...
                      Yours is 128px sq, when mine is 24px sq - just like the su_... equivalents...
                      Again you can use Gimp to resize then down to 24px sq [16px sq for small icons]...
                      As recommended here:
                      http://ruby.sketchup.com/UI/Command.html#large_icon=-instance_method

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • BoxB Offline
                        Box
                        last edited by

                        7 years between posts, impressive.

                        1 Reply Last reply Reply Quote 0
                        • K Offline
                          kostiaarh
                          last edited by

                          Thanks Tig. I made all the corrections but the plugin does not work. I don’t know what to do with it.
                          Error: #<NameError: undefined local variable or method deleting_group' for main:Object> C:/Users/KOSTIA/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/ComponentScenes.rb:189:in block in <top (required)>'


                          2ComponentScenes.rar

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            The error message is most helpful.
                            Your code calls deleting_group from outside the module !
                            The get it to work move all of your toolbar code inside it, and rename the methods with self.xxx
                            However, you never define deleting_group and ComponentScenes is used oddly within the menu code.
                            It all needs reworking...
                            Look at some other authors code that define a cmd and make a toolbar...
                            You have muddled up everything !

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              kostiaarh
                              last edited by

                              I would also like to know if it is possible to organize the created scenes in the panel? For example, scene1, scene2, scene3 ... sceneN? When I use this plugin, the scenes are placed in a chaotic order.


                              111.JPG

                              1 Reply Last reply Reply Quote 0
                              • TIGT Offline
                                TIG Moderator
                                last edited by

                                You are jumping around somewhat in your 'problems'...
                                Look at the Pages and Page section of the API guide.
                                You need to get an array of the scene-tabs names and sort them, then reorder the scenes accordingly...
                                http://ruby.sketchup.com/Sketchup/Pages.html
                                It's not that easy to do !
                                But here's a crib to get you started...

                                
                                model = Sketchup.active_model
                                pages = model.pages
                                num   = pages.length
                                if num > 0
                                  selected = pages.selected_page.name
                                  page_names = pages.map{|pg| pg.name }
                                  page_names.sort!
                                  num = page_names.length
                                  page_names.each{|page|
                                    tran_time = pages[page].transition_time
                                    pages[page].transition_time = 0
                                    delay_time = pages[page].delay_time
                                    pages[page].delay_time = 0
                                    pages.selected_page = pages[page]
                                    new_page = pages.add(page)
                                    new_page.transition_time = tran_time
                                    new_page.delay_time = delay_time
                                  }
                                  num.times{ pages.erase(model.pages[0]) }
                                  pages.selected_page = pages[selected]
                                end
                                
                                

                                Pages [Scenes] are now in order...

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  kostiaarh
                                  last edited by

                                  Thank you Tig. I put this code in the toolbar editor. Works great.

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

                                  Advertisement