Skip to content

Commit

Permalink
added simple Dictionary for Import of IfcProperies to all ArchComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo tuxobald committed Mar 7, 2014
1 parent 040c19b commit 2b4b5af
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Mod/Arch/ArchComponent.py
Expand Up @@ -25,6 +25,9 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

# empty dictionary for imported ifc attributes
IfcImportedAttributesDictionary = {}

import FreeCAD,Draft
from FreeCAD import Vector
if FreeCAD.GuiUp:
Expand Down Expand Up @@ -285,6 +288,8 @@ def __init__(self,obj):
obj.addProperty("App::PropertyLink","Base","Arch","The base object this component is built upon")
obj.addProperty("App::PropertyLinkList","Additions","Arch","Other shapes that are appended to this object")
obj.addProperty("App::PropertyLinkList","Subtractions","Arch","Other shapes that are subtracted from this object")
obj.addProperty("App::PropertyMap","IfcImportedAttributes","IfcAttributes",
translate("IfcAttributes","Dictionary containing Imported IfcAttributes"))
obj.Proxy = self
self.Type = "Component"
self.Subvolume = None
Expand Down
30 changes: 25 additions & 5 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -183,7 +183,11 @@ def read(filename):

# retrieving name
n = getCleanName(objname,objid,objtype)


# retrieving ifcproperties
#p = getIfcProperties(obj)
p = getIfcProperties(objname,objid,objtype)

# skip types
if objtype in SKIP:
if DEBUG: print "skipping because type is in skip list"
Expand All @@ -201,15 +205,15 @@ def read(filename):

# walls
if objtype in ["IfcWallStandardCase","IfcWall"]:
nobj = makeWall(objid,shape,n)
nobj = makeWall(objid,p,shape,n)

# windows
elif objtype in ["IfcWindow","IfcDoor"]:
nobj = makeWindow(objid,shape,n)

# structs
elif objtype in ["IfcBeam","IfcColumn","IfcSlab","IfcFooting"]:
nobj = makeStructure(objid,shape,objtype,n)
nobj = makeStructure(objid,p,shape,objtype,n)

# roofs
elif objtype in ["IfcRoof"]:
Expand Down Expand Up @@ -394,6 +398,20 @@ def read(filename):
return None


"""def getIfcProperties(ifcobj):
"Get some properties from an ifc object"
p = {"IfcID":str(ifcobj.id), "IfcType":ifcobj.type, "IFCName":ifcobj.name}
#p = {"IfcID":str(ifcobj.id), "IfcType":ifcobj.type, "IFCName":ifcobj.name, "IfcGUID":str(ifcobj.guid)}
#p = {"IfcID":str(ifcobj.id), "IfcType":ifcobj.type, "IFCName":ifcobj.name, "IfcMatrix":str(ifcobj.matrix)}
#App.ActiveDocument.ID769_IfcSlab.IfcImportedAttributes
return p
"""
def getIfcProperties(name,ifcid,ifctype):
"Get some properties from an ifc object"
p = {"IfcID":str(ifcid), "IfcType":ifctype, "IFCName":name}
return p


def getCleanName(name,ifcid,ifctype):
"Get a clean name from an ifc object"
#print "getCleanName called",name,ifcid,ifctype
Expand All @@ -407,7 +425,7 @@ def getCleanName(name,ifcid,ifctype):
return n


def makeWall(entity,shape=None,name="Wall"):
def makeWall(entity,ifcprops,shape=None,name="Wall"):
"makes a wall in the freecad document"
try:
if shape:
Expand All @@ -420,6 +438,7 @@ def makeWall(entity,shape=None,name="Wall"):
body.Mesh = shape
wall = Arch.makeWall(body,name=name)
wall.Label = name
wall.IfcImportedAttributes = ifcprops
if IOC_ADVANCED and ADDPLACEMENT:
wall.Placement = getPlacement(getAttr(entity,"ObjectPlacement"))
if DEBUG: print "made wall object ",entity,":",wall
Expand Down Expand Up @@ -496,7 +515,7 @@ def makeWindow(entity,shape=None,name="Window"):
return None


def makeStructure(entity,shape=None,ifctype=None,name="Structure"):
def makeStructure(entity,ifcprops,shape=None,ifctype=None,name="Structure"):
"makes a structure in the freecad document"
try:
if shape:
Expand All @@ -509,6 +528,7 @@ def makeStructure(entity,shape=None,ifctype=None,name="Structure"):
body.Mesh = shape
structure = Arch.makeStructure(body,name=name)
structure.Label = name
structure.IfcImportedAttributes = ifcprops
if ifctype == "IfcBeam":
structure.Role = "Beam"
elif ifctype == "IfcColumn":
Expand Down

0 comments on commit 2b4b5af

Please sign in to comment.