Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opensourcebim/python-mvdxml
A mvdXML checker and w3c SPARQL converter, as an IfcOpenShell submodule or stand-alone.
https://github.com/opensourcebim/python-mvdxml
bot buildingsmart ifc ifcowl industryfoundationclasses linkedbuildingdata linkeddata mvd mvdxml owl python semanticweb
Last synced: 2 months ago
JSON representation
A mvdXML checker and w3c SPARQL converter, as an IfcOpenShell submodule or stand-alone.
- Host: GitHub
- URL: https://github.com/opensourcebim/python-mvdxml
- Owner: opensourceBIM
- License: lgpl-3.0
- Created: 2019-03-15T14:08:32.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-19T21:25:30.000Z (about 1 year ago)
- Last Synced: 2024-04-15T00:12:30.912Z (9 months ago)
- Topics: bot, buildingsmart, ifc, ifcowl, industryfoundationclasses, linkedbuildingdata, linkeddata, mvd, mvdxml, owl, python, semanticweb
- Language: Python
- Size: 159 KB
- Stars: 31
- Watchers: 15
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## python-mvdxml
A mvdXML checker and w3c SPARQL converter, as an IfcOpenShell submodule or stand-alone.
WARNING: While this repository has many useful building blocks to build software around mvdXML and IFC, there are many mvdXML dialects and not all variants are likely to be fully supported.
### Quickstart
#### Extraction```python
import ifcopenshell
from ifcopenshell.mvd import mvdmvd_concept = mvd.open_mvd("examples/wall_extraction.mvdxml")
file = ifcopenshell.open("Duplex_A_20110505.ifc")all_data = mvd.get_data(mvd_concept, file, spreadsheet_export=True)
non_respecting_entities = mvd.get_non_respecting_entities(file, all_data[1])
respecting_entities = mvd.get_respecting_entities(file, all_data[1])```
```python
# Create a new file
new_file = ifcopenshell.file(schema=file.schema)
proj = file.by_type("IfcProject")[0]
new_file.add(proj)for e in respecting_entities:
new_file.add(e)new_file.write("new_file.ifc")
``````python
# Visualize results
mvd.visualize(file, non_respecting_entities)
```##### Validation
~~~py
import ifcopenshellfrom ifcopenshell.mvd import mvd
from colorama import Fore
from colorama import Styleconcept_roots = list(ifcopenshell.mvd.concept_root.parse(MVDXML_FILENAME))
file = ifcopenshell.open(IFC_FILENAME)tt = 0 # total number of tests
ts = 0 # total number of successful testsfor concept_root in concept_roots:
print("ConceptRoot: ", concept_root.entity)
for concept in concept_root.concepts():
tt = tt + 1
print("Concept: ", concept.name)
try:if len(concept.template().rules) > 1:
attribute_rules = []
for rule in concept.template().rules:
attribute_rules.append(rule)
rules_root = ifcopenshell.mvd.rule("EntityRule", concept_root.entity, attribute_rules)
else:
rules_root = concept.template().rules[0]
ts = ts + 1
finst = 0 #failed instancesfor inst in file.by_type(concept_root.entity):
try:
data = mvd.extract_data(rules_root, inst)
valid, output = mvd.validate_data(concept, data)
if not valid:
finst = finst + 1
print("[VALID]" if valid else Fore.RED +"[failure]"+Style.RESET_ALL, inst)
print(output)
except Exception as e:
print(Fore.RED+"EXCEPTION: ", e, Style.RESET_ALL,inst)
print ()
print (int(finst), "out of", int(len(file.by_type(concept_root.entity))), "instances failed the check")
print ("---------------------------------")
except Exception as e:
print("EXCEPTION: "+Fore.RED,e,Style.RESET_ALL)
print("---------------------------------")
print("---------------------------------")
print("---------------------------------")tf = tt-ts # total number of failed tests
print ("\nRESULTS OVERVIEW")
print ("Total number of tests: ",tt)
print ("Total number of executed tests: ", ts)
print ("Total number of failed tests: ", tf)
~~~