Search in sources :

Example 6 with IfcRelDefinesByProperties

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;
}
Also used : IfcProperty(org.bimserver.models.ifc2x3tc1.IfcProperty) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) IdEObject(org.bimserver.emf.IdEObject) IfcObject(org.bimserver.models.ifc2x3tc1.IfcObject) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines)

Example 7 with IfcRelDefinesByProperties

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;
}
Also used : IfcQuantityVolume(org.bimserver.models.ifc2x3tc1.IfcQuantityVolume) IfcElementQuantity(org.bimserver.models.ifc2x3tc1.IfcElementQuantity) IfcPhysicalQuantity(org.bimserver.models.ifc2x3tc1.IfcPhysicalQuantity) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines)

Example 8 with IfcRelDefinesByProperties

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;
}
Also used : IfcProperty(org.bimserver.models.ifc2x3tc1.IfcProperty) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines) IfcBoolean(org.bimserver.models.ifc2x3tc1.IfcBoolean)

Example 9 with IfcRelDefinesByProperties

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
    }
}
Also used : IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) IfcBoolean(org.bimserver.models.ifc2x3tc1.IfcBoolean) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcBoolean(org.bimserver.models.ifc2x3tc1.IfcBoolean)

Aggregations

IfcRelDefinesByProperties (org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties)9 IfcPropertySetDefinition (org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition)8 IfcRelDefines (org.bimserver.models.ifc2x3tc1.IfcRelDefines)8 IfcPropertySet (org.bimserver.models.ifc2x3tc1.IfcPropertySet)7 IfcProperty (org.bimserver.models.ifc2x3tc1.IfcProperty)6 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)6 IfcBoolean (org.bimserver.models.ifc2x3tc1.IfcBoolean)3 IfcValue (org.bimserver.models.ifc2x3tc1.IfcValue)3 URL (java.net.URL)2 HashSet (java.util.HashSet)2 IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)2 SProject (org.bimserver.interfaces.objects.SProject)2 IfcElementQuantity (org.bimserver.models.ifc2x3tc1.IfcElementQuantity)2 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)2 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1