{REQ} Collada Mass Export by layer
-
Not sure if this is possible, but I was wondering if you could, via script, take a model and export all layers into separate .dae (.or fbx) files, and ideally have each layer exported with a 0,0,0 origin on center. The purpose is for exporting to Lumion, (but could be useful for iClone, UDK or other similar programs) where each part of a model that needs to be controlled separately, needs imported separately with it's own axis defined. Right now it's a matter of copying each component to a new file, moving it to origin and manually exporting a dae file for each item. I was wondering if a speed up would be possible through a plugin.
-
I already wrote one [almost two years ago] called '
export_by_layer.rb'
http://forums.sketchucation.com/viewtopic.php?p=183609#p183609
You just specify the extension, e.g. 'dae'export_by_layer('dae')
...
It'll use that exporter's current export option settings...
The 'origin' issue isn't addressed, as it assumes you want to keep all of the exported pieces in the same relative positions...
It'd be easy enough to write a 'centering' script to run on the exported SKP files later...
Try it and comeback... -
This will center any model on the origin...
Copy+paste the code in a file calledTIG-centerorigin.rb
in Plugins and restart Sketchupmodule TIG def self.centerorigin() model=Sketchup.active_model if model.entities != model.active_entities until model.entities == model.active_entities begin model.close_active rescue end end end#if ct=model.bounds.center ct.z=0 ### ve=ct.vector_to(ORIGIN) tr=Geom;;Transformation.translation(ve) model.start_operation("TIG.centerorigin") model.entities.transform_entities(tr, model.entities.to_a) model.commit_operation end end
Usage: type
TIG.centerorigin
in the Ruby Console.Note: the line starting 'ct.z=0' keeps everything at the same Z height, BUT you can add a # to the front of it IF want to center everything in the Z axis too...
-
Thanks TIG. I forgot about that one. Let me try it out and I'll let you know. Lumion sets its origin point for each imported item at 0,0,0, so if I have a table that is 20' from origin when exported, in lumion, all the move and other other transforms are then set 20' from the table as well. I suppose I could use Chris Fullmer's center on origin too and center all the layers on top of each other, export and then undo the centering operation. The only issue is that his script centers items based on the middle of the bounding box and not the bottom. Still, I could make it work. Thanks again.
EDIT - just saw your code response. I'll try that too. Thanks!
-
My TIG.centerorigin moves all geometry in the current SKP so that it's centered in the XY at the origin - the Z is unchanged but can be centered too by # out a line as explained... It means you need to process the SKP for each layer exported, but it pretty quick...
Advertisement