Search in sources :

Example 6 with IfcFurnishingElement

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

the class TestCreateGuid method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        IfcModelInterface model = bimServerClient.newModel(newProject, true);
        IfcFurnishingElement furnishing = model.create(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement());
        furnishing.setGlobalId("0uyjn9Jan3nRq36Uj6gwws");
        long roid = model.commit("Initial model");
        IfcModelInterface newModel = bimServerClient.getModel(newProject, roid, true, false);
        List<IfcFurnishingElement> furnishingElements = newModel.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement());
        assertTrue("There must be 1 furnishing element, not " + furnishingElements.size(), furnishingElements.size() == 1);
        IfcFurnishingElement newF = furnishingElements.get(0);
        assertTrue("GUID must be 0uyjn9Jan3nRq36Uj6gwws", newF.getGlobalId().equals("0uyjn9Jan3nRq36Uj6gwws"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) Test(org.junit.Test)

Example 7 with IfcFurnishingElement

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

the class ExtractFurniture method main.

public static void main(String[] args) {
    try {
        Path home = Paths.get("home");
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        MetaDataManager metaDataManager = new MetaDataManager(home.resolve("tmp"));
        PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1");
        deserializer.init(packageMetaData);
        IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, Paths.get("../TestData/data/ADT-FZK-Haus-2005-2006.ifc"));
        model.fixOids(new IncrementingOidProvider());
        IfcFurnishingElement picknick = (IfcFurnishingElement) model.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");
        IfcModelInterface newModel = new BasicIfcModel(packageMetaData, null);
        ModelHelper modelHelper = new ModelHelper(pluginManager.getMetaDataManager(), new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE), pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")), newModel);
        modelHelper.copy(picknick, false);
        SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
        Serializer serializer = serializerPlugin.createSerializer(null);
        serializer.init(newModel, null, true);
        SerializerUtils.writeToFile(serializer, Paths.get("test.ifc"));
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (DeserializeException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    } catch (SerializerException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) ModelHelper(org.bimserver.plugins.ModelHelper) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) MetaDataManager(org.bimserver.emf.MetaDataManager) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) IOException(java.io.IOException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) SerializerException(org.bimserver.plugins.serializers.SerializerException) PluginManager(org.bimserver.plugins.PluginManager) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) Deserializer(org.bimserver.plugins.deserializers.Deserializer) HideAllInversesObjectIDM(org.bimserver.plugins.objectidms.HideAllInversesObjectIDM) IncrementingOidProvider(org.bimserver.shared.IncrementingOidProvider) Serializer(org.bimserver.plugins.serializers.Serializer)

Aggregations

IfcFurnishingElement (org.bimserver.models.ifc2x3tc1.IfcFurnishingElement)7 IfcModelInterface (org.bimserver.emf.IfcModelInterface)6 SProject (org.bimserver.interfaces.objects.SProject)4 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)4 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)4 Test (org.junit.Test)4 IfcAxis2Placement3D (org.bimserver.models.ifc2x3tc1.IfcAxis2Placement3D)3 IfcLocalPlacement (org.bimserver.models.ifc2x3tc1.IfcLocalPlacement)3 IfcRelContainedInSpatialStructure (org.bimserver.models.ifc2x3tc1.IfcRelContainedInSpatialStructure)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 URL (java.net.URL)2 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)2 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)2 IfcCartesianPoint (org.bimserver.models.ifc2x3tc1.IfcCartesianPoint)2 ModelHelper (org.bimserver.plugins.ModelHelper)2 PluginManager (org.bimserver.plugins.PluginManager)2 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)2 Deserializer (org.bimserver.plugins.deserializers.Deserializer)2 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)2