public static int getNrOfPropertySets(IfcProduct ifcProduct) { int nrPropertySets = 0; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { nrPropertySets++; } } } return nrPropertySets; }
public static List<String> listElementQuantities(IfcProduct ifcProduct) { List<String> list = new ArrayList<>(); for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcElementQuantity) { IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition; list.add(ifcElementQuantity.getName()); } } } return list; }
public static int getNrOfProperties(IfcProduct ifcProduct) { int nrProperties = 0; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; nrProperties += ifcPropertySet.getHasProperties().size(); } } } return nrProperties; }
public static Set<String> listPropertyNames(IfcProduct ifcProduct) { Set<String> list = new HashSet<>(); for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { list.add(ifcProperty.getName()); } } } } return list; }
public static Double getIfcQuantityVolume(IfcProduct ifcProduct) { Double volume = null; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcElementQuantity) { IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition; for (IfcPhysicalQuantity ifcPhysicalQuantity : ifcElementQuantity.getQuantities()) { if (ifcPhysicalQuantity instanceof IfcQuantityVolume) { if (volume == null) { volume = 0d; } volume += ((IfcQuantityVolume) ifcPhysicalQuantity).getVolumeValue(); } } } } } return volume; }
public static Double getIfcQuantityArea(IfcProduct ifcProduct) { Double area = null; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcElementQuantity) { IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition; for (IfcPhysicalQuantity ifcPhysicalQuantity : ifcElementQuantity.getQuantities()) { if (ifcPhysicalQuantity instanceof IfcQuantityArea) { if (area == null) { area = 0d; } area += ((IfcQuantityArea) ifcPhysicalQuantity).getAreaValue(); } } } } } return area; }
public static int getNrOfPSets(IfcProduct ifcProduct, boolean onlyOfficial) { int nrPSets = 0; for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { if (onlyOfficial) { try { Ifc2x3tc1OfficialPsets.valueOf(propertySetDefinition.getName()); nrPSets++; } catch (Exception e) { } } else { if (propertySetDefinition.getName().startsWith("Pset_")) { nrPSets++; } } } } } return nrPSets; }
public static String getStringProperty(IfcObject ifcObject, String propertyName) { for (IfcRelDefines ifcRelDefines : ifcObject.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { if (ifcProperty instanceof IfcPropertySingleValue) { IfcPropertySingleValue propertyValue = (IfcPropertySingleValue) ifcProperty; if (ifcProperty.getName().equals(propertyName)) { IfcValue nominalValue = propertyValue.getNominalValue(); return nominalValueToString(nominalValue); } } } } } } return null; }
public static Tristate getBooleanProperty(IfcObject ifcObject, String propertyName) { for (IfcRelDefines ifcRelDefines : ifcObject.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { if (ifcProperty instanceof IfcPropertySingleValue) { IfcPropertySingleValue propertyValue = (IfcPropertySingleValue) ifcProperty; if (ifcProperty.getName().equals(propertyName)) { IfcBoolean label = (IfcBoolean) propertyValue.getNominalValue(); return label.getWrappedValue(); } } } } } } return null; }
/** * Lists all properties of a given IfcPopertySet that are of type * IfcPropertySingleValue, all values are converted to the appropriate Java * type * * @param ifcObject * @param propertySetName * @return */ public static Map<String, Object> listProperties(IfcObject ifcObject, String propertySetName) { Map<String, Object> result = new HashMap<>(); for (IfcRelDefines ifcRelDefines : ifcObject.getIsDefinedBy()) { if (ifcRelDefines instanceof IfcRelDefinesByProperties) { IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines; IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition(); if (propertySetDefinition instanceof IfcPropertySet) { IfcPropertySet ifcPropertySet = (IfcPropertySet) propertySetDefinition; if (ifcPropertySet.getName() != null && ifcPropertySet.getName().equalsIgnoreCase(propertySetName)) { for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) { if (ifcProperty instanceof IfcPropertySingleValue) { IfcPropertySingleValue propertyValue = (IfcPropertySingleValue) ifcProperty; result.put(propertyValue.getName(), nominalValueToObject(propertyValue.getNominalValue())); } } } } } } return result; }