[IDS] Creating an IDS file with a python script
Here is the sample ids file from bSI: https://github.com/buildingSMART/IDS/blob/master/Documentation/library/sample.ids
I did create a script as a challenge to recreate that sample ids file, see below:
from ifctester import ids, reporter
my_ids_path = r"C:\pathtoidsfile\sample.ids"
# create new IDS
my_ids = ids.Ids(
title="buildingSMART Sample IDS",
copyright="buildingSMART",
version="1.0.0",
description="These are example specifications for those learning how to use IDS",
author="[email protected]",
date="2022-01-01",
purpose="Contractual requirements",
)
# add specification to it
my_spec = ids.Specification(
name="Project naming",
minOccurs=0,
maxOccurs="unbounded",
ifcVersion="IFC4",
description="Projects shall be named correctly for the purposes of identification, project archival, and model federation.",
instructions="Each discipline is responsible for naming their own project.",
)
my_spec.applicability.append(ids.Entity(name="IFCPROJECT"))
attribute = ids.Attribute(
name="Name",
value="TEST",
instructions="The project manager shall confirm the short project code with the client based on their real estate portfolio naming scheme.",
)
my_spec.requirements.append(attribute)
my_ids.specifications.append(my_spec)
# add an second specification to it
my_second_spec = ids.Specification(
name="Fire rating",
minOccurs=0,
maxOccurs="unbounded",
ifcVersion="IFC4",
description="All objects must have a fire rating for building compliance checks and to know the protection strategies needed for any penetrations.",
instructions="The architect is responsible for including this data.",
)
my_second_spec.applicability.append(ids.Entity(name="IFCWALLTYPE"))
restriction = ids.Restriction(
base="string",
options={"pattern": "(-|[0-9]{2,3})\/(-|[0-9]{2,3})\/(-|[0-9]{2,3})"},
)
property = ids.Property(
name="FireRating",
value=restriction,
propertySet="Pset_WallCommon",
datatype="IfcLabel",
uri="https://identifier.buildingsmart.org/uri/.../prop/LoadBearing",
instructions="Fire rating is specified using the Fire Resistance Level as defined in the Australian National Construction Code (NCC) 2019. Valid examples include -/-/-, -/120/120, and 60/60/60",
minOccurs=1,
maxOccurs=1)
my_second_spec.requirements.append(property)
my_ids.specifications.append(my_second_spec)
# Save such IDS to file
result = my_ids.to_xml(my_ids_path)
Really cool that with ifctester that is was possible to recreate the sample ids file !
Tagged: