[Plugin]export_by_layer.rb
-
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')
Put in Plugins Folder... -
There's API methods to export to different filetypes?
-
@thomthom said:
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. -
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... http://forums.sketchucation.com/viewtopic.php?p=183756#p183756 -
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.
-
@tig said:
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')
[attachment=0:144rdr3z]<!-- ia0 -->export_by_layer.rb<!-- ia0 -->[/attachment:144rdr3z]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? -
@jackalvn said:
@tig said:
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')
[attachment=0:334crvrl]<!-- ia0 -->export_by_layer.rb<!-- ia0 -->[/attachment:334crvrl]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.
Usage:
export_by_layer(type)Typed in Ruby Console or another script...
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 inexport_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... -
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.
-
How to export as png o jpg files with this plugin, please ?
-
hi.
what should i do if i want to export a section from my model in 2D dwg with layers? -
to export 2d graphics by layer you can exchange line 72
model.export(modelpath+"/"+modeltitle+"_Layer"+layername+"."+type,false)### exporterby:
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.
-
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
Advertisement