[Plugin] Component Libraries Loader
-
Hi all!
I'm currently writing a little Ruby Script which dynamically load all components (uh actually all files ) containing inside a specific folder. (including sub-folders)
The problem is that it need an empty sub-folder when some skp are present to be able to launch them... And I really don't know why ?
(file in attachment, I know that it's quite dirty but it's a simple test for the moment)
the problem appears on line 47
#UI.messagebox foldername $menu[folderNumber].add_item(fichier){component_loader(fichier,foldername)} #UI.messagebox foldername
If I active messagebox to view foldername before and after the calling to the function component_loader() the name is good.
But inside the component_loader function, foldername refer to the parent directory if and only if there is no sub-directory inside the current folder....I really don't understand why even if I suspect the line 42 to be guilty nevertheless I don't understand why before and after the calling of the function the name of the folder is good...
foldername[fichier+"/"]=""
(here to change the directory name the parent one when the reading of the actual is over)
Any ideas ?
-
Here is a much more compact version.
<span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /></span><span class="syntaxdefault">module Sm4rt<br /> class List_Menu_Load<br /> def initialize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> menu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> return nil if not rep or not menu or not File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">exist</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> or not File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">)==</span><span class="syntaxstring">'directory'<br /></span><span class="syntaxdefault"> skps</span><span class="syntaxkeyword">=[];</span><span class="syntaxdefault"> folders</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxdefault"> Dir</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entries</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> next if f</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'.'</span><span class="syntaxdefault"> or f</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'..'<br /></span><span class="syntaxdefault"> path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> f</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> skps </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> f if File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)!=</span><span class="syntaxstring">'directory'</span><span class="syntaxdefault"> and File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">extname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">downcase</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'.skp'<br /></span><span class="syntaxdefault"> folders </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> f if File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)==</span><span class="syntaxstring">'directory'<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> skps</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">skp</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> skpc</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">skp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">".*"</span><span class="syntaxkeyword">);</span><span class="syntaxdefault"> path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> skp</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">skpc</span><span class="syntaxkeyword">){</span><span class="syntaxdefault">Sm4rt</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">component_loader</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)}<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> folders</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> folder</span><span class="syntaxkeyword">);</span><span class="syntaxdefault"> smenu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_submenu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> Sm4rt</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> smenu</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if smenu<br /> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> end</span><span class="syntaxcomment">#initialize<br /></span><span class="syntaxdefault"> def List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">component_loader</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">import</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if path<br /> end</span><span class="syntaxcomment">#component_loader<br /></span><span class="syntaxdefault"> def List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">menu_maker</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> Sm4rt</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> </span><span class="syntaxstring">"MyLibrary"</span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> menu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">add_submenu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"MyLibrary"</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> end</span><span class="syntaxcomment">#menu_maker<br /></span><span class="syntaxdefault"> end</span><span class="syntaxcomment">#class<br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#module<br />### auto-run at startup<br /></span><span class="syntaxdefault">Sm4rt</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">menu_maker</span><span class="syntaxkeyword">()<br /></span><span class="syntaxcomment">### </span><span class="syntaxdefault"></span>
It avoids messing with base classes, global variables prone to clashing etc...
It's fully self-contained and self-iterates all skps in the specified folder or its subfolders, adding an item to a menu/submenu to suit and an action for the item to import the chosen skp... -
Any ideas of what happens and what's wrong in my version because I really don't understand where is the mistake in fact...
trying to treat files before folders but it don't change anything :
- when there is a sub folder everything works good
- when the actual folder is the last child one, skps do not load <= path is wrong |
but path is good before entering in the load function / wrong inside it / and right after quiting the load function....
it make me crazy!
-
Your menu_maker code ~line #50 was wrongly worded - it wasn't looking in the right folder IF the folder wasn't in Plugins with the .rb file !
Here's the module part of the code again...<span class="syntaxdefault"></span><span class="syntaxcomment">###..............<br /></span><span class="syntaxdefault">module Sm4rt_CL<br /> </span><span class="syntaxkeyword">class </span><span class="syntaxdefault">List_Menu_Load<br /> def initialize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">)<br /> return </span><span class="syntaxdefault">nil </span><span class="syntaxkeyword">if </span><span class="syntaxdefault">not rep </span><span class="syntaxkeyword">or </span><span class="syntaxdefault">not menu </span><span class="syntaxkeyword">or </span><span class="syntaxdefault">not File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">exist</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">) or </span><span class="syntaxdefault">not File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">)==</span><span class="syntaxstring">'directory'<br /> </span><span class="syntaxdefault">skps</span><span class="syntaxkeyword">=[]; </span><span class="syntaxdefault">folders</span><span class="syntaxkeyword">=[]<br /> </span><span class="syntaxdefault">Dir</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entries</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|<br /> </span><span class="syntaxdefault">next </span><span class="syntaxkeyword">if </span><span class="syntaxdefault">f</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'.' </span><span class="syntaxkeyword">or </span><span class="syntaxdefault">f</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'..'<br /> </span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">f</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">skps </span><span class="syntaxkeyword"><< </span><span class="syntaxdefault">f </span><span class="syntaxkeyword">if </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)!=</span><span class="syntaxstring">'directory' </span><span class="syntaxkeyword">and </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">extname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">downcase</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'.skp'<br /> </span><span class="syntaxdefault">folders </span><span class="syntaxkeyword"><< </span><span class="syntaxdefault">f </span><span class="syntaxkeyword">if </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">ftype</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)==</span><span class="syntaxstring">'directory'<br /> </span><span class="syntaxkeyword">}<br /> </span><span class="syntaxdefault">folders</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">|<br /> </span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">); </span><span class="syntaxdefault">smenu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_submenu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">Sm4rt_CL</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">smenu</span><span class="syntaxkeyword">) if </span><span class="syntaxdefault">smenu<br /> </span><span class="syntaxkeyword">}<br /> </span><span class="syntaxdefault">skps</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">skp</span><span class="syntaxkeyword">|<br /> </span><span class="syntaxdefault">skpc</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">skp</span><span class="syntaxkeyword">, </span><span class="syntaxstring">".*"</span><span class="syntaxkeyword">); </span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">rep</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">skp</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">skpc</span><span class="syntaxkeyword">){</span><span class="syntaxdefault">Sm4rt_CL</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">component_loader</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)}<br /> }<br /> </span><span class="syntaxdefault">end</span><span class="syntaxcomment">#initialize<br /> </span><span class="syntaxdefault">def List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">component_loader</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">import</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">true</span><span class="syntaxkeyword">) if </span><span class="syntaxdefault">path<br /> end</span><span class="syntaxcomment">#component_loader<br /> </span><span class="syntaxdefault">def List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">menu_maker</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">name</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">)<br /> return </span><span class="syntaxdefault">nil </span><span class="syntaxkeyword">if </span><span class="syntaxdefault">not folder </span><span class="syntaxkeyword">or </span><span class="syntaxdefault">not name<br /> Sm4rt_CL</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault">folder</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Plugins"</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">add_submenu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">))<br /> </span><span class="syntaxdefault">end</span><span class="syntaxcomment">#menu_maker<br /> </span><span class="syntaxdefault">end</span><span class="syntaxcomment">#class<br /></span><span class="syntaxdefault">end</span><span class="syntaxcomment">#module<br />### auto-run at startup<br /></span><span class="syntaxdefault">librariesNames</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">value</span><span class="syntaxkeyword">| </span><span class="syntaxdefault">Sm4rt_CL</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">List_Menu_Load</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">menu_maker</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">librariesFolders</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">value</span><span class="syntaxkeyword">], </span><span class="syntaxdefault">value</span><span class="syntaxkeyword">)}<br /></span><span class="syntaxcomment">### </span><span class="syntaxdefault"></span>
Also note that I removed a redundant "submenu=[]" line
-
No I was speaking about my version of the first post.... Because there is non sens there^^
Actually the last one I send works good for me... thanks to you^^ (and your last suggestion don't or is a good solution for declaring Absolute path personally I prefers Relative declaration like you did...
But I've suppressed "submenus=[]" though...
-
damn! still impressive TIG!
I've just modified it to treat folders before skps and added the ability to load more then one folder...
File in attachment for those who want
here is the log^^
@unknownuser said:
Copyright 2011 by sm4rt (No it's TIG one in fact)
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 : Dynamic Component Loader 0.1.1rc1
Description : load full libraries of components you often use by creating a menu list of your component libraries
inside the Sketchup Plugins Menu
Author : sm4rt but TIG
Usage : Simply edit/add the name you want to give for your component libraries inside "librariesNames" declaration
edit/add the corresponding folder path inside "librariesFolders" declaration
And that's it !
you'll no longer have to search through your disk to find model you usually use
Just feed your model libs as time goes by
Script will load sub-folders too
Date : 8.Apr.2011
Type : Loader
History:
0.1.1rc1 (8.Apr.2011) - impressive fully versatile revision
0.1.1beta1 (7.Apr.2011) - loud dirty unefficient version
-
i use this plugin as an alternative to sketchup native component browser; but, even with only one subfolder in the component folder, it takes a lot of room on the screen
would it be possible to have a button, or a key shortcut, that would open a window with only the chosen folder in sketchup component folder; by clicking on this folder, it would show its content, and it would be possible to pick up a component; like this
less room on the screen, easier to follow the path to the chosen component with the mouse
-
Is there any way to access folders outside of the SketchUp root folder? It doesn't read a folder if I enter the address as "C:\Library" or anything without the "../Components" type of notation.
-
any chance to get it working with sketchup 15?
-
it kind of does,
the code looks for the comps in two folders but they must be where the plugin itself is (plugins folder usually).
require 'sketchup.rb' #order = ["Components", "MyLibrary"] librariesNames = ["MyLibrary", "Components"] librariesFolders = { "Components" => "Components", "MyLibrary" => "MyLibrary"} module Sm4rt_CL class List_Menu_Load def initialize(rep=nil, menu=nil) return nil if not rep or not menu or not File.exist?(rep) or not File.ftype(rep)=='directory' skps=[]; folders=[] Dir.entries(rep).each{|f| next if f=='.' or f=='..' path=File.join(rep, f) skps << f if File.ftype(path)!='directory' and File.extname(f).downcase=='.skp' folders << f if File.ftype(path)=='directory' } folders.each{|folder| path=File.join(rep, folder); smenu=menu.add_submenu(folder) Sm4rt_CL;;List_Menu_Load.new(path, smenu) if smenu } skps.each{|skp| skpc=File.basename(skp, ".*"); path=File.join(rep, skp) menu.add_item(skpc){Sm4rt_CL;;List_Menu_Load;;component_loader(path)} } end#initialize def List_Menu_Load;;component_loader(path=nil) Sketchup.active_model.import(path, true) if path end#component_loader def List_Menu_Load;;menu_maker(folder=nil, name=nil) return nil if not folder or not name Sm4rt_CL;;List_Menu_Load.new(File.join(File.dirname(__FILE__), folder), menu=UI.menu("Plugins").add_submenu(name)) end#menu_maker end#class end#module ### auto-run at startup librariesNames.each {|value| Sm4rt_CL;;List_Menu_Load;;menu_maker(librariesFolders[value], value)} ###
-
Thank you
i didn't notice any change from the version i already have though
it did work perfectly in SU8
it doesn't work for me anymore in SU15components are in the components folder, the plugin is in the plugins folder
in SU15, they are far apart, maybe that's why
adding this file in my plugins folder, i do have 2 more lines in the plugins menu
"Mylibray"
"components"
but they don't unfold, and Launchup doesn't propose me components anymore when i type the name -
yes, i posted the code so you'd be sure of the one i used.
notice i took out the '../' from the 2 folders paths (start of script) - which made the script look in the directory above to the comps folder. (so it only works on su8)
if you put the folders in the same directory as the script it works. at least it does for me (check the case matches too)
need to look more into to see why it doesn't when you change the path to full (ie. "c/Program Files/SketchUp...etc etc)
-
@cadfather said:
yes, i posted the code so you'd be sure of the one i used.
notice i took out the '../' from the 2 folders paths (start of script) - which made the script look in the directory above to the comps folder. (so it only works on su8)
if you put the folders in the same directory as the script it works. at least it does for me (check the case matches too)
need to look more into to see why it doesn't when you change the path to full (ie. "c/Program Files/SketchUp...etc etc)
OK now i understand
it works for me also
muchas gracias
i shall try to change the path too...
Advertisement