Python Forum
IFC entities extracted twice
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IFC entities extracted twice
#1
Greetings for the day,
I am new with the coding world. I am using Python and IfcOpenShell to work on IFC files.
I want to use a command ifc.open but it is not working. I am using Python 2.7.
Please help me with this issue.
Thank you.
Reply
#2
Quote:fc.open but it is not working
How so?
Please post code, and error messages (complete, unmodified)
Use BBCode tags
Reply
#3
(Mar-17-2019, 07:17 AM)Larz60+ Wrote:
Quote:fc.open but it is not working
How so?
Please post code, and error messages (complete, unmodified)
Use BBCode tags
Thank you for your reply. Below given are the links to code and error:-

Code:- CODE
Error:- ERROR
Reply
#4
As Larz said, you should be posting in code tags. You're far less likely to get a reply if people have to go off-site. Also, I haven't looked at the links but the shorter the code the better - if you can reproduce your problem in 5-10 runnable lines of code rather than hundreds, you'll be substantially more likely to get a reply (and faster at that).
Reply
#5
(Mar-19-2019, 02:26 AM)micseydel Wrote: As Larz said, you should be posting in code tags. You're far less likely to get a reply if people have to go off-site. Also, I haven't looked at the links but the shorter the code the better - if you can reproduce your problem in 5-10 runnable lines of code rather than hundreds, you'll be substantially more likely to get a reply (and faster at that).

Thank you for your reply. I will definitely use BBCodes while posting any question.

from __future__ import print_function

f = ifc.open("C:\Users\GURBHEJ SINGH\Desktop\Beam_Material.ifc")
f2 = ifc.open("test22.ifc")


directions = f.by_type("ifcdirection")
for direction in directions:
   f2.add(direction)

beams = f.by_type("IFCBEAM")
for beam in beams:
   f2.add(beam)

f2.write("test22.ifc")
Error:
Traceback (most recent call last): File "C:\Users\GURBHEJ SINGH\Downloads\python\Abcdef.py", line 3, in <module> f = ifc.open("C:\Users\GURBHEJ SINGH\Desktop\Beam_Material.ifc") NameError: name 'ifc' is not defined
Please help me to solve the issue.
Thank you.
Reply
#6
You're trying to use a name which you haven't defined. The error seems relatively straightforward.

That said, I don't have an easy solution for you. I'm not familiar with ifc. I Googled very briefly and the Python examples I saw didn't try to use ifc the way you do. Are you following a tutorial? What inspired you to write this code?
Reply
#7
Greetings for the day,
I am working with IfcOpenShell and Python on the extraction of IFC entities. I have developed a Python code which I want to use to extract the structural model from the architectural model. But there is an issue which I am not able to understand and resolve because I am a beginner.
When I try to extract the entities which do not contain any entity written in bracket the code runs accurately.
for example:- #1=IFCPERSON($,$,'',$,$,$,$,$);
#2=IFCORGANIZATION($,'',$,$,$);

But the issue occurred when I want to extract the entities with previous entities written in Brackets
for example:- #20=IFCPROJECT('f2535189_f2f3_445f_963',#5,'Unnamed',$,$,$,$,(#11),#19);

The issue was that when I try to extract the entity for example "IFCPROJECT", the code will extract the "IFCPERSON" and "IFCORGANIZATION" twice if I have already extracted these two entities as done in the code given below.
import ifcopenshell

f = ifcopenshell.open("C:\Users\GURBHEJ SINGH\Desktop\IFC\ModelFull.ifc")
f2 = ifcopenshell.file()

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

organizations = f.by_type("IFCORGANIZATION")
for organization in organizations:
    f2.add(organization)

personorganizations = f.by_type("IFCPERSONANDORGANIZATION")
for personorganization in personorganizations:
    f2.add(personorganization)

f2.write("test222.ifc")
The output of the code was given below which is wrong:-
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T13:41:16',(),(),'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;
The output I want was that their should not be repetition of entities:-
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T13:41:16',(),(),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev',''); FILE_SCHEMA(('IFC2X3')); ENDSEC; DATA; #1=IFCPERSON($,$,'',$,$,$,$,$); #2=IFCORGANIZATION($,'',$,$,$); #3=IFCPERSONANDORGANIZATION(#1,#2,$) ENDSEC; END-ISO-10303-21;
Please help me to resolve this issue.
Reply
#8
Greetings for the day,
I have done some changes in the code and make it run. But I have faced another problem which I have explained in other thread.
The link to the thread:-
https://python-forum.io/Thread-IFC-entit...cted-twice

Thank you.
Reply
#9
As micseydel stated earlier:
Quote:You're far less likely to get a reply if people have to go off-site.
Reply
#10
(Apr-11-2019, 09:42 AM)Larz60+ Wrote: As micseydel stated earlier:
Quote:You're far less likely to get a reply if people have to go off-site.
I apologise. I am explaining the new problem which I have faced.

I am working with IfcOpenShell and Python on the extraction of IFC entities. I have developed a Python code which I want to use to extract the structural model from the architectural model. But there is an issue which I am not able to understand and resolve because I am a beginner.
When I try to extract the entities which do not contain any entity written in bracket the code runs accurately.
for example:- #1=IFCPERSON($,$,'',$,$,$,$,$);
#2=IFCORGANIZATION($,'',$,$,$);

But the issue occurred when I want to extract the entities with previous entities written in Brackets
for example:- #3=IFCPERSONANDORGANIZATION(#1,#2,$);

The issue was that when I try to extract the entity for example "IFCPERSONANDORGANIZATION", the code will extract the "IFCPERSON" and "IFCORGANIZATION" twice if I have already extracted these two entities as done in the code given below.

import ifcopenshell
 
f = ifcopenshell.open("C:\Users\GURBHEJ SINGH\Desktop\IFC\ModelFull.ifc")
f2 = ifcopenshell.file()
 
persons = f.by_type("IFCPERSON")
for person in persons:
    f2.add(person)
 
organizations = f.by_type("IFCORGANIZATION")
for organization in organizations:
    f2.add(organization)
 
personorganizations = f.by_type("IFCPERSONANDORGANIZATION")
for personorganization in personorganizations:
    f2.add(personorganization)
 
f2.write("test222.ifc")
The output of the code was given below which is wrong:-
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T13:41:16',(),(),'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;
The output I want was that their should not be repetition of entities:-
Output:
ISO-10303-21; HEADER; FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1'); FILE_NAME('','2019-04-11T13:41:16',(),(),'IfcOpenShell 0.5.0-dev','IfcOpenShell 0.5.0-dev',''); FILE_SCHEMA(('IFC2X3')); ENDSEC; DATA; #1=IFCPERSON($,$,'',$,$,$,$,$); #2=IFCORGANIZATION($,'',$,$,$); #3=IFCPERSONANDORGANIZATION(#1,#2,$) ENDSEC; END-ISO-10303-21;
Please help me to resolve this issue.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  naming entities(city abbreviations) tirumalaramakrishna 1 1,249 May-06-2022, 11:22 AM
Last Post: jefsummers
  How to couunt extracted values ? Eidrizi 0 1,486 Sep-10-2020, 06:05 AM
Last Post: Eidrizi
  instaloaders problem: search certain hashtag - posts without hashtag extracted ledgreve 0 2,155 Nov-18-2019, 01:22 PM
Last Post: ledgreve
  Seperate entities in text file bigdazza 1 2,835 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