Python Forum
IFC entities extracted twice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IFC entities extracted twice
#11
Is there a possibility of attaching the ModelFull.ifc file?
If not, as an alternative, one which you can attach that produces the same problem?
Reply
#12
(Apr-11-2019, 02:36 PM)Larz60+ Wrote: Is there a possibility of attaching the ModelFull.ifc file?
If not, as an alternative, one which you can attach that produces the same problem?

I am not able to attach the IFC file. Because I got an error "The type of file that you attached is not allowed. Please remove the attachment or choose a different type."

So I am giving a link to get the IFC files:-
https://drive.google.com/open?id=17Tj0q1...TPk5fyzW-3

Thank You.
Reply
#13
Ok, downloaded the files. I'm not highly confident that I can be of help, but am going to make a stab it it.
Reply
#14
Ok, I have managed to isolate where the duplicates are coming from.
To show this, I restructured your code a bit, to my style, so I could move around quicker,
code now looks like:

main module:
import IFCpaths
import ifcopenshell
import sys


class ifc:
    def __init__(self):
        self.ipath = IFCpaths.IFCpaths()
        self.f = ifcopenshell.open(self.ipath.ModelFull)
        self.f2 = ifcopenshell.file()
        self.process()

    def process(self):
        persons = self.f.by_type("IFCPERSON")
        for person in persons:
            self.f2.add(person)

        organizations = self.f.by_type("IFCORGANIZATION")
        for organization in organizations:
            self.f2.add(organization)
        
        personorganizations = self.f.by_type("IFCPERSONANDORGANIZATION")
        for personorganization in personorganizations:
            self.f2.add(personorganization)
        
        self.f2.write("test222.ifc")


if __name__ == '__main__':
    ifc()
IFCpaths.py
import os
from pathlib import Path


class IFCpaths:
    def __init__(self):
        os.chdir(os.path.abspath(os.path.dirname(__file__)))
        self.homepath = Path('.')
        self.rootpath = self.homepath / '..'

        self.datapath = self.rootpath / 'data'
        self.datapath.mkdir(exist_ok=True)

        self.beam_material = self.datapath / 'Beam_Material.ifc'
        self.ModelFull = self.datapath / 'ModelFull.ifc'
        self.testfile = self.datapath / 'test222.ifc'
Now to isolate the duplication, i wrote the output bit by bit
stage 1:
import IFCpaths
import ifcopenshell
import sys


class ifc:
    def __init__(self):
        self.ipath = IFCpaths.IFCpaths()
        self.f = ifcopenshell.open(self.ipath.ModelFull)
        self.f2 = ifcopenshell.file()
        self.process()

    def process(self):
        persons = self.f.by_type("IFCPERSON")
        for person in persons:
            print(f'person: {person}')
            self.f2.add(person)

        self.f2.write("test222.ifc")
        sys.exit(0)
        
        organizations = self.f.by_type("IFCORGANIZATION")
        for organization in organizations:
            print(f'organization: {organization}')
            self.f2.add(organization)
        
        personorganizations = self.f.by_type("IFCPERSONANDORGANIZATION")
        for personorganization in personorganizations:
            print(f'personorganization: {personorganization}')
            self.f2.add(personorganization)
        
        self.f2.write("test222.ifc")


if __name__ == '__main__':
    ifc()
output (all ok):
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T19:46:26',(),(),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev',''); FILE_SCHEMA(('IFC2X3')); ENDSEC; DATA; #1=IFCPERSON($,$,'',$,$,$,$,$); ENDSEC; END-ISO-10303-21;
stage 2:
import IFCpaths
import ifcopenshell
import sys


class ifc:
    def __init__(self):
        self.ipath = IFCpaths.IFCpaths()
        self.f = ifcopenshell.open(self.ipath.ModelFull)
        self.f2 = ifcopenshell.file()
        self.process()

    def process(self):
        persons = self.f.by_type("IFCPERSON")
        for person in persons:
            print(f'person: {person}')
            self.f2.add(person)
        
        organizations = self.f.by_type("IFCORGANIZATION")
        for organization in organizations:
            print(f'organization: {organization}')
            self.f2.add(organization)
        
        self.f2.write("test222.ifc")
        sys.exit(0)

        personorganizations = self.f.by_type("IFCPERSONANDORGANIZATION")
        for personorganization in personorganizations:
            print(f'personorganization: {personorganization}')
            self.f2.add(personorganization)
        
        self.f2.write("test222.ifc")


if __name__ == '__main__':
    ifc()
output (all still ok):
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T19:48:24',(),(),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev',''); FILE_SCHEMA(('IFC2X3')); ENDSEC; DATA; #1=IFCPERSON($,$,'',$,$,$,$,$); #2=IFCORGANIZATION($,'',$,$,$); ENDSEC; END-ISO-10303-21;
stage3
import IFCpaths
import ifcopenshell
import sys


class ifc:
    def __init__(self):
        self.ipath = IFCpaths.IFCpaths()
        self.f = ifcopenshell.open(self.ipath.ModelFull)
        self.f2 = ifcopenshell.file()
        self.process()

    def process(self):
        persons = self.f.by_type("IFCPERSON")
        for person in persons:
            print(f'person: {person}')
            self.f2.add(person)
        
        organizations = self.f.by_type("IFCORGANIZATION")
        for organization in organizations:
            print(f'organization: {organization}')
            self.f2.add(organization)
        
        personorganizations = self.f.by_type("IFCPERSONANDORGANIZATION")
        for personorganization in personorganizations:
            print(f'personorganization: {personorganization}')
            self.f2.add(personorganization)

        self.f2.write("test222.ifc")
        sys.exit(0)
        
        self.f2.write("test222.ifc")


if __name__ == '__main__':
    ifc()
output (not ok)
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T19:49:57',(),(),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev',''); FILE_SCHEMA(('IFC2X3')); ENDSEC; DATA; #1=IFCPERSON($,$,'',$,$,$,$,$); #2=IFCORGANIZATION($,'',$,$,$); #3=IFCPERSON($,$,'',$,$,$,$,$); #4=IFCORGANIZATION($,'',$,$,$); #5=IFCPERSONANDORGANIZATION(#3,#4,$); ENDSEC; END-ISO-10303-21;
So why? ...
This file format is totally new to me, but on looking in the model file, i see:
Output:
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
So, and this is a wild guess being totally uneducated on model file structurs, but having experience with other CAD layouts,
I wonder, does (#1, #2, $) mean include #1: (#1=IFCPERSON($,$,'',$,$,$,$,$);) and
include #2: #2=IFCORGANIZATION($,'',$,$,$); and
include $ (self?): #5=IFCPERSONANDORGANIZATION(#3,#4,$);
Reply
#15
This is a double post which is against forum rules. I will merge with previous post (which I just posted to by the way).
Double posts complicate answering.

see my response: https://python-forum.io/Thread-IFC-entit...6#pid76926
Reply
#16
(Apr-11-2019, 11:56 PM)Larz60+ Wrote: This file format is totally new to me, but on looking in the model file, i see:
Output:
#3=IFCPERSONANDORGANIZATION(#1,#2,$);
So, and this is a wild guess being totally uneducated on model file structurs, but having experience with other CAD layouts,
I wonder, does (#1, #2, $) mean include #1: (#1=IFCPERSON($,$,'',$,$,$,$,$);) and
include #2: #2=IFCORGANIZATION($,'',$,$,$); and
include $ (self?): #5=IFCPERSONANDORGANIZATION(#3,#4,$);

Thank you very much for your efforts.
Yes, #1 and #2 in (#1, #2, $) means include the entities #1 and #2.
The $ character encodes the indefinite value, i.e. it appears if an optional attribute has not been filled in.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  naming entities(city abbreviations) tirumalaramakrishna 1 1,198 May-06-2022, 11:22 AM
Last Post: jefsummers
  How to couunt extracted values ? Eidrizi 0 1,461 Sep-10-2020, 06:05 AM
Last Post: Eidrizi
  instaloaders problem: search certain hashtag - posts without hashtag extracted ledgreve 0 2,122 Nov-18-2019, 01:22 PM
Last Post: ledgreve
  Seperate entities in text file bigdazza 1 2,797 Jun-02-2018, 03:15 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020