Problem with huge ifc file

This forum section is only for IFC-related issues
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Problem with huge ifc file

Post by bernd »

would you post the file you would like to extract these entities?
jureko
Posts: 21
Joined: Thu Oct 31, 2019 10:01 am

Re: Problem with huge ifc file

Post by jureko »

bernd wrote: Mon Dec 23, 2019 9:39 am would you post the file you would like to extract these entities?
It's exmpl a file I've already attached, or any other file.
I can already split it into single ifc files, I hope all is correct.
What's interesting for me is that after merging them into one file I have no problem with import it in Freecad as on my first post in this thread.
However, merging files I do quite simply. I don't know how to write it well in python so I put the path list to merge in the script manually.
This is the code to split:

Code: Select all

import ifcopenshell
import importIFC
from string import *

filepath = 'C:/IFC/piping0/'

f = ifcopenshell.open(filepath + 'PIPING0.ifc')
products = f.by_type('IfcProduct')
for product in products:
    g = ifcopenshell.file(schema=f.schema)
    g.add(f.by_type("IfcProject")[0])
    a=str(product)
    b=a.find('=')
    entity=int(a[1:b])
#    print(product)
#    print(entity)
    g.add(f[entity])
    g.write(filepath + str(entity) + ".ifc")
And this is for merging:

Code: Select all

import ifcopenshell
#this is small first generated file
new_file = ifcopenshell.open("C:/IFC/piping0/2.ifc")

old_files = list(map(ifcopenshell.open, [
    "C:/IFC/piping0/74684.ifc",
    "C:/IFC/piping0/74707.ifc",
    "C:/IFC/piping0/74750.ifc",
    "C:/IFC/piping0/74751.ifc",
# there is block of 500 files paths

]))

for old_file in old_files:
    for inst in old_file:
        new_file.add(inst)

new_file.write("C:/IFC/piping0/merged5.ifc")

Would you give me an idea how to automate the merging of example 500 files into one ifc, and then generate new file etc?
Too big ifc files I can't then import into bocad.
Thanks for help with splitting ifc!

Translated with www.DeepL.com/Translator (free version)
User avatar
hlg
Posts: 39
Joined: Fri Jul 12, 2019 10:11 am

Re: Problem with huge ifc file

Post by hlg »

jureko wrote: Thu Dec 19, 2019 2:48 pm I have a question. What's the name of the property with the number of a singular entity ifc file?
I've printed out a list from the file, and I'd like to save those entitions as individual files. I just don't know how to get the number of a particular part.

Code: Select all

for product in products:
   print(product)
How to get #15, #28, etc to save it with 15.ifc, 28.ifc etc
I think what you need is just product.id.
jureko
Posts: 21
Joined: Thu Oct 31, 2019 10:01 am

Re: Problem with huge ifc file

Post by jureko »

hlg wrote: Tue Jan 07, 2020 6:52 pm
jureko wrote: Thu Dec 19, 2019 2:48 pm I have a question. What's the name of the property with the number of a singular entity ifc file?
I've printed out a list from the file, and I'd like to save those entitions as individual files. I just don't know how to get the number of a particular part.

Code: Select all

for product in products:
   print(product)
How to get #15, #28, etc to save it with 15.ifc, 28.ifc etc
I think what you need is just product.id.
Yeah.
I need to lear more about Ifc file structure etc. next pyhton etc :D. - for future...
Thanks everyone.
With Yours help I made small script to splitting ifc file and finally import sucessfully these large files to Freecad and next to bocad.
sanderboer
Posts: 26
Joined: Fri Aug 30, 2019 9:47 am

Re: Problem with huge ifc file

Post by sanderboer »

Hi,

Yesterday I posted a PR with a small patch that remedies a segfault bug. It looks like this is what ails this file. Ifcopenshell crashes when checking curve intersections.
https://github.com/IfcOpenShell/IfcOpenShell/issues/768


diff :

Code: Select all

--- /src/ifcgeom/IfcGeomFunctions.cpp
+++ /src/ifcgeom/IfcGeomFunctions.cpp
@@ -3645,10 +3645,9 @@
                        if (i == n - 1 && j == 0) continue;

                        double u11, u12, u21, u22, U1, U2;
-                       GeomAPI_ExtremaCurveCurve ecc(
-                               BRep_Tool::Curve(wd->Edge(i + 1), u11, u12),
-                               BRep_Tool::Curve(wd->Edge(j + 1), u21, u22)
-                       );
+      thread_local Handle(Geom_Curve) c0 = BRep_Tool::Curve(wd->Edge(i + 1), u11, u12);
+      thread_local Handle(Geom_Curve) c1 = BRep_Tool::Curve(wd->Edge(j + 1), u21, u22);
+      GeomAPI_ExtremaCurveCurve ecc(c0, c1);

                        // @todo: extend this to work in case of multiple extrema and curved segments.
                        const bool unbounded_intersects = (ecc.NbExtrema() == 1 && ecc.Distance(1) < eps);
@@ -4227,4 +4226,4 @@
        if (loops_removed || (non_manifold && l->declaration().is(IfcSchema::IfcClosedShell::Class()))) {
                Logger::Warning(boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " loops removed and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges for:", l);
        }
-}
\ No newline at end of file
+}
copy , save as thisdiff.patch, then in the root of ifcopenshell v0.60b0 release sourcecode:
patch -Np1 < thisdiff.patch

I cannot download the file anymore to check if this fixes this particular issue, if anyone has it I would like to take a stab at it.

gr.
Sander
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Problem with huge ifc file

Post by bernd »

try this https://github.com/IfcOpenShell/files/pull/2 It was extracted from the huge file of this topic. Related issue on ifcopenshell https://github.com/IfcOpenShell/IfcOpenShell/issues/744

BTW: link to PR: https://github.com/IfcOpenShell/IfcOpenShell/pull/779
sanderboer
Posts: 26
Joined: Fri Aug 30, 2019 9:47 am

Re: Problem with huge ifc file

Post by sanderboer »

Nope, my pr does not fix this. =(

I'll look into it though, it looks like it segfaults when trying to extrude a zero size loop ?
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Problem with huge ifc file

Post by bernd »

that would be great. Since I am a Python guy, debugging ifcopenshell is very very difficault for me.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Problem with huge ifc file

Post by bernd »

new PR was made to hopefully fix the issue ... https://github.com/IfcOpenShell/IfcOpenShell/pull/801
Post Reply