Is this possible? [code] batch export

Is this possible? [code] batch export

Postby robmoors » Thu Dec 27, 2007 7:41 pm

I was wondering is there a ruby out there which does this?

I have to export my 3D models in several 3D extensions. Its a time consuming thing to do by hand if youve got to export 10 models in 5 different formats each time. So I was wondering can this be automated with a ruby?

Something like this:

- Open model
- Click Ruby
- Tick the 3D extensions you want your model exported in
- Select a folder all these exports go into
- Press okay and supress any file name errors by automatically accepting them (3ds and a few more replace the spaces between words with underscores and asks if this is okay)
- SU starts exporting each 3D extension one by one with just that one click

Is this possible, or is something like this out there? It would mean the world to me.

Any help in this matter would be greatly appreciated!!
0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby Jim » Thu Dec 27, 2007 7:42 pm

Rob,

I think it's possible, at least most of it. What extensions should be available as options?

The core functionality is simple. If you can make this work, the rest is grunt work. You can copy and paste it right into the Ruby Console to test it.
Code: Select all
%w(dxf kmz fbx obj).each {|ext| Sketchup.active_model.export("/testmodel.#{ext}",false)}


This files should be create on c: on a Windows machine, and the / folder on a Mac (I assume.) I don't have the Pro exporters and so can't test them.
0
Hi

Jim 
Global Moderator
 

Re: Is this possible?

Postby Dave R » Thu Dec 27, 2007 7:42 pm

Jim, I tried your line of code and it seemed to work. There was a stop after the DXF export for user acknowledgement that the export had completed. I imagine Rob would like even that to be automated if it could be.
0
Etaoin Shrdlu


%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: Is this possible?

Postby Jim » Thu Dec 27, 2007 7:43 pm

Dave R wrote:Jim, I tried your line of code and it seemed to work. There was a stop after the DXF export for user acknowledgement that the export had completed. I imagine Rob would like even that to be automated if it could be.


That's promising. I edited the code snippet to add an explicit "false" to the export. If this does not make the DXF acknowledgment dialog go away, I don't think there is anything that can be done about it.
0
Hi

Jim 
Global Moderator
 

Re: Is this possible?

Postby todd burch » Thu Dec 27, 2007 7:43 pm

That specifically is a bug that's been reported already. (the dxf / false thingy)

Todd
0

todd burch 
 

Re: Is this possible?

Postby robmoors » Thu Dec 27, 2007 7:43 pm

Hey guys, thanks for your help so fast!

I want to export to

.3ds
.dwg
.dae
.obj

I would be willing to bash my return button a few times to make those pop ups go away. Is it possible that way?

Keep in my I have no idea how ruby's work, so that piece of code looks really fancy to me but what to do with it is beyond me. :P
0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby RickW » Thu Dec 27, 2007 7:44 pm

Using a dot-slash ( ./ ) puts the export files in the same folder as the original file (assumes the file has been saved somewhere), which might be more convenient.

Regardless, nice one-line coding :) Too bad this wasn't issued specifically as a ruby challenge item...
0

RickW 
 

Re: Is this possible?

Postby RickW » Thu Dec 27, 2007 7:44 pm

Rob,

To export to the types you specified, just change the stuff in parentheses after the %w at the beginning - something like

%w(3ds dwg dae obj)......

and leave the rest of the code intact.
0

RickW 
 

Re: Is this possible?

Postby robmoors » Thu Dec 27, 2007 7:45 pm

And I enter the code into the ruby entry console? or could I form it into a nice button?
0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby todd burch » Thu Dec 27, 2007 7:45 pm

Make 2 nice buttons and post them here. a 16X16 pixel and a 32X32 pixel. Someone will do it. ;)
Todd
0

todd burch 
 

Re: Is this possible?

Postby robmoors » Thu Dec 27, 2007 7:47 pm

Here you go 2 quick png's


0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby robmoors » Thu Dec 27, 2007 7:47 pm

Pwetty Pwease someone?
0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby brad » Thu Dec 27, 2007 7:48 pm

Hey Rob,

I just continued where Jim and Rick left off.

Put the contents of what is in the attached .zip into you plugins directory and restart SketchUp.

You'll see your icon that you made. Open a model click on the tool bar icon. The model will be exported to c:\ with the models name i.e. whatever the name says in the Title bar. I also gave the icon a tool tip and the status bar text.

Let me know if that works. This is a first draft and I'm sure it could be better.

BTW the defect Todd was talking about "not suppressing the results dialog after dwg export" is fixed and will be in the next version of SketchUp.

Hope this helps, I hope it doesn't suck....it good to breath clean air :mrgreen:

sas/Ruby/Export_Toolbar.zip
0
Brad
SketchUp QA
User avatar
brad 
SketchUp Team
SketchUp Team
 

Re: Is this possible?

Postby robmoors » Thu Dec 27, 2007 7:49 pm

Thanks alot Brad!
This will save me and the guys over at FF quite a bit of time!

If anyone is interested in advancing this ruby,
A window in which you can tick the exports and specify their file names and their location would be awesome.

But for now this works perfectly! It indeed is nice to breath clean air Brad ;) !
0
Rob Moors
Architecture Student

robmoors 
 

Re: Is this possible?

Postby boofredlay » Mon Jan 21, 2008 5:32 am

robmoors wrote:If anyone is interested in advancing this ruby, a window in which you can tick the exports and specify their file names and their location would be awesome.

Any progress on this one?
I used it the other day and all the files showed up with no name, just a .dwg .obj etc...
I would welcome a more refined script.

Thanks.
0
User avatar
boofredlay 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: HouseMan and 7 guests

Visit our sponsors: