Skip to content

Commit

Permalink
Arch: Fixed in IFC import
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Apr 16, 2014
1 parent 61919e8 commit 9766385
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -602,8 +602,8 @@ def addFixture(fixture,baseobject):
else:
FreeCAD.Console.PrintMessage(translate("Arch","This object has no support for fixtures"))

def getTuples(data,scale=1,placement=None):
"""getTuples(data,[scale,placement]): returns a tuple or a list of tuples from a vector
def getTuples(data,scale=1,placement=None,normal=None):
"""getTuples(data,[scale,placement,normal]): returns a tuple or a list of tuples from a vector
or from the vertices of a shape. Scale can indicate a scale factor"""
import Part
if isinstance(data,FreeCAD.Vector):
Expand All @@ -616,7 +616,12 @@ def getTuples(data,scale=1,placement=None):
import Part,DraftGeomUtils
data = Part.Wire(DraftGeomUtils.sortEdges(data.Wires[0].Edges))
verts = data.Vertexes
#verts.reverse()
try:
if DraftVecUtils.angle(verts[1].Point,verts[0].Point,normal) >= 0:
# inverting verts order if the direction is couterclockwise
verts.reverse()
except:
pass
for v in verts:
pt = v.Point
if placement:
Expand Down Expand Up @@ -662,7 +667,8 @@ def getBrepFacesData(obj,scale=1):
for face in obj.Shape.Faces:
f = []
for wire in face.Wires:
f.append(getTuples(wire,scale))
t = getTuples(wire,scale,normal=face.normalAt(0,0))
f.append(t)
s.append(f)
sols.append(s)
return sols
Expand Down
19 changes: 14 additions & 5 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -927,24 +927,33 @@ def export(exportList,filename):

# process objects
for obj in objectslist:
if DEBUG: print "adding ",obj.Label
otype = Draft.getType(obj)
name = str(obj.Label)
parent = Arch.getHost(obj)
gdata = None

if otype in ["Group"]:
# unsupported objects. TODO: support
continue

if DEBUG: print "adding ",obj.Label

if not forcebrep:
gdata = Arch.getExtrusionData(obj,scaling)
if DEBUG: print "extrusion data for ",obj.Label," : ",gdata
#if DEBUG: print "extrusion data for ",obj.Label," : ",gdata
if not gdata:
fdata = Arch.getBrepFacesData(obj,scaling)
if DEBUG: print "brep data for ",obj.Label," : ",fdata
#if DEBUG: print "brep data for ",obj.Label," : ",fdata
if DEBUG: print " Brep"
if not fdata:
if obj.isDerivedFrom("Part::Feature"):
print "IFC export: error retrieving the shape of object ", obj.Name
continue
else:
if DEBUG: print " Extrusion"

spacer = ""
for i in range(30-len(obj.Name)):
for i in range(36-len(obj.Label)):
spacer += " "
if otype in ["Structure","Window"]:
if hasattr(obj,"Role"):
Expand All @@ -953,7 +962,7 @@ def export(exportList,filename):
tp = otype
else:
tp = otype
txt.append(obj.Name + spacer + tp)
txt.append(obj.Label + spacer + tp)

if otype == "Building":
ifc.addBuilding( name=name )
Expand Down

0 comments on commit 9766385

Please sign in to comment.