[Plugin]export_by_layer.rb

[Plugin]export_by_layer.rb

Postby TIG » Thu Sep 10, 2009 5:35 pm

Usage: export_by_layer(type)
Typed in Ruby Console or another script...
Exports everything in the active Model into a set of files 'by layer',
put in the Model's folder named with the 'layer_name' as a suffix.
The argument 'type' sets the file export type...
e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
Faces with their Edges on another Layer take those Edges with them...
For example: export_by_layer('obj')
export_by_layer.rb
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin]export_by_layer.rb

Postby thomthom » Fri Sep 11, 2009 11:30 am

There's API methods to export to different filetypes?
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin]export_by_layer.rb

Postby Jim » Fri Sep 11, 2009 12:54 pm

thomthom wrote:There's API methods to export to different filetypes?


Sort of - the type is taken from the filename extension in Model.export. There is no way to specify any options, as far as I know.
0
Hi

Jim 
Global Moderator
 

Re: [Plugin]export_by_layer.rb

Postby TIG » Fri Sep 11, 2009 2:09 pm

The only option is the 2nd argument true/false which either pops up a report on what's been exported or not. The export method decodes what type of file to export from the file suffix - e.g. .obj, .dwg, .dxf... I think that it takes the settings as given in the manual export dialog options... These can't be 'scripted' [unless on a PC you use WinScript and change the options by sending key-strokes...]

By default the whole model is exported - my work around is to export by layer - it temporarily erases everything else that's on other layers (except Layer0), then exports what's left and then undoes the erase so we are back as we started...

The idea can also be used to export a selection by temporarily grouping it and erasing everything else, then exporting what's left, then undo the erase and explode the group... I'll write a quick version...
EDIT: it's here... viewtopic.php?p=183756#p183756
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin]export_by_layer.rb

Postby xiobus » Fri Jan 15, 2010 9:03 pm

Hey tig that code doesn't 100% work for me when i use instead of export the save skp method sometimes extra stuff is deleted, seems to be an issue with groups not being handled in the code? And also when no groups are used rogue bits from other layers are included. I'll take a look at the code again and see if its handling groups or not.
0

xiobus 
 

Re: [Plugin]export_by_layer.rb

Postby jackalvn » Fri Apr 23, 2010 11:46 am

TIG wrote:Usage: export_by_layer(type)
Typed in Ruby Console or another script...
Exports everything in the active Model into a set of files 'by layer',
put in the Model's folder named with the 'layer_name' as a suffix.
The argument 'type' sets the file export type...
e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
Faces with their Edges on another Layer take those Edges with them...
For example: export_by_layer('obj')
export_by_layer.rb


Firstly, thanks for your work in this problem.
I wonder how it works. I don't see the icon or something like that in Sketchup menus or everywhere to active it. Could you give some tutorials step-by-step?
Secondly, I see there are few choices when exporting sketchup into cad while still keeping layers alive, especially when export sections.
Any help for this thing?
0

jackalvn 
 

Re: [Plugin]export_by_layer.rb

Postby TIG » Fri Apr 23, 2010 12:18 pm

jackalvn wrote:
TIG wrote:Usage: export_by_layer(type)
Typed in Ruby Console or another script...
Exports everything in the active Model into a set of files 'by layer',
put in the Model's folder named with the 'layer_name' as a suffix.
The argument 'type' sets the file export type...
e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
Faces with their Edges on another Layer take those Edges with them...
For example: export_by_layer('obj')
export_by_layer.rb

Firstly, thanks for your work in this problem.
I wonder how it works. I don't see the icon or something like that in Sketchup menus or everywhere to active it. Could you give some tutorials step-by-step?
Secondly, I see there are few choices when exporting Sketchup into CAD while still keeping layers alive, especially when export sections.
Any help for this thing?

You sort of answered your own question in the quoted text. :roll:
Usage: [ruby]export_by_layer(type)
Typed in Ruby Console or another script...[/ruby]
You can write a script to run it with a menu item etc BUT the simplest way is to open Window > Ruby Console and type in export_by_layer(type) + <enter>
Exports everything in the active Model into a set of files 'by layer',
put in the Model's folder named with the 'layer_name' as a suffix.
The argument 'type' sets the file export type...
e.g. if type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf', 'dwg'
Faces with their Edges on another Layer take those Edges with them...
For examples: export_by_layer('obj') or export_by_layer('dwg')
The files produced are named 'ModelName__Layer_Layer0.dwg', 'ModelName__Layer_DOORS.dwg', 'ModelName__Layer_WALLS.dwg' etc....
Exporting 3D keeps everything Layered in CAD, in 2D it does not work the same way...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin]export_by_layer.rb

Postby GooUser » Sat Sep 29, 2012 8:20 pm

Hello,

I would like to export individually layers as PNG ou JPG files, but this plugin not works when i tried with "export_by_layer "png".

Can you help me to understand or to propose me another solution if it exists?

----------------

Bonjour, j'aimerai exporter des calques Sketchup individuellement en tant qu'images PNG ou autres formats images. J'ai essayé ces plugins export_by layer et export_by_selection sans succès.Ils n'exportent pas les fichiers sous le format image. Après je ne sais pas si je m'y prends mal mais j'ai constaté qu'il exporte bien en format 3D comme OBJ. Donc je suppose qu'il ne fonctionne pas pour la 2D seulement ?

Auriez-vous une solution à me propser pour exporter en lot en format images, car exporter un par un est très long pour un modèle avec beaucoup de calques.

merci de votre aide.
0

GooUser 
 

Re: [Plugin]export_by_layer.rb

Postby GooUser » Tue Oct 02, 2012 1:35 pm

How to export as png o jpg files with this plugin, please ?
0

GooUser 
 

Re: [Plugin]export_by_layer.rb

Postby arain_89 » Fri Mar 27, 2015 8:13 am

hi.
what should i do if i want to export a section from my model in 2D dwg with layers?
0

arain_89 
 

Re: [Plugin]export_by_layer.rb

Postby julian_frey » Fri Sep 18, 2015 1:39 pm

to export 2d graphics by layer you can exchange line 72
model.export(modelpath+"/"+modeltitle+"__Layer_"+layername+"."+type,false)### exporter

by:
view = model.active_view
view.write_image (modelpath+"/"+modeltitle+"__Layer_"+layername+"."+type)

this will dissable all 3D-Export possibilities and you have to use valid Image file formats liek 'jpg' as type.
0

julian_frey 
 

Re: [Plugin]export_by_layer.rb

Postby cox » Thu Nov 02, 2017 12:30 pm

Hi everyone,

Is the script supposed to work with 'skp' extension too?

I am on Skethup Make 17, *dae and *kmz are exporting correctly but is there any way to save a native skp file by layer? The console reports: X files exported by layer, as 'skp'
altough there is nothing in the model folder.

Thanks a lot for the help!

Andrea
0

cox 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: atagharehshir, jackyhu94, maximt, sketchy22, summerv31, thedaverman and 10 guests

Visit our sponsors: