View Issue Details

IDProjectCategoryView StatusLast Update
0002139ArchFeaturepublic2017-02-25 04:08
Reporteryorik Assigned Toyorik  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
PlatformPCOSDebianOS VersionTesting 64bit
Summary0002139: Export materials to obj
Descriptionhttp://forum.freecadweb.org/viewtopic.php?f=8&t=10935
TagsNo tags attached.
FreeCAD Information

Relationships

has duplicate 0001300 closedyorik File formats Importing OBJ does not load Material 

Activities

yorik

2015-12-03 12:47

administrator   ~0006577

Hi,
Very cool work! Thanks for attacking that matter!
So far it seems the right direction. One thing I would change, though:

Instead of adding importMTL to the export types in InitGui.py, which forces the user to export twice, I would manage everything from inside importOBJ. We can add a preference setting, if needed so the user can choose wether he wants to import/export mtl files, but for me it's not necessary. We can always import/export the mtl file (that's what other apps do).

So I would leave the mtl stuff inside importMTL.py, that's a good idea to separate, simply I would remove the line you added in InitGui.py. Instead, inside importOBJ, I would add something like this:

import importMTL
materials = importMTL.makeMAterialsList(exportlist)
importMTL.export(materials,filename)

After that we need to import MTL files too, if you have more courage ;)

yorik

2015-12-14 21:17

administrator   ~0006610

Excellent, well done!

We don't need to worry too much about speed I think, because the user can use the standard OBJ importer from Mesh if needed.

Now the delicate question is this: So far only Arch and FEM objects have support for materials. So what are we going to do with the materials from the obj file...

Maybe creating "blank" Arch components with ArchCommands.makeComponent.. These can have materials. But then we need to convert the mesh data into Part Shapes, which can become heavy...

yorik

2016-01-03 18:59

administrator   ~0006661

great progress!

I think creating meshes is the way to go, because 1) OBJ files will only contain meshes anyway, 2) converting meshes to shapes can be a very heavy operation and 3) there migth be no need, better to leave the user to decide.

So I would do this first
1) only create meshes frpm the geometry
2) create one material object from each material in the MTL file. See how it works in Arch/ArchMaterial.py, but this is independent from Arch
3) After that is done, we can look at how to relate the meshes and the materials...

yorik

2016-01-15 19:41

administrator   ~0006717

Hi damian,

great work! this is almost done!

Be careful with the Part tessellate stuff at lines 295->300 because it can modify slightly the vertices positions (there is sometimes a kind of "rounding" happening with OCC) but I don't know a pure Mesh way to triangulate a face with more than 3 verts... wmayer might have an idea

For your function at line 310, it is fine, you must just add this line:
    mat.Material = propDict

You must just take care that your propDict contains ONLY string:string pairs (no ints or floats)

yorik

2016-01-15 19:41

administrator   ~0006718

Reminder sent to: wmayer

yorik

2016-01-15 19:42

administrator   ~0006719

Werner, any idea about the last post above? Thanks!

damian

2016-01-19 14:41

reporter   ~0006734

Last edited: 2016-02-03 07:13

hi

https://github.com/caceres/FreeCAD/blob/aa2b74188f5e5d0edeed590aebe16bc7245a5944/src/Mod/Arch/importOBJ.py

https://github.com/caceres/FreeCAD/blob/aa2b74188f5e5d0edeed590aebe16bc7245a5944/src/Mod/Arch/importMTL.py

by

yorik

2017-02-25 04:08

administrator   ~0008428

Fix committed to master branch.

Related Changesets

FreeCAD: master aab99ad9

2017-02-25 04:07:48

yorik

Details Diff
Arch: Added materials support to Arch OBJ import/exporter - fixes 0002139 Affected Issues
0002139
mod - src/Mod/Arch/Init.py Diff File
mod - src/Mod/Arch/importDAE.py Diff File
mod - src/Mod/Arch/importOBJ.py Diff File

Issue History

Date Modified Username Field Change
2015-06-01 15:06 yorik New Issue
2015-06-01 15:06 yorik Status new => assigned
2015-06-01 15:06 yorik Assigned To => yorik
2015-12-03 12:47 yorik Note Added: 0006577
2015-12-14 21:17 yorik Note Added: 0006610
2016-01-03 18:59 yorik Note Added: 0006661
2016-01-15 19:41 yorik Note Added: 0006717
2016-01-15 19:41 yorik Note Added: 0006718
2016-01-15 19:42 yorik Note Added: 0006719
2016-01-19 14:41 damian Note Added: 0006734
2016-01-22 09:31 damian Note Edited: 0006734
2016-01-31 18:41 yorik Relationship added has duplicate 0001300
2016-01-31 19:54 damian Note Edited: 0006734
2016-02-03 07:13 damian Note Edited: 0006734
2016-03-22 14:44 yorik Project FreeCAD => Arch
2016-03-22 14:45 yorik Summary Arch - export materilas to obj => Export materilas to obj
2017-01-24 02:33 Kunda1 Summary Export materilas to obj => Export materials to obj
2017-02-25 04:08 yorik Changeset attached => FreeCAD master aab99ad9
2017-02-25 04:08 yorik Note Added: 0008428
2017-02-25 04:08 yorik Status assigned => closed
2017-02-25 04:08 yorik Resolution open => fixed