Apr-11-2019, 12:04 PM
(Apr-11-2019, 09:42 AM)Larz60+ Wrote: As micseydel stated earlier:I apologise. I am explaining the new problem which I have faced.
Quote:You're far less likely to get a reply if people have to go off-site.
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.