Import OBJ but using existing material?

Hi

I wanna import an OBJ-File (it contains already materialnames for example “groundfloor”).
In my Blender file I’ve already a set of materials (Cyclematerials) with the same names as in the OBJ-File.

But when I import the OBJ-File Blender always creates new materials. Instead of using the existing material “groundfloor” Blender creates a new material named “groundfloor.001”.

What do I have to do that Blender assigns automaticly existings materials to the imported OBJ-File ?

Or are there some other methodes, maybe a plugin ?

BTW: The same happens when I import a material from another Blenderscene. I wanna replace the existing material and not create a new material.

Edit:
There should be 2 options when an Obj-File get’s imported and if it has an existing Material:

  1. Use the existing Material in the Blenderfile instead of the imported one
  2. Use the Material from the imported File
    And a Checkbox: Always do the selected action when a material already exists in the Blenderfile

Kind regards
Alain

Sound like you only want to import the Objects mesh. You can “Append” mesh information only you know.

How do you mean that ?

Can you discribe please in detail how you would do that ?

Edit:
When I only import the Mesh then nothing happens in the Blenderscene.
When I only import the Object then Blender creates a new *.001 Material

So how is the workflow to use existing materials automaticly ?

Kind regards
Alain

This is not possible in Blender, right ?

Kind regards
Alain

Can somebody help me please ?

Kind regards
Alain

I cannot import large obj meshes too. Blender eats all the memory and crashes the os. Tested 2.58 - 2.61. I think its time to report a bug.

How large are your files? Importing a mesh with 8.75 million polygons in .obj format (372MB) worked flawless for me using 2.61. Though memory usage increased to a total of max. 7.4GB while importing.

edit: sorry Alain for going off topic. But since you got this on Campbell’s toDo list, it probably will work sooner or later. :slight_smile:

To my knowledge you won’t be able to import a mesh with a material name and have it auto-magically map to a same name material in Blender (or any application for that matter). You will have to select the mesh and use the material pulldown to re-assing to the new material. It’s really not difficult and even with a few dozen materials doesn’t take all that long to do.

Beyond that, you could try to delete the .mtl file (material library) with the .obj but I doubt that will do it. MeshLab I think has some tools to do this, but it’s such a detailed application that I haven’t been able to successfully do anything regarding materials with it. I know that doesn’t answer your question, but hopefully helps to get some direction.

I’m sure you don’t wanna waste your time with re-assigning 30 materials in a scene every time you update it.
My Workflow in architecture visualization is modelling in Sketchup (because it’s very easy, fast and intuitive to use), exporting to an OBJ-File and importing it in Blender. In Blender I add vegetation (tenthousand of instanced grass patches, trees and so on because Cycles supports instanced Objects and saves me ALOT VRAM).
And normaly I have to modify my Sketchup-Modell 3, 4 or n-times because the customer wants some changes.
So I have to restart importing it an assign my 30 materials again… I’m sure you wouldn’t wanna do such a boring and timeconsuming task :wink:

It’s no problem to expand the OBJ-Importscript with an automaticly “Assign existing Materials-Function” (Cambpell told me it wouln’t be such a big task for him ;-)).

Kind regards
Alain

Alain, thanks you for this initiative. I very need this feature too. It is boring after import obj re-assign the same material again and again.

Sorry, I was trying to offer you possible workarounds. If you are questioning my personal workflow, it’s usually a mute point, I don’t usually have to do multiple exports/imports. In the event that I actually do, I want to simplify the scene and reduce memory (in other words I want my models to be complete, but if something is obscured, I don’t want the textures loaded, same as you, VRAM consideration). I also like to examine every material (even though I have nodes pre-built) to ensure correctness.

Too bad he can’t also fix the importer such that it has the 2.49b options. Often when I import mesh I need it separated by material otherwise the import fails. Right now I import to 2.49b, save the blend and append to a new scene in 2.61. I long for the days I don’t need 2.49b anymore.

Any news with: OBJ-Importscript with an automaticly “Assign existing Materials-Function” , please ?
It´s annoying again and again fix material, material.001, material.002, material.003 …
Thanks.

With the help of Calli (the autor of the german Blenderbook “Das Blender-Buch”) I expandet the script with a checkbox-option “Use Blender-Materials”.
It works pretty well and covers all my needs now.
I hope it does for you as well :slight_smile:

Just overwrite the two files in the …\Blender Foundation\Blender\2.61\scripts\addons\io_scene_obj with the ones in the attached Zipfile.

I’ve only tested it for Window.

Edit:
See the Post below for the update of the Script, this one here does not work anymore.

Kind regards
Alain

Attachments

io_scene_obj_use_existing_materials_01_05022012.zip (12.8 KB)

Alain, very, very thanks. It works perfectly, will save a lot of my time.
I have blank file with tens of my tuned materials and I often import into this file objects with tens of materials. These materials have the same name and with this patch they are immediately assigned according its name…
A couple of second after import, I can render with tuned materials. It is fantastic, could be in trunk, i think.
Again, thanks.

I sended the patch to Campbell (the autor of the script) for a review. I hope he did not forget it :wink:

Edit:
The patch should be added in all kind of Importfunctions.
Also by importing Objects from other Blender-Files.
But I’m not able to do that.

Kind regards
Alain

I just updated the Patch with the newst Build (blender-2.62-r45133, Sun Mar 25 03:09:10 2012).

You can download it here:
www.archiviz.ch/download/io_scene_obj_25032012.zip

Kind regards
Alain

Alain thanks, I had no hope :slight_smile: , but after opening this file, it is empty, only 160 B size.

Sorry, my mistake :o
The Zipfile is not empty anymore now :slight_smile:

Thanks, works well, I think again, It should be in trunk, very useful feature. :slight_smile:

Maybe if you try to convince Campbell as well he will include into trunk :slight_smile:

Here is my “Patch”-Tracker (or how ever it’s called ;-)):
http://projects.blender.org/tracker/?func=detail&aid=30380&group_id=9&atid=127

So pls leave a comment there.

Kind regards
Alain