Search in sources :

Example 1 with IfcLabel

use of org.bimserver.models.ifc2x3tc1.IfcLabel 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.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, 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 2 with IfcLabel

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

the class TestChangeWrappedValue method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        long poid = 2686977;
        long roid = 720899;
        SProject project = client.getServiceInterface().getProjectByPoid(poid);
        IfcModelInterface model = client.getModel(project, roid, true, false);
        for (IfcPropertySingleValue prop : model.getAll(IfcPropertySingleValue.class)) {
            // IfcValue value = ((IfcPropertySingleValue) prop).getNominalValue();
            // if(value instanceof IfcLabel){
            // System.out.println(prop.getOid() + " is " + ((IfcLabel) value).getWrappedValue() );
            // ((IfcLabel) value).setWrappedValue(((IfcLabel) value).getWrappedValue() + " changed");
            // }
            IfcLabel label = model.create(IfcLabel.class);
            label.setWrappedValue("blabla");
            prop.setNominalValue(label);
        }
        model.commit("blaat");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    }
}
Also used : IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) IfcLabel(org.bimserver.models.ifc2x3tc1.IfcLabel) ServiceException(org.bimserver.shared.exceptions.ServiceException) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Aggregations

IfcModelInterface (org.bimserver.emf.IfcModelInterface)2 SProject (org.bimserver.interfaces.objects.SProject)2 IfcLabel (org.bimserver.models.ifc2x3tc1.IfcLabel)2 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)2 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)2 URL (java.net.URL)1 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)1 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)1 IfcAreaMeasure (org.bimserver.models.ifc2x3tc1.IfcAreaMeasure)1 IfcIdentifier (org.bimserver.models.ifc2x3tc1.IfcIdentifier)1 IfcProject (org.bimserver.models.ifc2x3tc1.IfcProject)1 IfcProperty (org.bimserver.models.ifc2x3tc1.IfcProperty)1 IfcPropertySet (org.bimserver.models.ifc2x3tc1.IfcPropertySet)1 IfcPropertySetDefinition (org.bimserver.models.ifc2x3tc1.IfcPropertySetDefinition)1 IfcRelDefines (org.bimserver.models.ifc2x3tc1.IfcRelDefines)1 IfcRelDefinesByProperties (org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties)1 IfcValue (org.bimserver.models.ifc2x3tc1.IfcValue)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)1 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)1