def step_impl(context, guid, number): number = util.assert_number(number) site = util.assert_guid(IfcStore.file, guid) util.assert_type(site, "IfcSite") ref = util.assert_attribute(site, "RefLatitude") number = ifcopenshell.util.geolocation.dd2dms(number, use_ms=(len(ref) == 4)) util.assert_attribute(site, "RefLatitude", number)
def check_geocode_address(guid, spatial_type, name, value): element = util.assert_guid(IfcStore.file, guid) ifc_class = get_ifc_class_from_spatial_type(spatial_type) util.assert_type(element, ifc_class) if ifc_class == "IfcSite": address_name = "SiteAddress" elif ifc_class == "IfcBuilding": address_name = "BuildingAddress" util.assert_attribute(element, address_name) util.assert_attribute(getattr(element, address_name), name, value)
def step_impl(context, guid): site = util.assert_guid(IfcStore.file, guid) util.assert_type(site, "IfcSite") if not site.ObjectPlacement: assert False, _("The site has no object placement") site_placement = ifcopenshell.util.placement.get_local_placement( site.ObjectPlacement)[:, 3][0:3] origin = np.array([0, 0, 0]) assert np.allclose( origin, site_placement), _('The site location is at "{}" instead of "{}"')
def step_impl(context, guid, predefined_type): element = util.assert_guid(IfcStore.file, guid) if ( hasattr(element, "PredefinedType") and element.PredefinedType == "USERDEFINED" and hasattr(element, "ObjectType") ): util.assert_attribute(element, "ObjectType", predefined_type) elif hasattr(element, "PredefinedType"): util.assert_attribute(element, "PredefinedType", predefined_type) else: assert False, _("The element {} does not have a PredefinedType or ObjectType attribute").format(element)
def step_impl(context, guid, easting, northing, elevation): if IfcStore.file.schema == "IFC2X3": if element.is_a("IfcSite"): site = element else: potential_sites = [ s for s in get_containing_spatial_elements(element) if s.is_a("IfcSite") ] if potential_sites: site = potential_sites[0] else: assert False, _( "The datum element does not belong to a geolocated site") map_conversion = util.assert_pset(site, "EPset_MapConversion") else: map_conversion = IfcStore.file.by_type("IfcMapConversion") if map_conversion: map_conversion = map_conversion[0].get_info() else: assert False, _("No map conversion was found in the file") element = util.assert_guid(IfcStore.file, guid) if not element.ObjectPlacement: assert False, _("The element does not have an object placement: {}" ).format(element) m = ifcopenshell.util.placement.get_local_placement( element.ObjectPlacement) e, n, h = ifcopenshell.util.geolocation.xyz2enh( m[0][3], m[1][3], m[2][3], float(map_conversion["Eastings"]), float(map_conversion["Northings"]), float(map_conversion["OrthogonalHeight"]), float(map_conversion["XAxisAbscissa"]), float(map_conversion["XAxisOrdinate"]), float(map_conversion["Scale"]), ) element_x = round(e, get_decimal_points(easting)) element_y = round(n, get_decimal_points(northing)) element_z = round(h, get_decimal_points(elevation)) expected_placement = (util.assert_number(easting), util.assert_number(northing), util.assert_number(elevation)) if (element_x, element_y, element_z) != expected_placement: assert False, _( "The element {} is meant to have a location of {} but instead we found {}" ).format(element, expected_placement, (element_x, element_y, element_z))
def step_impl(context, guid, x, y, z): element = util.assert_guid(IfcStore.file, guid) if not element.ObjectPlacement: assert False, _("The element does not have an object placement: {}" ).format(element) m = ifcopenshell.util.placement.get_local_placement( element.ObjectPlacement) element_x = round(m[0][3], get_decimal_points(x)) element_y = round(m[1][3], get_decimal_points(y)) element_z = round(m[2][3], get_decimal_points(z)) expected_placement = (util.assert_number(x), util.assert_number(y), util.assert_number(z)) if (element_x, element_y, element_z) != expected_placement: assert False, _( "The element {} is meant to have a location of {} but instead we found {}" ).format(element, expected_placement, (element_x, element_y, element_z))
def step_impl(context, guid, identification, reference_name): element = util.assert_guid(IfcStore.file, guid) if not hasattr(element, "HasAssociations") or not element.HasAssociations: assert False, _("The element {} has no associations.").format(element) references = [a.RelatingClassification for a in element.HasAssociations if a.is_a("IfcRelAssociatesClassification")] if not references: assert False, _("The element {element} has no associated classification references.").format(element) is_success = False for reference in references: try: util.assert_attribute(reference, "Identification", identification) util.assert_attribute(reference, "Name", reference_name) is_success = True except: pass if not is_success: assert False, _( "No classification references met the requirement for an identification {} and name {} for the element {}. The references we found were: {}" ).format(identification, reference_name, element, references)
def step_impl(context, guid, ifc_class): element = util.assert_guid(IfcStore.file, guid) util.assert_type(element, ifc_class)
def check_geocode_attribute(guid, spatial_type, name, value): element = util.assert_guid(IfcStore.file, guid) util.assert_type(element, get_ifc_class_from_spatial_type(spatial_type)) util.assert_attribute(element, name, value)
def step_impl(context, guid, number): number = util.assert_number(number) site = util.assert_guid(IfcStore.file, guid) util.assert_type(site, "IfcSite") util.assert_attribute(site, "RefElevation", number)