Wavefront OBJ exporter

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
vocx
Posts: 1430
Joined: Thu Oct 18, 2018 9:18 pm

Re: Wavefront OBJ exporter

Postby vocx » Wed Oct 09, 2019 11:10 pm

sgrogan wrote:
Wed Oct 09, 2019 10:01 pm
...
Pasteing the same in code tags fixes it?
Oh, this is very bad. Indeed spaces and tabs shouldn't be mixed. It's not fixed, the tabs are still there, although both the forum and GitHub display them as 8 spaces by default. If you can submit a pull request for that, that would be good. Four spaces indentation should be the norm. That's what is used in the big Python workbenches like Draft, Arch, and FEM.
vejmarie wrote:
Mon Oct 07, 2019 6:42 pm
Just posted my code through PR #2593. It is improving current implementation into Arch
Ping.
User avatar
yorik
Site Admin
Posts: 11514
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Wavefront OBJ exporter

Postby yorik » Thu Oct 10, 2019 1:55 pm

wmayer
Site Admin
Posts: 14788
Joined: Thu Feb 19, 2009 10:32 am

Re: Wavefront OBJ exporter

Postby wmayer » Thu Oct 10, 2019 6:03 pm

Oh, this is very bad. Indeed spaces and tabs shouldn't be mixed. It's not fixed, the tabs are still there, although both the forum and GitHub display them as 8 spaces by default
When looking at the code of the PR you can see that the indentation is inconsistent and when selecting the highlighted code you can see that these are tabs.

Anyway, it's good that Py3 raises an error now compared to Py2 where this was allowed. There the behaviour could be quite unexpected when in the editor tab size is set to 4 characters instead of 8.
vocx
Posts: 1430
Joined: Thu Oct 18, 2018 9:18 pm

Re: Wavefront OBJ exporter

Postby vocx » Thu Oct 10, 2019 8:25 pm

yorik wrote:
Thu Oct 10, 2019 1:55 pm
Fixed in git commit 04f87588b0
I think the fix isn't entirely correct.

It should be

Code: Select all

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)
and

Code: Select all

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)
User avatar
sgrogan
Posts: 5332
Joined: Wed Oct 22, 2014 5:02 pm

Re: Wavefront OBJ exporter

Postby sgrogan » Thu Oct 10, 2019 9:25 pm