Sign in to follow this  
othelarian

From Studio to Blender: a script!

Recommended Posts

Hi dear community!

I restarted building recently, and I changed for Studio instead of Mecabricks. With Mecabricks it was easy to transfer the model from the workshop to Blender, but I wanted to use some specific parts, plus some others studs, so I needed to switch. But it isn't that easy to transfer from Studio to Blender.

Maybe you heard about the laziness of software engineer and their tendancy to script everything to get rid of repetitive and boring tasks. Fun fact: it's quite true.

So I wrote this script : https://github.com/othelarian/studio2blender/releases/tag/first_release

It's a simple python file to make your life way easier when dealing with a Studio model.

How it works?

Let's go for a little howto!

  1. First, export your model from Studio, in the Collada format (.dae), with Winding Order set on Clockwise, and Coordination on Right Handed.
  2. Then, import the model in Blender (File => Import => Collada (.dae), it can take some time, wait for a success (the model appears!) or an error message).
  3. After the successfull import, open a scripting area (generally there is a layout called "Scripting" with one already open) and open the studio2blender.py file.
  4. Finally, run the script (the little triangle next to the "open" button on the top of the area).

What this script do?

That's a really good question!

In the exact order, the script does this:

  1. execute a "clear parent inverse" to fix the orientation of the parts after the import
  2. execute a "clear parent but keep transform", to isolate the empties created by the import from the part
  3. delete the empties, because there aren't needed anymore
  4. do some Blender internal stuff about making multi user object's data unique to each object
  5. apply scale transformation (needed to fix some issue when rendering)
  6. remove duplicated vertices by merging them, to reduce the nnumber of vertices (not the number of triangles though)
  7. apply normals auto smooth to get back the sharpness on the edges

What can go wrong?

This script is far from perfect, here a couple things to take care of when using it:

  • if you're working with big models you can easily reach millions of polygons. A solution to that is used directly by the importer to use multi user data, which help keeping the number of polygons low. But to apply scale transformation Blender needs that each part as its own data, and the script needs to break the multi user data to do that. There is a workaround but I didn't include it in this first release, so keep an eye on the model statistics in Blender.
  • the script looks for an object called "Model" to delete it, because it isn't needed to work with the parts (the script already clear any issue with parenting). But if you need to keep every parts under a single parent, then the script is your ennemy as it puts every parts on the top of the hierarchy.
  • still with the "Model" object, if you import multiple Studio models they get a new name build like this: Model.XXX, where XXX is the number of the model (Model.001, then Model.002, etc). If this is the case, the Model.XXX won't be deleted by the script.
  • the script is executed onto the entire scene, no matter the number of models, or if you already imported and cleaned with the script other models, and most importantly, the script doesn't care if it is running over the model you imported or over other objects you may have created directly in Blender. Every object with the word "dot_dat" in its name would be deleted.
  • For big models with submodels I have to run the script twice. I didn't have enough time to investigate further why. To be sure the script finish successfully, take any part and look at its normals auto smooth, it must be activated.

What's next?

I have plenty of idea to make this script better, but I also want to spend my time on building more than writing some code. For now I don't know if I'll continue a little or not.

Here some ideas already plan for "one day":

  • Transform the script to a Blender addon
  • Try to handle the import directly in the script
  • Limit the script execution to one Model
  • Insert an option to keep a global parent for the model (to keep things organized)
  • Fixing the submodel issue
  • Enable submodel separation option
  • Include the workaround for multi user data

 

Feel free to ask me for any script variation you may need. I may answer with some delay, and maybe it'll be too hard or to time consuming to make it, but at least I can give you some advice :wink:

Have a great build!

Share this post


Link to post
Share on other sites

hello i just made this account and had a question i downloaded the script and nothing happened does it still work when i went to blenter addon it didnt show up  is there a new verson of it or updated one

Edited by blueblock

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.