예제 #1
0
 def addProduct(self,elttype,shapes,storey=None,placement=None,name="Unnamed element",description=None,extra=None):
     """addProduct(elttype,representations,[storey,placement,name,description,extra]): creates an element of the given type
     (IfcWall, IfcBeam, etc...) with the given attributes, plus the given extra attributes."""
     if not extra:
         extra = []
     if not description:
         description = None
     if not placement:
         placement = self.addPlacement()
     representations = self.addRepresentations(shapes)
     prd = create(self._fileobject,"IfcProductDefinitionShape",[None,None,representations])
     try:
         elt = create(self._fileobject,elttype,[uid(),self._owner,name,description,None,placement,prd,None]+extra)
     except:
         print "unable to create an ",elttype, " with attributes: ",[uid(),self._owner,name,description,None,placement,prd,None]+extra
         try:
             o = IfcImport.Entity(elttype)
             print "supported attributes are: "
             print getPropertyNames(o)
         except:
             print "unable to create an element of type '"+elttype+"'"
         print "WARNING: skipping object '"+name+"' of type "+elttype
         return None
     self.BuildingProducts.append(elt)
     if not storey:
         if self.Storeys:
             storey = self.Storeys[0]
         else:
             storey = self.addStorey()
     self._relate(storey,elt)
     return elt
예제 #2
0
def create(ifcdoc=None,ifcname=None,arguments=[]):
    """create(ifcdoc,ifcname,[arguments]):creates an entity 
    of the given name in the given document and optionally 
    gives it an ordered list of arguments"""
    entity = IfcImport.Entity(ifcname)
    if ifcdoc:
        ifcdoc.add(entity)
    # this is a temporary hack while ifcopenshell has no ref counting
    holder.refs.append(entity)
    if not isinstance(arguments,list):
        arguments = [arguments]
    for i in range(len(arguments)):
        arg = arguments[i]
        if isinstance(arg,tuple):
            if len(arg) in [2,3]:
                arg = IfcImport.Doubles(arg)
        entity.set_argument(i,arg)
    return entity