by tim » Tue Jun 05, 2012 1:50 am
Here's a first attempt at a plugin to build a set of pages that show one component each, ready for Layout to embed and dimension etc. UsageSelect one or more components - even inside another component - and from the plugin menu 'Build Component Scenes'. You should see a number of pages appear, each named after the components chosen, Each page will have one component visible on a layer named after the component. When you open the model in Layout you will now have a nice convenient way to do individual component drawings. I've tried to make this idempotent - if you repeat the command you should get the same results each time with no interference between the sets of pages. Pages seem to be happy to share names whereas Layers seem to prefer unique names and there shouldn't be any clashes. The current To-Do list is Make this an extension later http://sketchupapi.blogspot.ca/2011/07/ ... nsion.htmlPackage as an RBZ file http://sketchupapi.blogspot.ca/2011/12/ ... -your.htmlDo not make scenes for duplicate components - (how to decide this? scaling, shearing and flipping in the component transform can make two apparently equivalent components NOT duplicates). Make undo/redo friendly. - first pass at this is to wrap the main routine in start/commit_ operation # but it doesn't remove created pages and # SU crashes completely if it tries to undo a lot of component pages Find a way to close any open component edits after making the component pages so that the components don't appear to be missing; you could argue that the user should understand but never underestimate the confusion of users. On hold for now because it would surely annoy users to lose an edit deep inside a complex model Updates for v0.3 - attempt workaround for active_view.zoom failing to actually zoom to the chosen component
Updates for v0.2 - Wrapped routine in start/commit_operation, which speeds up dealing with many components.
- Zoom to extent of component when making the page.
Download ComponentScenesComponentScenes.rb
Last edited by tim on Sat Jun 16, 2012 2:37 am, edited 2 times in total.
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by tim » Tue Jun 05, 2012 5:46 am
Here's an example skp file and layout file to show what it does. BedComponentScenesExample.skp BedComponentScenesExample.layout The skp started as a single page with the bed model. I d-clicked on the bed component to open it and selected-all. The plugin created the slat, side, headboard, footboard and mid rail pages. Since the headboard and footboard are composed of further components I also opened them and repeated the process, creating a sizeable list of other pages with each individual component on its own page. The model was sent to Layout and just as an example I created a detail page for the post from the headboard. Since the post exists on its own scene I could have a total of five views on the page, one each of the left/right/front/back view and an iso view for context. Without any other components in the SU scene there is no clutter to worry about in Layout.
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by tim » Sat Jun 09, 2012 4:53 am
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.
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by Rich O Brien » Sat Jun 09, 2012 8:57 am
Thanks for this Tim It's somewhat similar to this.... viewtopic.php?t=39152
There's a frontroom and a backroom....reverse faces
-

Rich O Brien
- Administrator
-
- Posts: 12683
- Joined: Fri Oct 31, 2008 9:05 am
- Location: Broadford, Clare, Ireland
- Name: Rich O'Brien
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Advanced
-
by tim » Mon Jun 11, 2012 4:09 am
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 
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by tim » Mon Jun 11, 2012 7:33 pm
tim wrote: something oblong the same lines
Hunh? Damn you auto cockerel. That should be oolong
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by tim » Sat Jun 16, 2012 2:39 am
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.
-
tim
-
- Posts: 431
- Joined: Wed Nov 14, 2007 6:50 pm
- Location: Qualicum Beach, Vancouver Island, Canada
-
by Dan Rathbun » Sat Jul 21, 2012 7:12 am
tim wrote: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. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5042
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by TIG » Sat Jul 21, 2012 3:57 pm
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... - Code: Select all
### 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
-

TIG
- Global Moderator
-
- Posts: 20267
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by kostiaarh » Sat Aug 31, 2019 9:07 pm
Can anyone help me? please add icons for this plugin. I tried to do it, but could not get the plugin to work. Thanks
-
kostiaarh
-
- Posts: 18
- Joined: Sun Feb 24, 2013 9:32 am
- Name: kostya
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by TIG » Sun Sep 01, 2019 1:43 pm
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.htm ... nce_method
TIG
-

TIG
- Global Moderator
-
- Posts: 20267
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Box » Sun Sep 01, 2019 3:15 pm
7 years between posts, impressive.
-

Box
-
- Posts: 5014
- Joined: Mon Jun 07, 2010 1:55 pm
- Location: Sydney
- Name: Box
- Operating system: Windows
- SketchUp version: 2020
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Intermediate
-
by kostiaarh » Sun Sep 01, 2019 4:33 pm
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)>'
-
kostiaarh
-
- Posts: 18
- Joined: Sun Feb 24, 2013 9:32 am
- Name: kostya
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by TIG » Sun Sep 01, 2019 5:07 pm
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
-

TIG
- Global Moderator
-
- Posts: 20267
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by kostiaarh » Sun Sep 01, 2019 5:11 pm
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.
-
kostiaarh
-
- Posts: 18
- Joined: Sun Feb 24, 2013 9:32 am
- Name: kostya
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by TIG » Sun Sep 01, 2019 6:14 pm
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.htmlIt's not that easy to do ! But here's a crib to get you started... - Code: Select all
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
-

TIG
- Global Moderator
-
- Posts: 20267
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by kostiaarh » Sun Sep 01, 2019 8:14 pm
Thank you Tig. I put this code in the toolbar editor. Works great.
-
kostiaarh
-
- Posts: 18
- Joined: Sun Feb 24, 2013 9:32 am
- Name: kostya
- Operating system: Windows
- SketchUp version: 2017
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|