MoI discussion forum
MoI discussion forum

Full Version: FBX multiple objects export to separate files.

Show messages:  1-20  21-27

From: Moier (STARDUST)
21 Dec 2016   [#1]
Hi Moi'ers

After using several file formats in export I have settle with FBX as the best option for me (detail conservative) and I usually export each named/colored object part in separate file for better control in the render engine.

I wonder if you 'Gurus' can write a script that solves "multiple object export to separate FBX files"?

Would be awesome to reduce the export time

Thanks

Stardust


- Michael for Nobel Prize -
From: Michael Gibson
21 Dec 2016   [#2] In reply to [#1]
Hi Stardust, a few additional details would probably help, like how would the file name for each separate file be determined, do you want a file save dialog to pop up for each separate file or do you want to see the dialog to choose one base name and then have the other files be numbered versions like name01.fbx name02.fbx .

How do you want to control the meshing parameters for the multi file export, should the meshing dialog show up for each separate file?


> I usually export each named/colored object part in separate file for better control in the render engine.

I guess you'd need to pick one method for the script to do, should it make a separate file for each named object or should it be a separate file for each style?

- Michael
From: Moier (STARDUST)
22 Dec 2016   [#3] In reply to [#2]
Hi Michael

Thanks for the quick respond.

My first thought was to arrange this sequence (I might have missed some..)

- Activate the objects and styles you wish to export
- A dialog shows up with all objects marked, listed and named as the origin object
- Settings for export are made
- Name of the separate files will inherent the named objects when fix file is created.


This might be hard to make.. but it will be just great if :)


/Stardust
From: Michael Gibson
22 Dec 2016   [#4] In reply to [#3]
Hi Stardust, the more UI and dialogs that are shown tend to take a lot more time to develop. For example there isn't currently any already built in way to "activate the styles you want to export", if you needed to be able to pick styles that would involve some custom developed UI to do it.

I'd be more likely to be able to cook up something for you if it had less steps and less or no custom UI needed in it.

- Michael
From: Moier (STARDUST)
23 Dec 2016   [#5] In reply to [#4]
Great Michael

For me it sure could be very straight forward with "only" a new button - Multiple export
(It might even be dedicated to only fbx format if it will ease up the code)


Function as;

- Activate objects (no styles) to be exported
- Using same dialog as origin Settings
- Easiest way to name separate files, like 001..002..003 (If the files can inherit the object names it would be great)


The goal is only to export separate objects in "one click" operation


Thanks

BR
Stardust

- Michael for Nobel Prize -
From: Michael Gibson
23 Dec 2016   [#6] In reply to [#5]
Hi Stardust, someone else had a very similar request today and I just posted a script over in this other thread: http://moi3d.com/forum/index.php?webtag=MOI&msg=8230.1

Currently that script exports to .obj format, you can change it to export to .fbx format by editing the line number 42 that currently has this:

code:
var filename = g_dirname + name + '.obj';


to instead have this:

code:
var filename = g_dirname + name + '.fbx';


You also need to edit the directory name at the top of the script, that's the directory where the files will be written to, it will write a separate file for each group of named objects that are in the current model, and the exported file's name will be the object name. Right now it doesn't pay attention to selection, to make it only export selected objects, change line number 18 of the script that currently has this:

code:
var all_objs = moi.geometryDatabase.getObjects();  


to this instead:

code:
var all_objs = moi.geometryDatabase.getSelectedObjects(); 



You wrote:
> - Using same dialog as origin Settings

I'm sorry I'm not understanding this part, what is the origin dialog?

Hopefully that is close to what you were looking for though.

- Michael
From: Moier (STARDUST)
23 Dec 2016   [#7] In reply to [#6]
Wohaa.. Michael, you're a genius


Thanks a lot, I will test it right away.

Sorry for not being clear of the part > - Using same dialog as origin Settings
I mean the mesh setting dialog

Thanks

Merry Christmas

/Stardust



- Michael for Nobel Prize -
From: Michael Gibson
23 Dec 2016   [#8] In reply to [#7]
Hi Stardust, you're welcome!

I've attached here a modified version for you, which has the modifications I mentioned above to use selected objects only, and to write to .fbx files instead of .obj and additionally it will show the meshing options dialog during the first export so you can adjust the settings using the dialog, which will then be used by the rest of the exports as well.

- Michael

Attachments:
ExportNamedObjectsToIndividualFiles.js


From: Moier (STARDUST)
25 Dec 2016   [#9] In reply to [#8]
Oboy Michael, what can I say..you are incredible!!

Thanks a million

I wish you the best of holiday

/Stardust

- Michael for Nobel Prize -
From: Moier (STARDUST)
25 Dec 2016   [#10] In reply to [#9]
Hi Michael

I just want to double check that my changed file path is written correct when use in mac

line 12 ... var g_dirname = '/Users/user name/desktop/fbxexp/';

I am having problem to extract files to this desktop folder called 'fbxexp'


Thanks

/Stardust
From: Michael Gibson
25 Dec 2016   [#11] In reply to [#10]
Hi Stardust, sorry yeah for the Mac you'll need to set the path using a Windows path with a pretend z: drive, like this:

var g_dirname = 'z:\\Users\\user name\\Desktop\\fbxexp\\';

V4 will handle native paths better for the Mac version.

- Michael
From: Moier (STARDUST)
26 Dec 2016   [#12] In reply to [#11]
Amazing..Thanks Michael

This is an incredible forum master folks!
I cant think of another where you get this rapid respond, just wow

Thanks

/Stardust

- Michael for Nobel Prize -
From: Anton.Berezin (ANTONBEREZIN)
7 Oct 2020   [#13]

Hi.
Could it work for .ai format?

Thanks.


From: Michael Gibson
7 Oct 2020   [#14] In reply to [#13]
Hi Anton,

re:
> Could it work for .ai format?

It would work for .ai format too if you just change the file extension to be .ai instead of .fbx .

But one additional thing is that there is a dialog box that pops up when you export to .ai format for setting different options. It is possible to not show the dialog box for a script driven save by passing in an additional parameter to geometryDatabase.saveAs() or geometryDatabase.fileExport() . That would be a string parameter with NoUI=true in it, like this:

moi.geometryDatabase.saveAs( filename, 'NoUI=true' );

You can also set other options through script by having multiple settings in the string separated by semi-colons. The full list of parameters that can be set in this way is:

// PDF/AI export function parameter options:
//
// NoUI=true
// ProjectionView=top | 3d | front | right
// ScaleType=fit | preserveunits
// MoiScale=1.0
// PageScale=1.0
// PageUnits=mm | cm | in | pt
// CenterOnPage=true
//
// PageSize=letter | legal | tabloid | a3 | a4 | a5 | custom
// Landscape=false
// PageSizeCustomWidth=8.5
// PageSizeCustomHeight=11.0
// PageSizeCustomUnits=mm | cm | in | pt
//
// GenerateOutlines=true
// GenerateSilhouettes=true
// GenerateHiddenLines=false
// ShadedBackground=true
// IgnoreTangentEdges=false
// Resolution=25.0
//
// Line style properties for visible lines:
// VisWidth=0.1
// VisColorMode=fromstyle | custom
// VisColor=0,0,0 (r,g,b color value for lines when color mode = custom)
// VisLayerMode=fromstyle | custom
// VisLayerName=Visible lines (layer name to use when layer mode = custom)
// VisLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
// VisLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
// VisLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)
//
// Line style properties for outlines:
// OutWidth=3.0
// OutColorMode=fromstyle | custom
// OutColor=0,0,0 (r,g,b color value for lines when color mode = custom)
// OutLayerMode=fromstyle | custom
// OutLayerName=Outlines (layer name to use when layer mode = custom)
// OutLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
// OutLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
// OutLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)
//
// Line style properties for silhouettes:
// SilWidth=0.4
// SilColorMode=fromstyle | custom
// SilColor=0,0,0 (r,g,b color value for lines when color mode = custom)
// SilLayerMode=fromstyle | custom
// SilLayerName=Silhouettes (layer name to use when layer mode = custom)
// SilLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
// SilLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
// SilLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)
//
// Line style properties for hidden lines:
// HidWidth=0.1
// HidColorMode=fromstyle | custom
// HidColor=0,0,0 (r,g,b color value for lines when color mode = custom)
// HidLayerMode=fromstyle | custom
// HidLayerName=Hidden lines (layer name to use when layer mode = custom)
// HidLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
// HidLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
// HidLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)
//
// Line style properties for annotations:
// AnnWidth=0.1
// AnnColorMode=fromstyle | custom
// AnnColor=0,0,0 (r,g,b color value for lines when color mode = custom)
// AnnLayerMode=fromstyle | custom
// AnnLayerName=Annotations (layer name to use when layer mode = custom)
// AnnLayerPrefixSuffix=prefix | suffix (which of prefix or suffix are shown in the UI when layer mode = fromstyle)
// AnnLayerPrefix= (prefix to prepend to the layer name when layer mode = fromstyle)
// AnnLayerSuffix= (suffix to append to layer name when layer mode = fromstyle)
//
// HiddenLinesOpacity=0.75 (opacity only applies to PDF export, not AI export)
// HiddenLinesDashed=true
// HiddenLinesDashSize=0.75
// HiddenLinesGapSize=1.0
//
// UseAICB=true (for AI copy to clipboard on OSX, for going into Adobe Illustrator CS3 or older).
From: Anton.Berezin (ANTONBEREZIN)
18 Nov 2020   [#15] In reply to [#14]

Hi.
I used this script which exporting all objects to AI* files, but all objects (fit to page). I used 3d viewport.
I think it will be good idea if it exporting each object + one test object( named "scale") maybe just line or rectangle.

This will allow the save scale of the objects relative to the test object and to each other

Could you help me to add this function to script?

Thanks


From: Michael Gibson
18 Nov 2020   [#16] In reply to [#15]
Hi Anton, are you exporting a 3D perspective view? Because if so the length of a line with perspective applied will not be able to give a scale factor like that.

- Michael
From: Anton.Berezin (ANTONBEREZIN)
18 Nov 2020   [#17] In reply to [#16]

Please check my images maybe it will be more clear.
Thanks.

Image Attachments:
image-01.png  image-02.png 


From: Michael Gibson
18 Nov 2020   [#18] In reply to [#17]
Hi Anton, so if I understand right you want the line to establish a common page width?

Is the script you are using the "ExportNamedObjectsToIndividualFiles.js" from above in this thread (http://moi3d.com/forum/index.php?webtag=MOI&msg=8226.8) ?

Do you want something like the line has a certain name and the script will export that additionally to each file?

So in the script ExportNamedObjectsToIndividualFiles.js, on line 36 it has this currently:

code:
for ( var name in named_objs )
{
	// Clear the selection and then set all objects of this name to be selected.
	moi.geometryDatabase.deselectAll();
	named_objs[name].setProperty( 'selected', true );


So if you want the line to export with each file, it could go like this:

code:
for ( var name in named_objs )
{
	// Clear the selection and then set all objects of this name to be selected.
	moi.geometryDatabase.deselectAll();
	named_objs[name].setProperty( 'selected', true );

// new code here:

	var line_name = 'reg_line';
	if ( name == line_name )
		continue; //  Don't export the line all by itself.

	// select the line so it will export.
	if ( named_objs[line_name] )
		named_objs[line_name].setProperty( 'selected', true );


I haven't tested that, let me know if it doesn't work.

- Michael
From: Anton.Berezin (ANTONBEREZIN)
19 Nov 2020   [#19] In reply to [#18]

Sorry but it is not working.
Probably just I am not good java developer.


I am getting all 3 objects (1,2, line) as separate files

Thanks for your help again


From: Michael Gibson
19 Nov 2020   [#20] In reply to [#19]
Hi Anton, can you please post the current script you have and an example .3dm file ?

- Michael

Show messages:  1-20  21-27