Wavefront OBJ exporter
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- vejmarie
- Posts: 713
- Joined: Mon Jan 04, 2016 4:52 pm
- Location: Somewhere between France, USA and Taiwan
- Contact:
Re: Wavefront OBJ exporter
Looks like that getGlobalPlacement is going to make it
Re: Wavefront OBJ exporter
I'm still working on the wavefront exporter, but at the moment development is blocked pending a decision. This is not a criticism because it's better to delay and evaluate than to accept whatever.
After that, I took parts of the exporter code I wrote (which weren't in dispute) and reused them in the renderer workbench (multimaterial specifically). When there's a resolution, I'll either integrate the fixes and enhancements for (multi-)materials I wrote for the render wb back into the wavefront exporter. Or maybe argue for a function which returns a list of (material, shape/mesh) instead of duplicating this code across exporters, render workbench, archtexture,... I don't know if the latter is even a good option.
What I'm trying to say is I'm working on both because there's duplicate code, but I'm not quite sure where to put it so it could be shared and what would be a good api.
Re: Wavefront OBJ exporter
It sounds to me that it could be in importOBJ.py in the Arch Workbench. Since this is a basic workbench, you guarantee that is available. Meanwhile, Render and ArchTexture can use it, once they are installed from the Addon Manager.Nocturnial wrote: ↑Mon Oct 07, 2019 2:58 pm ...
What I'm trying to say is I'm working on both because there's duplicate code, but I'm not quite sure where to put it so it could be shared and what would be a good api.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
- vejmarie
- Posts: 713
- Joined: Mon Jan 04, 2016 4:52 pm
- Location: Somewhere between France, USA and Taiwan
- Contact:
Re: Wavefront OBJ exporter
I am working on this part of the code, and I agree this is where we shall update, it is coming straight with FreeCADvocx wrote: ↑Mon Oct 07, 2019 3:41 pmIt sounds to me that it could be in importOBJ.py in the Arch Workbench. Since this is a basic workbench, you guarantee that is available. Meanwhile, Render and ArchTexture can use it, once they are installed from the Addon Manager.Nocturnial wrote: ↑Mon Oct 07, 2019 2:58 pm ...
What I'm trying to say is I'm working on both because there's duplicate code, but I'm not quite sure where to put it so it could be shared and what would be a good api.
Re: Wavefront OBJ exporter
Sorry to ruin things..vejmarie wrote: ↑Mon Oct 07, 2019 4:52 pmI am working on this part of the code, and I agree this is where we shall update, it is coming straight with FreeCADvocx wrote: ↑Mon Oct 07, 2019 3:41 pm It sounds to me that it could be in importOBJ.py in the Arch Workbench. Since this is a basic workbench, you guarantee that is available. Meanwhile, Render and ArchTexture can use it, once they are installed from the Addon Manager.
The reason I know where to get the normals is because I read the c++ code to export wavefront objects. That's one of the things I'm talking about when I say there's code duplication. The c++ code exports one mesh at a time. While we want to export an entire scene.
The c++ code can also export ply files which I need for the render wb. But it exports them by naming a field "face_index" instead of "face_indices" or something similar. So I've (re)written a short ply exporter in python.
The question is whether we completely drop the c++ implementation for a python implementation or add customization options to the c++ exporter?
- vejmarie
- Posts: 713
- Joined: Mon Jan 04, 2016 4:52 pm
- Location: Somewhere between France, USA and Taiwan
- Contact:
Re: Wavefront OBJ exporter
Do not worry you do not ruin anything, I am a big C++ fan. I was looking for a quick OBJ exporter for an internal need . I got my stuff working now and will push the code on top of Yorik one (everything is in Python and I can export a global scene, mesh by mesh using the Absolute coordinate (getGlobalPlacement) and it works like a charm. This is still an enhancement against Yorik implementation which do not display anything currently as it doesn't contain the normals. I have implemented that too based on the discussion we just had into that thread.
As soon as your implementation will be ready I will be switching. I still need to have all part generating a dedicated mesh, as my goal is to allow my users to comment assemblies on per part bases.
As soon as your implementation will be ready I will be switching. I still need to have all part generating a dedicated mesh, as my goal is to allow my users to comment assemblies on per part bases.
- vejmarie
- Posts: 713
- Joined: Mon Jan 04, 2016 4:52 pm
- Location: Somewhere between France, USA and Taiwan
- Contact:
Re: Wavefront OBJ exporter
Just posted my code through PR #2593. It is improving current implementation into Arch
Last edited by Kunda1 on Tue Oct 08, 2019 6:46 pm, edited 1 time in total.
Reason: created hyperlink for convenience
Reason: created hyperlink for convenience
Re: Wavefront OBJ exporter
Nice!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Wavefront OBJ exporter
Very minor issue, I get a python syntax error with self tests for ImportOBJ.py lines 76,77,82,83
It looks OK on git hub https://github.com/FreeCAD/FreeCAD/blob ... OBJ.py#L76
The referenced lines are tabs not spaces locally, is this something with my git settings, I haven't seen this before?
I can see and fix the problem locally with Notepad++ Pasteing the same in code tags fixes it?
Code: Select all
if isinstance(shape,Part.Shape):
for e in shape.Edges:
try:
if not isinstance(e.Curve,Part.LineSegment):
if not curves:
myshape = obj.Shape.copy(False)
myshape.Placement=obj.getGlobalPlacement()
mesh=MeshPart.meshFromShape(Shape=myshape, LinearDeflection=0.1, AngularDeflection=0.7, Relative=True)
FreeCAD.Console.PrintWarning(translate("Arch","Found a shape containing curves, triangulating")+"\n")
break
except: # unimplemented curve type
myshape = obj.Shape.copy(False)
myshape.Placement=obj.getGlobalPlacement()
mesh=MeshPart.meshFromShape(Shape=myshape, LinearDeflection=0.1, AngularDeflection=0.7, Relative=True)
FreeCAD.Console.PrintWarning(translate("Arch","Found a shape containing curves, triangulating")+"\n")
break
"fight the good fight"