diff --git a/src/Mod/Arch/CMakeLists.txt b/src/Mod/Arch/CMakeLists.txt
index d249a8a5b..63ea6d6c6 100644
--- a/src/Mod/Arch/CMakeLists.txt
+++ b/src/Mod/Arch/CMakeLists.txt
@@ -17,6 +17,7 @@ SET(Arch_SRCS
Commands.py
SectionPlane.py
importDAE.py
+ importOBJ.py
Window.py
)
SOURCE_GROUP("" FILES ${Arch_SRCS})
diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py
index 0465c6612..2cb2f9fcf 100755
--- a/src/Mod/Arch/InitGui.py
+++ b/src/Mod/Arch/InitGui.py
@@ -56,6 +56,7 @@ class ArchWorkbench(Workbench):
FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addPreferencePage(":/ui/archprefs-base.ui","Arch")
FreeCAD.addImportType("Industry Foundation Classes (*.ifc)","importIFC")
+ FreeCAD.addExportType("Wavefront OBJ - Arch module (*.obj)","importOBJ")
try:
import collada
except:
diff --git a/src/Mod/Arch/Makefile.am b/src/Mod/Arch/Makefile.am
index 9a2bb9ea4..b5257ba12 100644
--- a/src/Mod/Arch/Makefile.am
+++ b/src/Mod/Arch/Makefile.am
@@ -18,6 +18,7 @@ data_DATA = \
ifcReader.py \
importDAE.py \
importIFC.py \
+ importOBJ.py \
Init.py \
InitGui.py \
Site.py \
diff --git a/src/Mod/Arch/importOBJ.py b/src/Mod/Arch/importOBJ.py
new file mode 100644
index 000000000..5389cdd5b
--- /dev/null
+++ b/src/Mod/Arch/importOBJ.py
@@ -0,0 +1,50 @@
+import FreeCAD
+from draftlibs import fcgeo
+
+pythonopen = open
+
+def findVert(aVertex,aList):
+ "finds aVertex in aList, returns index"
+ for i in range(len(aList)):
+ if (aVertex.X == aList[i].X) and (aVertex.Y == aList[i].Y) and (aVertex.Z == aList[i].Z):
+ return i
+
+def getIndices(shape,offset):
+ "returns a list with 2 lists: vertices and face indexes, offsetted with the given amount"
+ vlist = []
+ flist = []
+ for v in shape.Vertexes:
+ vlist.append(" "+str(round(v.X,4))+" "+str(round(v.Z,4))+" "+str(round(v.Y,4)))
+ for f in shape.Faces:
+ fi = ""
+ # OCC vertices are unsorted. We need to sort in the right order...
+ edges = fcgeo.sortEdges(f.Wire.Edges)
+ print edges
+ for e in edges:
+ print e.Vertexes[0].Point,e.Vertexes[1].Point
+ v = e.Vertexes[0]
+ fi+=" "+str(findVert(v,shape.Vertexes)+offset)
+ flist.append(fi)
+ return vlist,flist
+
+def export(exportList,filename):
+ "called when freecad exports a file"
+ outfile = pythonopen(filename,"wb")
+ ver = FreeCAD.Version()
+ outfile.write("# FreeCAD v" + ver[0] + "." + ver[1] + " build" + ver[2] + " Arch module\n")
+ outfile.write("# http://free-cad.sf.net\n")
+ offset = 1
+ for obj in exportList:
+ if obj.isDerivedFrom("Part::Feature"):
+ vlist,flist = getIndices(obj.Shape,offset)
+ offset += len(vlist)
+ outfile.write("o " + obj.Name + "\n")
+ for v in vlist:
+ outfile.write("v" + v + "\n")
+ for f in flist:
+ outfile.write("f" + f + "\n")
+ outfile.close()
+ FreeCAD.Console.PrintMessage("successfully written "+filename)
+
+
+
diff --git a/src/Mod/Draft/draftlibs/fcgeo.py b/src/Mod/Draft/draftlibs/fcgeo.py
index 186371e92..c7770f22c 100755
--- a/src/Mod/Draft/draftlibs/fcgeo.py
+++ b/src/Mod/Draft/draftlibs/fcgeo.py
@@ -407,7 +407,25 @@ def sortEdges(lEdges, aVertex=None):
linstances += [i,j-1,instance]
return [count]+linstances
- if (len(lEdges) < 2): return lEdges
+ if (len(lEdges) < 2):
+ if aVertex == None:
+ return lEdges
+ else:
+ result = lookfor(aVertex,lEdges)
+ if result[0] != 0:
+ if isSameVertex(aVertex,result[3].Vertexes[0]):
+ print "1keeping"
+ return lEdges
+ else:
+ print "1flipping"
+ if isinstance(result[3].Curve,Part.Line):
+ return [Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()]
+ elif isinstance(result[3].Curve,Part.Circle):
+ mp = findMidpoint(result[3])
+ return [Part.Arc(aVertex.Point,mp,result[3].Vertexes[0].Point).toShape()]
+ else:
+ return lEdges
+
olEdges = [] # ol stands for ordered list
if aVertex == None:
for i in range(len(lEdges)*2) :
@@ -424,8 +442,10 @@ def sortEdges(lEdges, aVertex=None):
del lEdges[result[1]]
next = sortEdges(lEdges, result[3].Vertexes[-((-result[2])^1)])
if isSameVertex(aVertex,result[3].Vertexes[0]):
+ print "keeping"
olEdges += [result[3]] + next
else:
+ print "flipping"
if isinstance(result[3].Curve,Part.Line):
newedge = Part.Line(aVertex.Point,result[3].Vertexes[0].Point).toShape()
olEdges += [newedge] + next
diff --git a/src/WindowsInstaller/ModArch.wxi b/src/WindowsInstaller/ModArch.wxi
index d48a55d5a..bd1944649 100644
--- a/src/WindowsInstaller/ModArch.wxi
+++ b/src/WindowsInstaller/ModArch.wxi
@@ -36,6 +36,7 @@
+