text
stringlengths
81
112k
get the ranges for this field def getrange(bch, fieldname): """get the ranges for this field""" keys = ['maximum', 'minimum', 'maximum<', 'minimum>', 'type'] index = bch.objls.index(fieldname) fielddct_orig = bch.objidd[index] fielddct = copy.deepcopy(fielddct_orig) therange = {} for key in...
throw exception if the out of range def checkrange(bch, fieldname): """throw exception if the out of range""" fieldvalue = bch[fieldname] therange = bch.getrange(fieldname) if therange['maximum'] != None: if fieldvalue > therange['maximum']: astr = "Value %s is not less or equal to ...
get the idd dict for this field Will return {} if the fieldname does not exist def getfieldidd(bch, fieldname): """get the idd dict for this field Will return {} if the fieldname does not exist""" # print(bch) try: fieldindex = bch.objls.index(fieldname) except ValueError as e: ...
return an item from the fieldidd, given the iddkey will return and empty list if it does not have the iddkey or if the fieldname does not exist def getfieldidd_item(bch, fieldname, iddkey): """return an item from the fieldidd, given the iddkey will return and empty list if it does not have the iddkey ...
return True if the field is equal to value def isequal(bch, fieldname, value, places=7): """return True if the field is equal to value""" def equalalphanumeric(bch, fieldname, value): if bch.get_retaincase(fieldname): return bch[fieldname] == value else: return bch[field...
Get a list of objects that refer to this object def getreferingobjs(referedobj, iddgroups=None, fields=None): """Get a list of objects that refer to this object""" # pseudocode for code below # referringobjs = [] # referedobj has: -> Name # -> reference # for each obj in idf: ...
Get an object referred to by a field in another object. For example an object of type Construction has fields for each layer, each of which refers to a Material. This functions allows the object representing a Material to be fetched using the name of the layer. Returns the first item found since if th...
return True if the field == value Will retain case if get_retaincase == True for real value will compare to decimal 'places' def isequal(self, fieldname, value, places=7): """return True if the field == value Will retain case if get_retaincase == True for real value will compare...
Get a list of objects that refer to this object def getreferingobjs(self, iddgroups=None, fields=None): """Get a list of objects that refer to this object""" return getreferingobjs(self, iddgroups=iddgroups, fields=fields)
volume of a irregular tetrahedron def vol_tehrahedron(poly): """volume of a irregular tetrahedron""" p_a = np.array(poly[0]) p_b = np.array(poly[1]) p_c = np.array(poly[2]) p_d = np.array(poly[3]) return abs(np.dot( np.subtract(p_a, p_d), np.cross( np.subtract(p_b, p...
volume of a zone defined by two polygon bases def vol(poly1, poly2): """"volume of a zone defined by two polygon bases """ c_point = central_p(poly1, poly2) c_point = (c_point[0], c_point[1], c_point[2]) vol_therah = 0 num = len(poly1) poly1.append(poly1[0]) poly2.append(poly2[0]) for i...
make the name2refs dict in the idd_index def makename2refdct(commdct): """make the name2refs dict in the idd_index""" refdct = {} for comm in commdct: # commdct is a list of dict try: idfobj = comm[0]['idfobj'].upper() field1 = comm[1] if 'Name' in field1['field'...
make the ref2namesdct in the idd_index def makeref2namesdct(name2refdct): """make the ref2namesdct in the idd_index""" ref2namesdct = {} for key, values in name2refdct.items(): for value in values: ref2namesdct.setdefault(value, set()).add(key) return ref2namesdct
embed ref2names into commdct def ref2names2commdct(ref2names, commdct): """embed ref2names into commdct""" for comm in commdct: for cdct in comm: try: refs = cdct['object-list'][0] validobjects = ref2names[refs] cdct.update({'validobjects':val...
Calculation of zone area def area(poly): """Calculation of zone area""" poly_xy = [] num = len(poly) for i in range(num): poly[i] = poly[i][0:2] + (0,) poly_xy.append(poly[i]) return surface.area(poly)
get the pervious component in the loop def prevnode(edges, component): """get the pervious component in the loop""" e = edges c = component n2c = [(a, b) for a, b in e if type(a) == tuple] c2n = [(a, b) for a, b in e if type(b) == tuple] node2cs = [(a, b) for a, b in e if b == c] c2nodes = ...
height def height(poly): """height""" num = len(poly) hgt = 0.0 for i in range(num): hgt += (poly[i][2]) return hgt/num
unit normal def unit_normal(apnt, bpnt, cpnt): """unit normal""" xvar = np.tinylinalg.det([ [1, apnt[1], apnt[2]], [1, bpnt[1], bpnt[2]], [1, cpnt[1], cpnt[2]]]) yvar = np.tinylinalg.det([ [apnt[0], 1, apnt[2]], [bpnt[0], 1, bpnt[2]], [cpnt[0], 1, cpnt[2]]]) zvar = np.tinylinalg.det([ ...
Insert an idfobject (bunch) to list1 and its object to list2. def insert(self, i, v): """Insert an idfobject (bunch) to list1 and its object to list2.""" self.list1.insert(i, v) self.list2.insert(i, v.obj) if isinstance(v, EpBunch): v.theidf = self.theidf
Collect data into fixed-length chunks or blocks def grouper(num, iterable, fillvalue=None): "Collect data into fixed-length chunks or blocks" # grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx args = [iter(iterable)] * num return zip_longest(fillvalue=fillvalue, *args)
return the coordinates of the surface def getcoords(ddtt): """return the coordinates of the surface""" n_vertices_index = ddtt.objls.index('Number_of_Vertices') first_x = n_vertices_index + 1 # X of first coordinate pts = ddtt.obj[first_x:] return list(grouper(3, pts))
return building name def buildingname(ddtt): """return building name""" idf = ddtt.theidf building = idf.idfobjects['building'.upper()][0] return building.Name
massage the version number so it matches the format of install folder def cleanupversion(ver): """massage the version number so it matches the format of install folder""" lst = ver.split(".") if len(lst) == 1: lst.extend(['0', '0']) elif len(lst) == 2: lst.extend(['0']) elif len(lst...
find the IDD file of the E+ installation def getiddfile(versionid): """find the IDD file of the E+ installation""" vlist = versionid.split('.') if len(vlist) == 1: vlist = vlist + ['0', '0'] elif len(vlist) == 2: vlist = vlist + ['0'] ver_str = '-'.join(vlist) eplus_exe, _ = e...
automatically set idd and open idf file. Uses version from idf to set correct idd It will work under the following circumstances: - the IDF file should have the VERSION object. - Needs the version of EnergyPlus installed that matches the IDF version. - Energyplus should be installed in the default...
the comment is similar to that in python. any charachter after the # is treated as a comment until the end of the line astr is the string to be de-commented cphrase is the comment phrase def removecomment(astr, cphrase): """ the comment is similar to that in python. any charachter after the...
initdict2 def initdict2(self, dictfile): """initdict2""" dt = {} dtls = [] adict = dictfile for element in adict: dt[element[0].upper()] = [] # dict keys for objects always in caps dtls.append(element[0].upper()) return dt, dtls
create a blank dictionary def initdict(self, fname): """create a blank dictionary""" if isinstance(fname, Idd): self.dt, self.dtls = fname.dt, fname.dtls return self.dt, self.dtls astr = mylib2.readfile(fname) nocom = removecomment(astr, '!') idfst = noc...
stuff file data into the blank dictionary def makedict(self, dictfile, fnamefobject): """stuff file data into the blank dictionary""" #fname = './exapmlefiles/5ZoneDD.idf' #fname = './1ZoneUncontrolled.idf' if isinstance(dictfile, Idd): localidd = copy.deepcopy(dictfile) ...
replace the node here with the node from othereplus def replacenode(self, othereplus, node): """replace the node here with the node from othereplus""" node = node.upper() self.dt[node.upper()] = othereplus.dt[node.upper()]
add the node here with the node from othereplus this will potentially have duplicates def add2node(self, othereplus, node): """add the node here with the node from othereplus this will potentially have duplicates""" node = node.upper() self.dt[node.upper()] = self.dt[node.upper(...
add an item to the node. example: add a new zone to the element 'ZONE' def addinnode(self, otherplus, node, objectname): """add an item to the node. example: add a new zone to the element 'ZONE' """ # do a test for unique object here newelement = otherplus.dt[node.upper()]
reflist is got from getobjectref in parse_idd.py getobjectref returns a dictionary. reflist is an item in the dictionary getrefs gathers all the fields refered by reflist def getrefs(self, reflist): """ reflist is got from getobjectref in parse_idd.py getobjectref return...
draw a graph without the nodes def dropnodes(edges): """draw a graph without the nodes""" newedges = [] added = False for edge in edges: if bothnodes(edge): newtup = (edge[0][0], edge[1][0]) newedges.append(newtup) added = True elif firstisnode(edge):...
gather the nodes from the edges def edges2nodes(edges): """gather the nodes from the edges""" nodes = [] for e1, e2 in edges: nodes.append(e1) nodes.append(e2) nodedict = dict([(n, None) for n in nodes]) justnodes = list(nodedict.keys()) # justnodes.sort() justnodes = sorted...
make the diagram with the edges def makediagram(edges): """make the diagram with the edges""" graph = pydot.Dot(graph_type='digraph') nodes = edges2nodes(edges) epnodes = [(node, makeanode(node[0])) for node in nodes if nodetype(node)=="epnode"] endnodes = [(node, makeendnode(node...
return the edges jointing the components of a branch def makebranchcomponents(data, commdct, anode="epnode"): """return the edges jointing the components of a branch""" alledges = [] objkey = 'BRANCH' cnamefield = "Component %s Name" inletfield = "Component %s Inlet Node Name" outletfield = "C...
make the edges for the airloop and the plantloop def makeairplantloop(data, commdct): """make the edges for the airloop and the plantloop""" anode = "epnode" endnode = "EndNode" # in plantloop get: # demand inlet, outlet, branchlist # supply inlet, outlet, branchlist plantloops = l...
return the edges of the idf file fname def getedges(fname, iddfile): """return the edges of the idf file fname""" data, commdct, _idd_index = readidf.readdatacommdct(fname, iddfile=iddfile) edges = makeairplantloop(data, commdct) return edges
input 'astr' which is the Energy+.idd file as a string returns (st1, st2, lss) st1 = with all the ! comments striped st2 = strips all comments - both the '!' and '\\' lss = nested list of all the variables in Energy+.idd file def get_nocom_vars(astr): """ input 'astr' which is the Energy+.idd f...
remove the blank lines in astr def removeblanklines(astr): """remove the blank lines in astr""" lines = astr.splitlines() lines = [line for line in lines if line.strip() != ""] return "\n".join(lines)
copied from extractidddata below. It deals with all the types of fnames def _readfname(fname): """copied from extractidddata below. It deals with all the types of fnames""" try: if isinstance(fname, (file, StringIO)): astr = fname.read() else: astr = open(fname...
generate the iddindex def make_idd_index(extract_func, fname, debug): """generate the iddindex""" astr = _readfname(fname) # fname is exhausted by the above read # reconstitute fname as a StringIO fname = StringIO(astr) # glist = iddgroups.iddtxt2grouplist(astr.decode('ISO-8859-2')) ...
insert group info into extracted idd def embedgroupdata(extract_func, fname, debug): """insert group info into extracted idd""" astr = _readfname(fname) # fname is exhausted by the above read # reconstitute fname as a StringIO fname = StringIO(astr) try: astr = astr.decode('I...
extracts all the needed information out of the idd file if debug is True, it generates a series of text files. Each text file is incrementally different. You can do a diff see what the change is - this code is from 2004. it works. I am trying not to change it (until I rewrite the whole thin...
makes a dictionary of object-lists each item in the dictionary points to a list of tuples the tuple is (objectname, fieldindex) def getobjectref(blocklst, commdct): """ makes a dictionary of object-lists each item in the dictionary points to a list of tuples the tuple is (objectname, fieldind...
read the idf file def readdatacommlst(idfname): """read the idf file""" # iddfile = sys.path[0] + '/EplusCode/Energy+.idd' iddfile = 'Energy+.idd' # iddfile = './EPlusInterfaceFunctions/E1.idd' # TODO : can the path name be not hard coded iddtxt = open(iddfile, 'r').read() block, commlst, commd...
read the idf file def readdatacommdct(idfname, iddfile='Energy+.idd', commdct=None): """read the idf file""" if not commdct: block, commlst, commdct, idd_index = parse_idd.extractidddata(iddfile) theidd = eplusdata.Idd(block, 2) else: theidd = iddfile data = eplusdata.Eplusdata(...
get all the objects of objkey. fieldlists will have a fieldlist for each of those objects. return the contents of those fields def extractfields(data, commdct, objkey, fieldlists): """get all the objects of objkey. fieldlists will have a fieldlist for each of those objects. return the contents of t...
return the plantloopfield list def plantloopfieldlists(data): """return the plantloopfield list""" objkey = 'plantloop'.upper() numobjects = len(data.dt[objkey]) return [[ 'Name', 'Plant Side Inlet Node Name', 'Plant Side Outlet Node Name', 'Plant Side Branch List Name',...
get plantloop fields to diagram it def plantloopfields(data, commdct): """get plantloop fields to diagram it""" fieldlists = plantloopfieldlists(data) objkey = 'plantloop'.upper() return extractfields(data, commdct, objkey, fieldlists)
get branches from the branchlist def branchlist2branches(data, commdct, branchlist): """get branches from the branchlist""" objkey = 'BranchList'.upper() theobjects = data.dt[objkey] fieldlists = [] objnames = [obj[1] for obj in theobjects] for theobject in theobjects: fieldlists.append...
return the inlet and outlet of a branch def branch_inlet_outlet(data, commdct, branchname): """return the inlet and outlet of a branch""" objkey = 'Branch'.upper() theobjects = data.dt[objkey] theobject = [obj for obj in theobjects if obj[1] == branchname] theobject = theobject[0] inletindex = ...
docstring for splittermixerfieldlists def splittermixerfieldlists(data, commdct, objkey): """docstring for splittermixerfieldlists""" objkey = objkey.upper() objindex = data.dtls.index(objkey) objcomms = commdct[objindex] theobjects = data.dt[objkey] fieldlists = [] for theobject in theobje...
get splitter fields to diagram it def splitterfields(data, commdct): """get splitter fields to diagram it""" objkey = "Connector:Splitter".upper() fieldlists = splittermixerfieldlists(data, commdct, objkey) return extractfields(data, commdct, objkey, fieldlists)
get mixer fields to diagram it def mixerfields(data, commdct): """get mixer fields to diagram it""" objkey = "Connector:Mixer".upper() fieldlists = splittermixerfieldlists(data, commdct, objkey) return extractfields(data, commdct, objkey, fieldlists)
return a list of repeating fields fld is in format 'Component %s Name' so flds = [fld % (i, ) for i in range(n)] does not work for 'fields as indicated' def repeatingfields(theidd, commdct, objkey, flds): """return a list of repeating fields fld is in format 'Component %s Name' so flds = [fld %...
return the count of objects of key def objectcount(data, key): """return the count of objects of key""" objkey = key.upper() return len(data.dt[objkey])
given objkey and fieldname, return its index def getfieldindex(data, commdct, objkey, fname): """given objkey and fieldname, return its index""" objindex = data.dtls.index(objkey) objcomm = commdct[objindex] for i_index, item in enumerate(objcomm): try: if item['field'] == [fname]: ...
docstring for fname def getadistus(data, commdct): """docstring for fname""" objkey = "ZoneHVAC:AirDistributionUnit".upper() objindex = data.dtls.index(objkey) objcomm = commdct[objindex] adistutypefield = "Air Terminal Object Type" ifield = getfieldindex(data, commdct, objkey, adistutypefield)...
make the dict adistu_inlets def makeadistu_inlets(data, commdct): """make the dict adistu_inlets""" adistus = getadistus(data, commdct) # assume that the inlet node has the words "Air Inlet Node Name" airinletnode = "Air Inlet Node Name" adistu_inlets = {} for adistu in adistus: objkey ...
get the version number from the E+ install folder def folder2ver(folder): """get the version number from the E+ install folder""" ver = folder.split('EnergyPlus')[-1] ver = ver[1:] splitapp = ver.split('-') ver = '.'.join(splitapp) return ver
just like the comment in python. removes any text after the phrase 'com' def nocomment(astr, com='!'): """ just like the comment in python. removes any text after the phrase 'com' """ alist = astr.splitlines() for i in range(len(alist)): element = alist[i] pnt = element.find...
convert the idf text to a simple text def idf2txt(txt): """convert the idf text to a simple text""" astr = nocomment(txt) objs = astr.split(';') objs = [obj.split(',') for obj in objs] objs = [[line.strip() for line in obj] for obj in objs] objs = [[_tofloat(line) for line in obj] for obj in ob...
given the idd file or filehandle, return the version handle def iddversiontuple(afile): """given the idd file or filehandle, return the version handle""" def versiontuple(vers): """version tuple""" return tuple([int(num) for num in vers.split(".")]) try: fhandle = open(afile, 'rb') ...
make a bunch from the object def makeabunch(commdct, obj, obj_i): """make a bunch from the object""" objidd = commdct[obj_i] objfields = [comm.get('field') for comm in commdct[obj_i]] objfields[0] = ['key'] objfields = [field[0] for field in objfields] obj_fields = [bunchhelpers.makefieldname(f...
make bunches with data def makebunches(data, commdct): """make bunches with data""" bunchdt = {} ddtt, dtls = data.dt, data.dtls for obj_i, key in enumerate(dtls): key = key.upper() bunchdt[key] = [] objs = ddtt[key] for obj in objs: bobj = makeabunch(commdct...
make bunches with data def makebunches_alter(data, commdct, theidf): """make bunches with data""" bunchdt = {} dt, dtls = data.dt, data.dtls for obj_i, key in enumerate(dtls): key = key.upper() objs = dt[key] list1 = [] for obj in objs: bobj = makeabunch(comm...
convert the float and interger fields def convertfields_old(key_comm, obj, inblock=None): """convert the float and interger fields""" convinidd = ConvInIDD() typefunc = dict(integer=convinidd.integer, real=convinidd.real) types = [] for comm in key_comm: types.append(comm.get('type', [None]...
convert field based on field info in IDD def convertafield(field_comm, field_val, field_iddname): """convert field based on field info in IDD""" convinidd = ConvInIDD() field_typ = field_comm.get('type', [None])[0] conv = convinidd.conv_dict().get(field_typ, convinidd.no_type) return conv(field...
convert based on float, integer, and A1, N1 def convertfields(key_comm, obj, inblock=None): """convert based on float, integer, and A1, N1""" # f_ stands for field_ convinidd = ConvInIDD() if not inblock: inblock = ['does not start with N'] * len(obj) for i, (f_comm, f_val, f_iddname) in en...
docstring for convertallfields def convertallfields(data, commdct, block=None): """docstring for convertallfields""" # import pdbdb; pdb.set_trace() for key in list(data.dt.keys()): objs = data.dt[key] for i, obj in enumerate(objs): key_i = data.dtls.index(key) key_c...
add functions to the objects def addfunctions(dtls, bunchdt): """add functions to the objects""" snames = [ "BuildingSurface:Detailed", "Wall:Detailed", "RoofCeiling:Detailed", "Floor:Detailed", "FenestrationSurface:Detailed", "Shading:Site:Detailed", "Sh...
add functions to a new bunch/munch object def addfunctions2new(abunch, key): """add functions to a new bunch/munch object""" snames = [ "BuildingSurface:Detailed", "Wall:Detailed", "RoofCeiling:Detailed", "Floor:Detailed", "FenestrationSurface:Detailed", "Shading...
read idf file and return bunches def idfreader(fname, iddfile, conv=True): """read idf file and return bunches""" data, commdct, idd_index = readidf.readdatacommdct(fname, iddfile=iddfile) if conv: convertallfields(data, commdct) # fill gaps in idd ddtt, dtls = data.dt, data.dtls # skip...
read idf file and return bunches def idfreader1(fname, iddfile, theidf, conv=True, commdct=None, block=None): """read idf file and return bunches""" versiontuple = iddversiontuple(iddfile) # import pdb; pdb.set_trace() block, data, commdct, idd_index = readidf.readdatacommdct1( fname, i...
dictionary of conversion def conv_dict(self): """dictionary of conversion""" return dict(integer=self.integer, real=self.real, no_type=self.no_type)
Find out if idjobject is mentioned an any object anywhere def getanymentions(idf, anidfobject): """Find out if idjobject is mentioned an any object anywhere""" name = anidfobject.obj[1] foundobjs = [] keys = idfobjectkeys(idf) idfkeyobjects = [idf.idfobjects[key.upper()] for key in keys] for id...
field=object_name, prev_field=object_type. Return the object def getobject_use_prevfield(idf, idfobject, fieldname): """field=object_name, prev_field=object_type. Return the object""" if not fieldname.endswith("Name"): return None # test if prevfieldname ends with "Object_Type" fdnames = idfobj...
return a list of keys of idfobjects that hve 'None Name' fields def getidfkeyswithnodes(): """return a list of keys of idfobjects that hve 'None Name' fields""" idf = IDF(StringIO("")) keys = idfobjectkeys(idf) keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames) for key i...
return all objects that mention this node name def getobjectswithnode(idf, nodekeys, nodename): """return all objects that mention this node name""" keys = nodekeys # TODO getidfkeyswithnodes needs to be done only once. take out of here listofidfobjects = (idf.idfobjects[key.upper()] f...
return the object, if the Name or some other field is known. send filed in **kwargs as Name='a name', Roughness='smooth' Returns the first find (field search is unordered) objkeys -> if objkeys=['ZONE', 'Material'], search only those groupnames -> not yet coded def name2idfobject(idf, groupnamess=None,...
return a list of all idfobjects in idf def getidfobjectlist(idf): """return a list of all idfobjects in idf""" idfobjects = idf.idfobjects # idfobjlst = [idfobjects[key] for key in idfobjects if idfobjects[key]] idfobjlst = [idfobjects[key] for key in idf.model.dtls if idfobjects[key]] # `for...
copy fromidf completely into toidf def copyidfintoidf(toidf, fromidf): """copy fromidf completely into toidf""" idfobjlst = getidfobjectlist(fromidf) for idfobj in idfobjlst: toidf.copyidfobject(idfobj)
return the diffs between the two idfs def idfdiffs(idf1, idf2): """return the diffs between the two idfs""" thediffs = {} keys = idf1.model.dtls # undocumented variable for akey in keys: idfobjs1 = idf1.idfobjects[akey] idfobjs2 = idf2.idfobjects[akey] names = set([getobjname(i...
return autsizeable field names in idfobject def autosize_fieldname(idfobject): """return autsizeable field names in idfobject""" # undocumented stuff in this code return [fname for (fname, dct) in zip(idfobject.objls, idfobject['objidd']) if 'autosizabl...
wrapper for iddtxt2groups def idd2group(fhandle): """wrapper for iddtxt2groups""" try: txt = fhandle.read() return iddtxt2groups(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2groups(txt)
wrapper for iddtxt2grouplist def idd2grouplist(fhandle): """wrapper for iddtxt2grouplist""" try: txt = fhandle.read() return iddtxt2grouplist(txt) except AttributeError as e: txt = open(fhandle, 'r').read() return iddtxt2grouplist(txt)
extract the groups from the idd file def iddtxt2groups(txt): """extract the groups from the idd file""" try: txt = txt.decode('ISO-8859-2') except AttributeError as e: pass # for python 3 txt = nocomment(txt, '!') txt = txt.replace("\\group", "!-group") # retains group in next line ...
return a list of group names the list in the same order as the idf objects in idd file def iddtxt2grouplist(txt): """return a list of group names the list in the same order as the idf objects in idd file """ def makenone(astr): if astr == 'None': return None else: ...
add group info to commlst def group2commlst(commlst, glist): """add group info to commlst""" for (gname, objname), commitem in zip(glist, commlst): newitem1 = "group %s" % (gname, ) newitem2 = "idfobj %s" % (objname, ) commitem[0].insert(0, newitem1) commitem[0].insert(1, newite...
add group info tocomdct def group2commdct(commdct, glist): """add group info tocomdct""" for (gname, objname), commitem in zip(glist, commdct): commitem[0]['group'] = gname commitem[0]['idfobj'] = objname return commdct
extract embedded group data from commdct. return gdict -> {g1:[obj1, obj2, obj3], g2:[obj4, ..]} def commdct2grouplist(gcommdct): """extract embedded group data from commdct. return gdict -> {g1:[obj1, obj2, obj3], g2:[obj4, ..]}""" gdict = {} for objidd in gcommdct: group = objidd[0]['grou...
flatten and return a copy of the list indefficient on large lists def flattencopy(lst): """flatten and return a copy of the list indefficient on large lists""" # modified from # http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python thelist = copy.deepcopy(lst) ...
make a pipe component generate inlet outlet names def makepipecomponent(idf, pname): """make a pipe component generate inlet outlet names""" apipe = idf.newidfobject("Pipe:Adiabatic".upper(), Name=pname) apipe.Inlet_Node_Name = "%s_inlet" % (pname,) apipe.Outlet_Node_Name = "%s_outlet" % (pname...
make a duct component generate inlet outlet names def makeductcomponent(idf, dname): """make a duct component generate inlet outlet names""" aduct = idf.newidfobject("duct".upper(), Name=dname) aduct.Inlet_Node_Name = "%s_inlet" % (dname,) aduct.Outlet_Node_Name = "%s_outlet" % (dname,) ret...
make a branch with a pipe use standard inlet outlet names def makepipebranch(idf, bname): """make a branch with a pipe use standard inlet outlet names""" # make the pipe component first pname = "%s_pipe" % (bname,) apipe = makepipecomponent(idf, pname) # now make the branch with the pipe in...
make a branch with a duct use standard inlet outlet names def makeductbranch(idf, bname): """make a branch with a duct use standard inlet outlet names""" # make the duct component first pname = "%s_duct" % (bname,) aduct = makeductcomponent(idf, pname) # now make the branch with the duct in...
get the components of the branch def getbranchcomponents(idf, branch, utest=False): """get the components of the branch""" fobjtype = 'Component_%s_Object_Type' fobjname = 'Component_%s_Name' complist = [] for i in range(1, 100000): try: objtype = branch[fobjtype % (i,)] ...
rename all the changed nodes def renamenodes(idf, fieldtype): """rename all the changed nodes""" renameds = [] for key in idf.model.dtls: for idfobject in idf.idfobjects[key]: for fieldvalue in idfobject.obj: if type(fieldvalue) is list: if fieldvalue...