Search in sources :

Example 1 with IfcObject

use of org.bimserver.models.ifc2x3tc1.IfcObject in project BIMserver by opensourceBIM.

the class IfcUtils method getStringProperty.

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;
}
Also used : IfcValue(org.bimserver.models.ifc2x3tc1.IfcValue) 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)

Example 2 with IfcObject

use of org.bimserver.models.ifc2x3tc1.IfcObject 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 3 with IfcObject

use of org.bimserver.models.ifc2x3tc1.IfcObject 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)

Aggregations

IfcProperty (org.bimserver.models.ifc2x3tc1.IfcProperty)3 IfcPropertySet (org.bimserver.models.ifc2x3tc1.IfcPropertySet)3 IfcPropertySetDefinition (org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition)3 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)3 IfcRelDefines (org.bimserver.models.ifc2x3tc1.IfcRelDefines)3 IfcRelDefinesByProperties (org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties)3 HashMap (java.util.HashMap)1 IdEObject (org.bimserver.emf.IdEObject)1 IfcBoolean (org.bimserver.models.ifc2x3tc1.IfcBoolean)1 IfcObject (org.bimserver.models.ifc2x3tc1.IfcObject)1 IfcValue (org.bimserver.models.ifc2x3tc1.IfcValue)1 EObject (org.eclipse.emf.ecore.EObject)1