1
# ***************************************************************************
3
# * Copyright (c) 2018 Yorik van Havre <yorik@uncreated.net> *
5
# * This program is free software; you can redistribute it and/or modify *
6
# * it under the terms of the GNU Lesser General Public License (LGPL) *
7
# * as published by the Free Software Foundation; either version 2 of *
8
# * the License, or (at your option) any later version. *
9
# * for detail see the LICENCE text file. *
11
# * This program is distributed in the hope that it will be useful, *
12
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
# * GNU Library General Public License for more details. *
16
# * You should have received a copy of the GNU Library General Public *
17
# * License along with this program; if not, write to the Free Software *
18
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21
# ***************************************************************************
23
"""This script retrieves a list of standard property sets from the IFC4 official documentation website
24
and stores them into a pset_dfinitions.xml files in the current directory. Warning, this can take
25
a certain time (there are more than 400 definitions to retrieve)"""
28
from urllib.request import urlopen
31
IFC_DOCS_ROOT_URL = "https://standards.buildingsmart.org/IFC/DEV/IFC4_2/FINAL/HTML/"
34
print("Getting psets list...")
36
IFC_DOCS_ROOT_URL + "annex/annex-b/alphabeticalorder_psets.htm"
38
p = u.read().decode('utf-8')
40
psets = re.findall(">Pset_(.*?)</a>", p)
42
# retrieve xml data from each Pset type
45
for i, pset in enumerate(psets):
46
print(i + 1, "/", len(psets), ": Retrieving Pset", pset)
47
for j in range(MAXTRIES):
50
IFC_DOCS_ROOT_URL + "psd/Pset_"
54
p = u.read().decode('utf-8')
57
print(" Connection failed. trying one more time...")
61
print(" Unable to retrieve ", pset, ". Skipping...")
64
psetdefs = psetdefs.replace('<?xml version="1.0" encoding="utf-8"?>', "")
65
psetdefs = '<?xml version="1.0" encoding="utf-8"?>\n<Root>\n' + psetdefs + "</Root>"
67
f = codecs.open("pset_definitions.xml", "wb", "utf-8")
72
+ os.path.join(os.path.abspath(os.curdir), "pset_definitions.xml")
75
print("The following psets failed and were not retrieved:", failed)