Search in sources :

Example 1 with IfcPropertySingleValue

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

the class TestSetWrappedIntegerGeometry method test.

@Test
public void test() {
    try {
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        bimServerClient.getSettingsInterface().setCacheOutputFiles(false);
        LowLevelInterface lowLevelInterface = bimServerClient.getLowLevelInterface();
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        bimServerClient.checkinSync(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/revit_quantities.ifc"));
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc"));
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false);
        long tid = lowLevelInterface.startTransaction(newProject.getOid());
        IfcPropertySingleValue ifcPropertySingleValue = model.getAll(IfcPropertySingleValue.class).iterator().next();
        bimServerClient.getLowLevelInterface().setWrappedLongAttribute(tid, ifcPropertySingleValue.getOid(), "NominalValue", "IfcInteger", 12345L);
        long roid = lowLevelInterface.commitTransaction(tid, "v2", false);
        IfcModelInterface newModel = bimServerClient.getModel(newProject, roid, true, false, true);
        SVector3f minBounds = newModel.getModelMetaData().getMinBounds();
        SVector3f maxBounds = newModel.getModelMetaData().getMaxBounds();
        org.junit.Assert.assertNotNull(minBounds);
        org.junit.Assert.assertNotNull(maxBounds);
        bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc"));
        bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc"));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SVector3f(org.bimserver.interfaces.objects.SVector3f) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) LowLevelInterface(org.bimserver.shared.interfaces.LowLevelInterface) URL(java.net.URL) Test(org.junit.Test)

Example 2 with IfcPropertySingleValue

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

the class TestCreateProperties method test.

@Test
public void test() {
    try {
        // New client
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a project
        SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Look for a deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        bimServerClient.checkinSync(project.getOid(), "test", deserializer.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project
        project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
        // Load model without lazy loading (complete model at once)
        IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true);
        String propertyName = "BooleanProperty";
        int nrWindowsFirst = 0;
        // Iterate over all projects, there should be 1
        for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
            nrWindowsFirst++;
            createProperty(window, model, propertyName, "Description of property", true);
        }
        long newRoid = model.commit("Added boolean properties to " + nrWindowsFirst + " windows");
        model = bimServerClient.getModel(project, newRoid, true, false);
        int foundOke = 0;
        int nrWindowsSecond = 0;
        Set<Long> counted = new HashSet<Long>();
        for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
            nrWindowsSecond++;
            for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
                if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
                    IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
                    IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
                    if (relatingPropertyDefinition instanceof IfcPropertySet) {
                        IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
                        for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
                            if (ifcProperty instanceof IfcPropertySingleValue) {
                                IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
                                if (ifcPropertySingleValue.getName().equals(propertyName)) {
                                    IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
                                    if (nominalValue instanceof IfcBoolean) {
                                        if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
                                            if (!counted.contains(ifcPropertySingleValue.getOid())) {
                                                foundOke++;
                                                counted.add(ifcPropertySingleValue.getOid());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        LOGGER.info("Windows first: " + nrWindowsFirst);
        LOGGER.info("Windows second: " + nrWindowsSecond);
        LOGGER.info("Found Oke: " + foundOke);
        if (foundOke != nrWindowsFirst) {
            fail(foundOke + " / " + nrWindowsFirst);
        }
    } catch (Throwable e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : IfcValue(org.bimserver.models.ifc2x3tc1.IfcValue) IfcProperty(org.bimserver.models.ifc2x3tc1.IfcProperty) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcWindow(org.bimserver.models.ifc2x3tc1.IfcWindow) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SProject(org.bimserver.interfaces.objects.SProject) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) URL(java.net.URL) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) HashSet(java.util.HashSet) IfcBoolean(org.bimserver.models.ifc2x3tc1.IfcBoolean) Test(org.junit.Test)

Example 3 with IfcPropertySingleValue

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

the class TestReadProperties method test.

@Test
public void test() {
    try {
        // New client
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a project
        SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Look for a deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        // Checkin file
        bimServerClient.checkinSync(project.getOid(), "test", deserializer.getOid(), false, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project
        project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
        // Load model without lazy loading (complete model at once)
        IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, false);
        // Iterate over all projects, there should be 1
        for (IfcProject ifcProject : model.getAllWithSubTypes(IfcProject.class)) {
            for (IfcRelDefines ifcRelDefines : ifcProject.getIsDefinedBy()) {
                if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
                    IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
                    IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
                    if (relatingPropertyDefinition instanceof IfcPropertySet) {
                        IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
                        for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
                            if (ifcProperty instanceof IfcPropertySingleValue) {
                                IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
                                IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
                                String stringValue = "";
                                if (nominalValue instanceof IfcLabel) {
                                    stringValue = ((IfcLabel) nominalValue).getWrappedValue();
                                } else if (nominalValue instanceof IfcIdentifier) {
                                    stringValue = ((IfcIdentifier) nominalValue).getWrappedValue();
                                } else if (nominalValue instanceof IfcAreaMeasure) {
                                    stringValue = "" + ((IfcAreaMeasure) nominalValue).getWrappedValue();
                                }
                                if (ifcPropertySingleValue.getName().equals("ConstructionMode")) {
                                    if (!stringValue.equals("Massivbau")) {
                                        fail("Massivbau expected");
                                    }
                                } else if (ifcPropertySingleValue.getName().equals("BuildingPermitId")) {
                                    if (!stringValue.equals("4711")) {
                                        fail("4711 expected");
                                    }
                                } else if (ifcPropertySingleValue.getName().equals("GrossAreaPlanned")) {
                                    if (stringValue == null || !stringValue.equals("1000.0")) {
                                        fail("1000. expected");
                                    }
                                }
                                System.out.println(ifcPropertySingleValue.getName() + ": " + stringValue);
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        if (!(e instanceof AssertionError)) {
            fail(e.getMessage());
        }
    }
}
Also used : IfcProject(org.bimserver.models.ifc2x3tc1.IfcProject) IfcValue(org.bimserver.models.ifc2x3tc1.IfcValue) IfcProperty(org.bimserver.models.ifc2x3tc1.IfcProperty) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) IfcAreaMeasure(org.bimserver.models.ifc2x3tc1.IfcAreaMeasure) SProject(org.bimserver.interfaces.objects.SProject) IfcRelDefinesByProperties(org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties) URL(java.net.URL) IfcRelDefines(org.bimserver.models.ifc2x3tc1.IfcRelDefines) IfcLabel(org.bimserver.models.ifc2x3tc1.IfcLabel) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IfcPropertySet(org.bimserver.models.ifc2x3tc1.IfcPropertySet) IfcPropertySetDefinition(org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition) IfcIdentifier(org.bimserver.models.ifc2x3tc1.IfcIdentifier) Test(org.junit.Test)

Example 4 with IfcPropertySingleValue

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

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

IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)11 IfcModelInterface (org.bimserver.emf.IfcModelInterface)7 SProject (org.bimserver.interfaces.objects.SProject)7 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)7 URL (java.net.URL)6 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)6 IfcPropertySet (org.bimserver.models.ifc2x3tc1.IfcPropertySet)6 IfcRelDefinesByProperties (org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties)6 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)6 Test (org.junit.Test)6 IfcProperty (org.bimserver.models.ifc2x3tc1.IfcProperty)5 IfcPropertySetDefinition (org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition)5 IfcRelDefines (org.bimserver.models.ifc2x3tc1.IfcRelDefines)5 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)4 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)4 IfcBoolean (org.bimserver.models.ifc2x3tc1.IfcBoolean)3 IfcValue (org.bimserver.models.ifc2x3tc1.IfcValue)3 IfcLabel (org.bimserver.models.ifc2x3tc1.IfcLabel)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1