use of org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties in project BIMserver by opensourceBIM.
the class IfcUtils method listProperties.
/**
* 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;
}
use of org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties in project BIMserver by opensourceBIM.
the class IfcUtils method getIfcQuantityVolume.
public static Double getIfcQuantityVolume(IfcProduct ifcProduct, String name) {
for (IfcRelDefines ifcRelDefines : ifcProduct.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition propertySetDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (propertySetDefinition instanceof IfcElementQuantity) {
if (propertySetDefinition.getName().equals("BaseQuantities")) {
IfcElementQuantity ifcElementQuantity = (IfcElementQuantity) propertySetDefinition;
for (IfcPhysicalQuantity ifcPhysicalQuantity : ifcElementQuantity.getQuantities()) {
if (ifcPhysicalQuantity instanceof IfcQuantityVolume) {
return ((IfcQuantityVolume) ifcPhysicalQuantity).getVolumeValue();
}
}
}
}
}
}
return null;
}
use of org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties in project BIMserver by opensourceBIM.
the class IfcUtils method getBooleanProperty.
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;
}
use of org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties in project BIMserver by opensourceBIM.
the class TestCreateProperties method createProperty.
private void createProperty(IfcWindow window, IfcModelInterface model, String name, String description, Object value) throws IfcModelInterfaceException {
IfcRelDefinesByProperties ifcRelDefinesByProperties = model.create(IfcRelDefinesByProperties.class);
window.getIsDefinedBy().add(ifcRelDefinesByProperties);
IfcPropertySet propertySet = model.create(IfcPropertySet.class);
ifcRelDefinesByProperties.setRelatingPropertyDefinition(propertySet);
IfcPropertySingleValue property = model.create(IfcPropertySingleValue.class);
propertySet.getHasProperties().add(property);
property.setName(name);
property.setDescription(description);
if (value instanceof Boolean) {
IfcBoolean ifcValue = model.create(IfcBoolean.class);
ifcValue.setWrappedValue(((Boolean) value) ? Tristate.TRUE : Tristate.FALSE);
property.setNominalValue(ifcValue);
} else {
// Unimplemented
}
}
Aggregations