V
by valgianf on 14 Mar 2024, edited 20 Mar 2024
#
Hi everyone,
I've coded a script that generates an IFC model but I think that the IFC in the output is wrong because it doesn't classify the elements. For example, I have a series of elements typed as IfcCivilElementType but when I parse the file I have this "No stream support: No module named 'lark'", but being new in this kind of stuff I have no idea what it means. Furthermore, I have no elements classified when I read IFC with IFC viewer. I have attached my script to this discussion. Thank you in advance to everyone who will be able to help me. Cheers!
PS: STL file needed to run the script is attached in .txt as stl.txt
A
by Andrej730 on 15 Mar 2024
#
Hi! Can you please narrow down the issue in your script so it will be easier to help? Currently it's 1.4k lines of code.
V
by valgianf on 15 Mar 2024
#
You're right, the script works but I think that there is a problem in the BIM part because the IFC comes out is not good (the IFC viewer doesn't recognize the different IFC type in the model). Just to figure out, the problem would be from line 628 to the end leaving out the saving part. Thank you!
A
by Andrej730 on 15 Mar 2024, edited 15 Mar 2024
#
It's still 0.8k lines of code... Can you please create simple script to reproduce the issue?
V
by valgianf on 15 Mar 2024
#
Well, I've just made up a simpler Python script. As I explained for the other script, the problem is that the IFC viewer doesn't see the properties of the structure underneath the accropode because in my opinion the IFC is not written correctly. Thank you!
B
by bruno_perdigao on 15 Mar 2024
#
+1 votes
It seems to me that you tried to write the properties yourself instead of using the blenderbim and ifcopenshell modules. Any reasons why you did this way?
V
by valgianf on 16 Mar 2024
#
@bruno_perdigao Yes, I did. I'd need to write elements custom properties via Python script and I don't know if it is the right way to do this. It is the only reason. If you have some pieces of advice I'd be very happy to follow them. Thank you for your feedback!
B
by bruno_perdigao on 16 Mar 2024, edited 6 Jun 2024
#
+2 votes
I don't have experience in creating an IFC file from scratch, so I don't know what would be the best practice here. But I suggest that you take a look at this section (https://docs.blenderbim.org/devs/hello_world.html) from the BlenderBIM documentation. It's aimed to development, but it will help you understand how the code generally works and how you can use ifcopenshell and blenderbim functions inside Blender. There is also this introduction to ifcopenshell: https://docs.ifcopenshell.org/ifcopenshell-python/hello_world.html
For more advanced stuff: https://github.com/cvillagrasa/IfcOpenHouse/blob/master/nbs/00_generation.ipynb
In your code, for example, you tried to update the author name by using bpy.context.scene.BIMProjectProperties.author_name
which only updates this property inside blender, not in the IFC file. If you want to edit the author name inside blender using a script, you would have to load the ifc file to the code:
from blenderbim.bim.ifc import IfcStore
ifc_file = IfcStore.get_file()
ifc_file.wrapped_data.header.file_name.author = ("Author Name", "author@email.com")
Maybe there are other ways, but I think this is the general problem of your code, sometimes you're not editing the IFC, just the Blender file. So all the data is not being saved as IFC.
A
by Andrej730 on 18 Mar 2024
#
@valgianf said:
Well, I've just made up a simpler Python script. As I explained for the other script, the problem is that the IFC viewer doesn't see the properties of the structure underneath the accropode because in my opinion the IFC is not written correctly. Thank you!
I tried to run simplified version and it seems to work fine.
After running the script:

After reopening created file in BBIM:

Opening created file in Open IFC Viewer:

but I think that the IFC in the output is wrong because it doesn't classify the elements
Furthermore, I have no elements classified when I read IFC with IFC viewer
Can you please show some examples what is missing?
V
by valgianf on 19 Mar 2024
#
@Andrej730 In the case of the complex script when I open the IFC with Open IFC Viewer misses all the elements underneath the accropodes. Just to figure out, The elements are visualized but they don't appear in the project tree on the left side
A
by Andrej730 on 19 Mar 2024
#
+1 votes
@valgianf said:
@Andrej730 In the case of the complex script when I open the IFC with Open IFC Viewer misses all the elements underneath the accropodes. Just to figure out, The elements are visualized but they don't appear in the project tree on the left side
The missing object "IfcCivilElement/Cons" is. I guess it's missing because it's assigned to IfcProject directly and not to IfcSite/IfcBuilding etc. You can add this object to one of those collections in your script before saving .ifc file and object will appear in IFC Viewer.
V
by valgianf on 20 Mar 2024
#
Perfect, it works! Thank you so much