MoI discussion forum
MoI discussion forum

Full Version: FBX multiple objects export to separate files.

Show messages:  1-8  9-27

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
From: Anton.Berezin (ANTONBEREZIN)
19 Nov 2020   [#21] In reply to [#20]

Yes sure.
And sorry for my incompetence

Attachments:
ExportNamedObjectsToIndividualFiles_test.js
test.3dm


From: Michael Gibson
19 Nov 2020   [#22] In reply to [#21]
Hi Anton, try this attached one, and also the script is expecting the line's object name to be "reg_line" but in your .3dm file it is named "Testline".

I still didn't test this so please let me know if it still doesn't work and I will take a closer look.

- Michael

Attachments:
ExportNamedObjectsToIndividualFiles_test.js


From: Anton.Berezin (ANTONBEREZIN)
19 Nov 2020   [#23] In reply to [#22]

Oh thanks man. It is realy working.
How could I thank you?
I am illustrator and if you need something to draw let me know.
(yaberezinanton@yandex.ru)


From: Michael Gibson
19 Nov 2020   [#24] In reply to [#23]
Hi Anton, that's great!

> How could I thank you?

It would be fun to see some of the output that you're using it for! :)

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

I’m trying to create method to export a complex illustration\model as different parts\files for further processing and assembly in Adobe illustrator.

I will show you the result

Thanks again


From: Mindset (IGNITER)
1 Jan 2023   [#26] In reply to [#22]
Hey Michael,

How can I make ExportNamedObjectsToIndividualFiles work for STEP [(*.stp, *.step, *.stpz) (AP 203, AP 214, AP 242)] ,or SAT [(*.sat) (Up to 2020)] Files?
Also, my target app, Alibre Atom3D, accepts only one Solid per file.
This script will write out every object having an identical name to the same file.
Might it append a numeric incremental for each such duplicately named solid and thereby save it into its own separately named file?
Another problem is that it will write out a group, rather than just its individual constituent solids.
Also, might the user pick the output directory at runtime ?


Thanks,
MindSet
From: Michael Gibson
1 Jan 2023   [#27] In reply to [#26]
Hi MindSet,

Are you using the ExportNamedObjectsToIndividualFiles.js that was in this previous post? :
http://moi3d.com/forum/index.php?webtag=MOI&msg=8226.8

re:
> How can I make ExportNamedObjectsToIndividualFiles work for STEP [(*.stp, *.step, *.stpz)
> (AP 203, AP 214, AP 242)] ,or SAT [(*.sat) (Up to 2020)] Files?

MoI will figure out what file type to write based on the file extension on the filename.

So to make it export STEP instead of FBX, go to line number 43 in the script which has this currently:
code:
    var filename = g_dirname + name + '.fbx';

And change the .fbx to .stp like this:
code:
    var filename = g_dirname + name + '.stp';

re:
> Might it append a numeric incremental for each such duplicately named solid and thereby save it
> into its own separately named file?

I've attached a version that should do that.


> Another problem is that it will write out a group, rather than just its individual constituent solids.

This should be fixed in the attached version also.


> Also, might the user pick the output directory at runtime ?

Sorry no that's not easy to do currently because there is not a directory picking UI set up for a script to use. I'll see what's involved in setting one up.

- Michael

Attachments:
ExportNamedObjectsToIndividualFiles.js


Show messages:  1-8  9-27