[beginner] Added some functionality to .3ds importer, how to succeed

(KGyST) #1

One of my long standing problems got solved. I build models with ArchiCAD, import through .3ds, and finish them Blender.
The problem was that .3ds format’s materials didn’t know many things that that of Blender did, so I had to modify/improve materials in Blender. But if I worked again with the project in ArchiCAD (these iteration cycles are quite common), and imported the stuff again to Blender, I had to change all the materials of the imported stuff to the (more advanced) Blender materials. So, say, I had a ‘Grass’ material in Blender, then with the new import a ‘Grass.001’ was made, and I had to select all objets with ‘Grass.001’ material to change them back to ‘Grass’. If there were 100 materials in My scene, I had to do this a hundred times. (And there were 100 materials with 0 user.)
Now I have played around a bit and added an option to enable Blender to add the existing material to the imported geometry (or add it the old way).

My question is if this is meaningful to add the option to the Blender development and if Yes, how to do it?


BTW the current version of the script is here:

(romanromanroman) #2


This would be an extremly usefull tool!!! any news on that or can you send me the source code?


(KGyST) #3

I’ve uploaded the zipped file to my Dropbox folder, here is the link:
You need to unpack the zipfile to …\Blender(current version, say, 2.68)\scripts\addons (there should be a folder with the same name that is strongly suggested to be backed up before unzipping). If all works, You will see the 3ds import option in Your File menu (at the old place), and after clicking it, a new option in the importer (Add material: Use existing/Add), that does the job.
It’s only tested with 2.64 and probably 2.65, not with the current versions.
Needless to say, I don’t guarantee anything, however, it should work well.
Have luck.

(JMininger) #4

I also do architectural work in another program and import to blender so this is a very important add-on for me as well. Thank you so much for sharing it. I am getting mixed results though. Some materials use the existing ones correctly and others duplicate with the new name .001 Do you have any suggestions or a newer version that might help to solve this? Thanks.

(KGyST) #5

I’m curious about this problem, would You make a shrinked down .blend/.3ds file combo with such materials? I’d check what’s the problem and fix it if I can.

(JMininger) #6

Thank you for taking a look at it. Here is the link. Materials like “vienna rug” and “pine (brown)” replace correctly. Others create duplicates with the new name .001

(KGyST) #7

Thanks, I’ll give it a try at the weekend.
(My computer that I use Blender with is not perfect now, please leave the file at Dropbox for some more weeks)

(KGyST) #8

I think now the stuff works, I’m curious about Your opinion:

(bat3a) #9

i tried it today and got this error:

global: N
importing 3DS: ‘C:\Users\*****\Desktop\Wood N130112.3DS’…read material
New material: Standard_16
read material
New material: Standard_17
read material
New material: Standard_18
read material
New material: w mahagon
read material
New material: w
read material
New material: w mahagon1
read material
Traceback (most recent call last):
File “C:\blender\win64-mingw\2.69\scripts\addons\io_scene_3ds_init_.py”, li
ne 129, in execute
return import_3ds.load(self, context, **keywords)
File “C:\blender\win64-mingw\2.69\scripts\addons\io_scene_3ds\import_3ds.py”,
line 1002, in load
File “C:\blender\win64-mingw\2.69\scripts\addons\io_scene_3ds\import_3ds.py”,
line 896, in load_3ds
process_next_chunk(file, current_chunk, importedObjects, IMAGE_SEARCH)
File “C:\blender\win64-mingw\2.69\scripts\addons\io_scene_3ds\import_3ds.py”,
line 470, in process_next_chunk
process_next_chunk(file, new_chunk, importedObjects, IMAGE_SEARCH)
File “C:\blender\win64-mingw\2.69\scripts\addons\io_scene_3ds\import_3ds.py”,
line 518, in process_next_chunk
print ('New material: ’ + material_name)
File “C:\blender\win64-mingw\2.69\python\lib\encodings\cp720.py”, line 21, in
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: ‘charmap’ codec can’t encode characters in position 14-16: c
haracter maps to <undefined>

location: <unknown location>:-1

location: <unknown location>:-1

(KGyST) #10

This looks to be another kind of problem, Python doesn’t like different (non nativa) charsets. I suggest trying the old bundled importer, however, I might look at this problem in the Christmas holiday.

(bat3a) #11

I suggest trying the old bundled importer,

you mean the one u posted before, i tried it with the same error.
the original one that comes in the addon folder works with no errors, it’s just doesn’t import materials!

(KGyST) #12

I mean the original that comes with the Blender package, it’s a bit surprising that doesn’t work or fails in a different way.

(bat3a) #13

no it works, but it doesn’t import materials! which is why i tried your version!

(JMininger) #14

I’m not sure why I never saw your revised script until now but this worked for me and I am very grateful for your help!

(KGyST) #15

Now i have a new version.
-I have fixed problems with native characters, now they are decoded properly to the OS system language. No more ugly chars.
-I have added my fixa idea and set the Receive Transparent Shadows to True
-Fixed bug: if material’s alpha is less than 1.00, then Transparency is set to True

In theory the link is the same:

(KGyST) #16

Again, a new version
-The script now checks only the first 16 characters of materials to match, since the .3DS format has such a limitation for material names, while Blender allows longer names

The link stays the same:

(JMininger) #17

This has been a tremendous help to me. Thank you again for the update!

(simdal) #18

Hi KGyST, thank you! thank you! thank you! fantastic job! Your system works. I was looking for so long. It was an important function that was missing in the blender. you’ve been very good. Thanks again.

(JMininger) #19

I am getting an error with the newest version. I am using Blender 2.77 on a Macbook OS X 10.11.4 Any help would be appreciated. Thanks again.


(KGyST) #20

I have no Mac to test it but it seems that the script on mac is not able to get the locale normally. I’ll look for a workaround.

The error might be something like this:

And You should try a workaround like this:
find the line

samu_locale = locale.getdefaultlocale()[1]

in file “import_3ds.py”, and change it to:

samu_locale = ‘UTF-8’

This might solve the problem.