Problem with huge ifc file
Re: Problem with huge ifc file
would you post the file you would like to extract these entities?
Re: Problem with huge ifc file
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")
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")
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)
Re: Problem with huge ifc file
I think what you need is just product.id.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.
How to get #15, #28, etc to save it with 15.ifc, 28.ifc etcCode: Select all
for product in products: print(product)
Re: Problem with huge ifc file
Yeah.hlg wrote: ↑Tue Jan 07, 2020 6:52 pmI think what you need is just product.id.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.
How to get #15, #28, etc to save it with 15.ifc, 28.ifc etcCode: Select all
for product in products: print(product)
I need to lear more about Ifc file structure etc. next pyhton etc . - 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.
-
- Posts: 26
- Joined: Fri Aug 30, 2019 9:47 am
Re: Problem with huge ifc file
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 :
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
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
+}
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
Re: Problem with huge ifc file
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
BTW: link to PR: https://github.com/IfcOpenShell/IfcOpenShell/pull/779
-
- Posts: 26
- Joined: Fri Aug 30, 2019 9:47 am
Re: Problem with huge ifc file
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 ?
I'll look into it though, it looks like it segfaults when trying to extrude a zero size loop ?
Re: Problem with huge ifc file
that would be great. Since I am a Python guy, debugging ifcopenshell is very very difficault for me.
Re: Problem with huge ifc file
new PR was made to hopefully fix the issue ... https://github.com/IfcOpenShell/IfcOpenShell/pull/801