[Plugin] Import ALL from Folder

[Plugin] Import ALL from Folder

Postby TIG » Sun May 29, 2011 2:37 pm

This script has been split off from posts in a convoluted thread...





(c) TIG 2009-2015

import_from_folder.rb

Run the tool by typing
TIG::import_from_folder
in the Ruby Console or picking 'Import ALL from Folder' from the File menu.
In the dialog that appears navigate to the required Folder and pick one
File of the 'type' to be imported.
e.g. select any 'geometry' type [some are available for 'Pro' only]
skp, dwg, dxf, kml, dae, 2ds, dem, ddf, stl
or image files
png, jpg, tif, psd, tga, bmp
Images are 'imported' differently... They come in with their width/height
in inches based on their pixel-size, and they line up along X-axis [red]
ALL files of the 'type' you selected will be imported from that folder
into the Model.
SKPs produce an extra request on 'placement'...
Progress of each file is shown in the VCB...

v1.0 20091124 First issue.
v1.1 20100305 Image 'import' added.
v1.2 20110529 Module added.
v1.3 20140116 STL files import added - uses last set options, need to OK between each one!
See post for each revision...

Download from the PluginStore

Download

2
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby Bob James » Sun May 29, 2011 8:18 pm

Can they be imported as textures rather than images and put into their own rectangles? This would be a great way to add to a favorites material folder.
0
i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60
User avatar
Bob James 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Sun May 29, 2011 8:21 pm

Bob James wrote:Can they be imported as textures rather than images and put into their own rectangles? This would be a great way to add to a favorites material folder.

That's another Plugin :roll:
http://rhin.crai.archi.fr/rld/plugin_details.php?id=241
massmaterialimporter.rb by Adam Beazley, tweaked by me...
Makes materials from image files in a folder... each named after the image-file and using that image as its texture...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby Bob James » Mon May 30, 2011 11:35 pm

Thank you, TIG. You guys are amazing :thumb:
You and your fellow ruby gurus are what turn SU from a great program to a untouchably superior program.

Thank you again for this and your many other generous contributions.
0
i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60
User avatar
Bob James 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby Bob James » Sat Jun 18, 2011 1:04 am

TIG wrote:That's another Plugin :roll:
http://rhin.crai.archi.fr/rld/plugin_details.php?id=241
massmaterialimporter.rb by Adam Beazley, tweaked by me...
Makes materials from image files in a folder... each named after the image-file and using that image as its texture...

A oldy but goody!!
I imported all of my textures, one group at at time (e.g. metals). I then dragged them down into either an existing materials folder or added a new folder in C:\Program Files (x86)\Google\Google SketchUp 8\Materials.

I can use all of them.

The big question I have is: where are they stored?
They do not appear in the folders in C:\Program Files (x86)\Google\Google SketchUp 8\Materials. :!:
For example, when I open C:\Program Files (x86)\Google\Google SketchUp 8\Materials\Metal, there are 21 files. But when I open the Materials Window and click on Metals, there are 195 :!: :!:

I really need to know why they are stored so I can back them up as .skm files.
0
i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60
User avatar
Bob James 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Sat Jun 18, 2011 9:52 am

They are made as new materials in the current Model materials.
You must save them as external SKM files just like you would with any material you have created that you might want to have for reuse in another SKP...
To save all Model Materials as external SKM files use the Material Browser's "Save collection as..." option [accessed from the pop-out menu from browser's right-hand menu-arrow] and locate in any folder you wish, it should start in ../Materials, give it a new subfolder as appropriate... or to save an individual material as a SKM use the "Save As" option accessed by the right-click context menu when one material is selected. You can also open a second folder pane in the browser [top-right + button] and navigate to the required folder to take the new materials, and then drag your desired materials one at a time from the Model materials pane and drop them into that other folder's pane, to make SKM copies of them externally...
So to recap there are three ways to make external SKM files from the Model's materials - either all at once as a 'collection', or one at a time with 'save as', or one at a time by drag+drop into a selected folder... :ugeek:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Sat Jun 18, 2011 10:42 am

If you've used the drag method and the SKM files still aren't showing up then open the Materials folder [subfolder if used] and check your permissions [security] settings - you need to have all rights to add files etc.
On Vista [and Win7] there's the dreaded/stupid 'Compatibilty Files' issue. Your PC lets you [seemingly] add files to a folder that has limited permissions. These then don't show up when you next look for them - they have actually be put into a 'Compatibilty Files' folder that you then have the chance to merge back into the intended folder - it's frankly madness to protect you from yourself to this extent - especially when it doesn't explicitly tell you what it's done! If a folder has these 'Compatibilty Files' issues there's usually a button on the top window bar with that name, to show it and allow you access to these...
It can be very very annoying!! I experienced it when I first got Vista and a new Sketchup install... I suggest that you go through all of the folders in your ../Sketchup folder to which you are likely to want to add files - e.g. ../Plugins, ../Materials, ../Components and ../Styles - and ensure you have full access-rights to these and all of their subfolders... then there should be no more 'Compatibilty Files' issues at least :geek:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby Bob James » Mon Jun 20, 2011 8:16 pm

TIG wrote:These then don't show up when you next look for them - they have actually be put into a 'Compatibilty Files' folder that you then have the chance to merge back into the intended folder


I suggest that you go through all of the folders in your ../Sketchup folder to which you are likely to want to add files - e.g. ../Plugins, ../Materials, ../Components and ../Styles - and ensure you have full access-rights to these and all of their subfolders... then there should be no more 'Compatibilty Files' issues at least :geek:

I finally found the "Compatibility Files" location. There is no such folder name per se. For future reference by other users having this problem it is:
C:\Users\jamesb\AppData\Local\VirtualStore\Program Files (x86)\Google\Google SketchUp 8\Materials.
Thank you for your help. I never would have thought of looking for them :thumb:

I had my IT people give me permissions and ownership to the SketchUp files, but this did not solve the problem. So I'm just dragging and dropping from the "Compatibility Folders" to the Materials folder at C:\Program Files (x86)\Google\Google SketchUp 8\Materials :puke:

Seems like there should be a cleaner way to get new materials/textures into SU. :roll:
0
i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60
User avatar
Bob James 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Mon Jun 20, 2011 10:31 pm

Windows 7 even decided to rename the 'compatibility' folder when compared to Vista :roll:

It wouldn't be so bad if it explicitly told you what it was doing, rather than subtly moving them into a side-folder !!! :puke:

Your IT guys need to ensure that all suitable users have full rights to read/write/add/change/delete files/subfolders/etc in the various subfolders of Sketchup that they WILL need to access [at least on occasion]... like Plugins, Components, Styles, Materials...

This is not exceptional - it should be the norm for all [except the most junior/reckless] members of staff... :roll: :roll: :roll:

It's not Sketchup's fault it's your IT guys... :evil:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby Camille Morrison » Tue Aug 02, 2011 7:21 pm

Hi I am trying to use the dwg/plugin but I don't know how to get it to work, I tried running it from start/run but it doesn't work
0

Camille Morrison 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Wed Aug 03, 2011 11:28 am

Camille

What dwg-plugin ?
The DWG Exporter is one of the types accessed off Sketchup's File > Export menu - that's Pro only though ?? No 'plugin' file is needed as that is an exporter [.dll on PC] supplied with Sketchup itself.

BUT do you mean this thread's plugin tool...

Plugins are not 'run' like external apps they [typically a plugin is named 'xxxxxxxx.rb'] go in the Plugins folder and either appear in a menu or are activated in other ways from within Sketchup itself - as explained in the download page for each tool... so for this tool it says...
    Run the tool by typing
    TIG::import_from_folder
    in the [Window >] Ruby Console, or picking 'Import ALL from Folder' from the [Sketchup] File menu.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby mattao987 » Fri Nov 30, 2012 2:26 am

Hi TIG,

Thanks for your plugin with is really useful.

I'd like to add an optionnal STAGE in your script.

Once a file is imported, i'd like to create a new layer named by reference to the file name with a suffix.
Let's say Wonka_Niv1
Then, Group all the freshly imported items on this new layer.
Then proceed to the next file.

Could you be kind enough to assist me?
0

mattao987 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Fri Nov 30, 2012 11:20 am

mattao987 wrote:...I'd like to add an optionnal STAGE in your script.
Once a file is imported, i'd like to create a new layer named by reference to the file name with a suffix.
Let's say Wonka_Niv1
Then, Group all the freshly imported items on this new layer.
Then proceed to the next file...

What file type are you importing?
SKP and Others need to be treated differently...
Obviously none of this 'Layering' stuff will ever work with imported 'Images' !!

For non-SKP files:
Provided there is at least one object already in the receiving-SKP, then all imported formats [other than a SKP] will already import as a component named after the file - e.g. "Wonka_Niv1.dwg".
So after line#84:
model.import(file,false)
add these lines:
unless File.extname(list[0]).downcase==".skp"
ins=model.definitions[File.basename(file)].instances[0]
ins.layer=model.layers.add(File.basename(file, ".*"))
end#if

Note: this uses the imported files 'basename' [e.g. "Wonka_Niv1"], to use the full name with say its '.dwg. suffix use ...add(File.basename(file)) instead

For SKP imports you will need to edit another part of the code:
after line#107:
ins=model.active_entities.add_instance(defn,tr)
add this:
ins.layer=model.layers.add(name)
This uses the imported SKP's name, without any '.skp' suffix [e.g. "Wonka_Niv1"] - but if you want to add one, then change ...add(name) to ...add(File.basename(file))

This should do what you want... :D
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby mattao987 » Wed Dec 05, 2012 2:40 am

I encounter some errors at the script loading ( sketchup launch time )

Loading File import_from_folder.rb
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/import_from_folder.rb:89: parse error, unexpected '}', expecting kEND
}
^
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/import_from_folder.rb:124: parse error, unexpected kEND, expecting '}'
end#def import_from_folder
^
/Library/Application Support/Google SketchUp 8/SketchUp/Plugins/import_from_folder.rb:134: parse error, unexpected $, expecting '}'


I've tried a BBedit editing and I suspect some bad editing error. ( I am not a programmer as you can see )

I've tried to edit the code after sketchup launch and it works one time but only one.

Could you help?
0

mattao987 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby mattao987 » Wed Dec 05, 2012 2:51 am

Maybe I could use this command m=Sketchup.active_model;m.start_operation('c');m.active_entities.each{|e|next unless e.is_a?(Sketchup::ComponentInstance);n=e.definition.name;l=m.layers.add(n);e.layer=l};m.commit_operation
0

mattao987 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby TIG » Wed Dec 05, 2012 11:09 am

mattao987 wrote:Maybe I could use this command m=Sketchup.active_model;m.start_operation('c');m.active_entities.each{|e|next unless e.is_a?(Sketchup::ComponentInstance);n=e.definition.name;l=m.layers.add(n);e.layer=l};m.commit_operation
BUT that only puts component-instances in the active_entities context onto layers named after their definitions. :?
The original .rb file in the first post in the thread works just fine.
I can see you have changed some of it in your example...
Why?
I'm not going to look farther into it as I don't understand what you are attempting to do...
What are you trying to do differently, when compared to the original code ?
Obviously you have messed up your version that you you attached, it's broken around line#89 :roll:
:?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby driven » Sat Jan 05, 2013 1:44 am

TIG wrote:Why?
I'm not going to look farther into it as I don't understand what you are attempting to do...

hi Tig,
I think he's on a mac, as I just tried to run it and got similar errors.
As I only needed one folder of images I pulled the bits out and line fed Ruby Console, to ascertain what worked, oddly it was failing at every return and worked when they were removed? is it a 1.8.5 ruby issue? I cobbled the bits that worked in a new file and ran it fine, if you want to see it I can PM...

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby mattao987 » Sat Jan 05, 2013 2:02 am

Sorry for this long absence, ( a long serie of "bugs" in my working life )

I've just tried the editing of the code with BBEdit cos it was not working on my mac.

My goal is to achieve a fast import of files exported from VectorWorks through the DWG plug-in.
I got a very good answer with your script but I hoped to get it one step beyond

(Please pardon me my bad english)
0

mattao987 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby driven » Sat Jan 05, 2013 2:11 am

hi mattao987

fill in your profile so everyone knows your on a mac, we are a minority group here...

I didn't need much of it, but splitting out the explicit returns made the bits I needed work, I also de-modularised it for a one off run.

If you go through and gat the basics to fully work, I'd suggest PM'ing TIG your working version of the basic script, then talk about extra's...

Even the initial error reports may help see what's going wrong on mac.

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby driven » Sat Jan 05, 2013 2:15 am

@Tig

I just tested using ruby 1.8.7 and it worked fine

edit and now it works with 1.8.5............how peculiar

john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby mattao987 » Sat Jan 05, 2013 2:18 am

I will try to update my ruby asap.
0

mattao987 
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby driven » Sat Jan 05, 2013 2:24 am

mattao987 wrote:I will try to update my ruby asap.

it's just a button click with the new [soon to be released plugin]
look up the mac ruby thread, I haven't got it handy,
or PM me
john
0
learn from the mistakes of others, you may not live long enough to make them all yourself...

driven 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby pmagans » Thu Jan 16, 2014 4:06 pm

TIG,
Do you know of any .stl batch importers? I have found two .stl importers but nothing with the batch capabilities.
Thanks
0

pmagans 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder

Postby TIG » Thu Jan 16, 2014 6:37 pm

@pmangans

This tool 'Import ALL from Folder' will batch import STL files - if you have the SketchUp STL import/export tool installed: http://extensions.sketchup.com/en/content/sketchup-stl

However because of that importer's coding I think it is not hash-able - so it will use the last options set in its dialog - and you must answer 'Yes' when prompted for each STL file in imports as that can't be switched off...

Get 'Import ALL from Folder' v1.3 here: http://sketchucation.com/pluginstore?pl ... rom_folder
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder

Postby pmagans » Thu Jan 16, 2014 9:25 pm

Thanks TIG that worked
0

pmagans 
Premium Member
Premium Member
 

Re: [Plugin] Import ALL from Folder

Postby bitslapped » Tue Jun 10, 2014 11:50 pm

I love this plugin. I think a nice addition would be an option to import onto a grid so components are easier to manage.
Thanks TIG
0

bitslapped 
 

Re: [Plugin] Import ALL from Folder

Postby TIG » Wed Jun 11, 2014 9:15 am

bitslapped wrote:I love this plugin. I think a nice addition would be an option to import onto a grid so components are easier to manage.
Thanks TIG
Try http://sketchucation.com/pluginstore?pl ... nents_grid
This arranges installed components on a user chosen 'grid'...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder v1.2 20110529

Postby YoungOSG » Thu Jan 15, 2015 7:24 am

TIG wrote:
mattao987 wrote:...I'd like to add an optionnal STAGE in your script.
Once a file is imported, i'd like to create a new layer named by reference to the file name with a suffix.
Let's say Wonka_Niv1
Then, Group all the freshly imported items on this new layer.
Then proceed to the next file...

What file type are you importing?
SKP and Others need to be treated differently...
Obviously none of this 'Layering' stuff will ever work with imported 'Images' !!

For non-SKP files:
Provided there is at least one object already in the receiving-SKP, then all imported formats [other than a SKP] will already import as a component named after the file - e.g. "Wonka_Niv1.dwg".
So after line#84:
model.import(file,false)
add these lines:
unless File.extname(list[0]).downcase==".skp"
ins=model.definitions[File.basename(file)].instances[0]
ins.layer=model.layers.add(File.basename(file, ".*"))
end#if

Note: this uses the imported files 'basename' [e.g. "Wonka_Niv1"], to use the full name with say its '.dwg. suffix use ...add(File.basename(file)) instead

For SKP imports you will need to edit another part of the code:
after line#107:
ins=model.active_entities.add_instance(defn,tr)
add this:
ins.layer=model.layers.add(name)
This uses the imported SKP's name, without any '.skp' suffix [e.g. "Wonka_Niv1"] - but if you want to add one, then change ...add(name) to ...add(File.basename(file))

This should do what you want... :D




after i use this plugins to add ade files,i can not see them!
i can not understand why.
any helps?
0

YoungOSG 
 

Re: [Plugin] Import ALL from Folder

Postby TIG » Thu Jan 15, 2015 6:17 pm

You said 'ade', I guess you really meant '.DAE' ?
They should import OK.
Any error messages in the Ruby Console when try it ??
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Import ALL from Folder

Postby YoungOSG » Sun Jan 18, 2015 2:47 pm

TIG wrote:You said 'ade', I guess you really meant '.DAE' ?
They should import OK.
Any error messages in the Ruby Console when try it ??

Yes! I mean *.dae files.
I use your script.and add purge_unsed,export.
However i need to handle thousands of files.Sketchup always crashes after export few files.
I really don't know how to fix it.
any helps?
0

YoungOSG 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: thinga, zul6041 and 23 guests

Visit our sponsors: