Script request

Next
 From:  Oliver (FRITZ57)
8230.1 
Hi all,
I'm looking for a script able to automate file export of all named objects to the obj format.
The file export options are identical for all named objects as is the destination folder.
The usual dialog should be suppressed and the script assignable to a shortkey.
I could dig thru all the MOI API JS documentation, but I'm sure such a script already exists on some script expert's hd .-)
TIA
Oliver
o5m6.de
Beware of the hun coming out of the sun ;-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.2 In reply to 8230.1 
Hi Oliver, so just to clarify, you want each named object exported to its own individual file? Or do all the named objects go into a single file?

How would the destination folder be specified?

> The usual dialog should be suppressed and the script assignable to a shortkey.

There are 2 dialogs usually shown for .obj export, one for picking the file name and the next one for meshing options. Which of these were you referring to?

If you don't want the meshing options dialog to be shown, do you just want the default meshing options used?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Oliver (FRITZ57)
8230.3 In reply to 8230.2 
Hi Michael,

first of all, thanks a lot for your quick reply, amazing and much appreciated !

>> you want each named object exported to its own individual file? Or do all the named objects go into a single file?
Each named object should be exported to its own individual file, same name as the object name.

>> How would the destination folder be specified ?
I would hardcode it into the js file.

>> There are 2 dialogs usually shown for .obj export, one for picking the file name and the next one for meshing options. Which of these were you referring to?
Both. File name = object name + ".obj"

>> If you don't want the meshing options dialog to be shown, do you just want the default meshing options used?
I would hardcode those into the js file as well.

Best,
Oliver
o5m6.de
Beware of the hun coming out of the sun ;-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.4 In reply to 8230.3 
Hi Oliver, that should be feasible, I'll give it a try later on tonight.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.5 In reply to 8230.3 
Hi Oliver, please try the attached script. There are instructions for installing a plug-in script here. This script only has a .js file, no .htm since it does not show any UI.

You will need to edit the script to alter the directory name, it's near the top. Also there's a note in there on how to set an option in moi.ini for how to turn off script file caching, if you don't do that you'd need to exit MoI every time you edited the script since by default they're cached in memory and not reloaded.

To adjust the meshing parameters you'll need to alter the second parameter that's sent to moi.geometryDatabase.fileExport() , like to make it use an angle of 10, edit that line to be:
moi.geometryDatabase.fileExport( filename, 'NoUI=true;Angle=12.0' );

If you remove the NoUI=true part then the meshing options dialog will be displayed.

Hope that does what you were looking for!

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
8230.6 In reply to 8230.5 
Hi Michael and good morning.

Thank you very much for this very useful script!!!

Best,

- Marco (mkdm)

P.S. How to put inline BBcode images inside forum messages ?

- Marco (mkdm)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.7 In reply to 8230.6 
Hi Marco, for this forum use html like tags, like <code></code>

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
8230.8 
for image
img src="name_image.jpg" /
between <>
---
Pilou
Is beautiful that please without concept!
My Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  mkdm
8230.9 In reply to 8230.8 
Thanks :)

- Marco (mkdm)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Oliver (FRITZ57)
8230.10 
Great, Michael, works like a charm, thank you !

It's important to delimit the parameters of fileExport with ";" and inclose them in " ' " like here :

moi.geometryDatabase.fileExport(filename,'NoUI=true;Angle=12.0;Output=quads;Weld=true;Display=shadedwithedges');

Perhaps the script could be added to the script collection.

Another question
Is there a way to compute the minimum size of the exported object
for an uvmap size of, say, 2048 pixels ?
I want to keep my obj files as small as possible before being unwrapped and uvmapped in 3D Coat.

TIA
Oliver
o5m6.de
Beware of the hun coming out of the sun ;-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.11 In reply to 8230.10 
Hi Oliver, I'm glad that is working for you!

re:
> Another question
> Is there a way to compute the minimum size of the exported object
> for an uvmap size of, say, 2048 pixels ?

Sorry I don't understand this question, what size is it that you want to compute in pixels? There isn't really anything that MoI generates to an .obj file that is measured in pixels.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Oliver (FRITZ57)
8230.12 In reply to 8230.11 
Hi Michael,

just wanted to know if there's a way to reduce
the uvmap size by reducing the model size.

I have a really huge model to be textured that
is bursting 3D Coat in the Paint Room.

So I guess I will have to reduce the polycount
to get the work done.

Anyway, Merry Christmas to you and all of the members
of this outstanding forum and a happy 2017 !!
Oliver
o5m6.de
Beware of the hun coming out of the sun ;-)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
8230.13 In reply to 8230.12 
Hi Oliver, Merry Christmas to you as well!

But for the UV map size question, sorry no there isn't any connection between model size and UV map size. The UV coordinates MoI exports are pretty basic, every face in the model has UV coordinates between 0 and 1. These coordinates are not pixel coordinates though, they're coordinates in an abstract unit square representing the texture map width and height without any specific pixel coordinates. Pixels only come into play when you assign an actual texture bitmap to something later on.

But if the default UV coordinates that MoI is exporting is causing a problem in 3D Coat and you're going to need to make a new UV mapping anyway you could just turn off the UV coordinate export by a setting in moi.ini , go to Options > General > "Edit .ini file" button. Then go to the [OBJ Export] section and find this line:

[OBJ Export]
<...>
WriteTextureCoordinates=y
<...>

And change that to say WriteTextureCoordinates=n instead.

Hope that will help!

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  chippwalters
8230.14 
Good hint, Michael. Thanks for sharing!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All