Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a simple wall with property set and quantity information | IfcOpenShell Academy #4

Open
IfcOpenBot opened this issue Aug 14, 2021 · 27 comments

Comments

@IfcOpenBot
Copy link

#Creating a simple wall with property set and quantity information | IfcOpenShell Academy

url

@IfcOpenBot
Copy link
Author

Original comment by Omar zerhouni on 2021-01-04 08:12:44


Hi,

I am following the recipe, but getting an error in create_ifclocalplacement part.

Traceback (most recent call last):

File "C:/Users/TOSHIBA/AppData/Roaming/JetBrains/PyCharmCE2020.2/scratches/TestZone.py", line 103, in

site_placement = create_ifclocalplacement(ifcfile)

File "C:/Users/TOSHIBA/AppData/Roaming/JetBrains/PyCharmCE2020.2/scratches/TestZone.py", line 25, in create_ifclocalplacement

axis2placement = create_ifcaxis2placement(ifcfile, point, dir1, dir2)

File "C:/Users/TOSHIBA/AppData/Roaming/JetBrains/PyCharmCE2020.2/scratches/TestZone.py", line 17, in create_ifcaxis2placement

point = ifcfile.createIfcCartesianPoint(point)

File "C:\ProgramData\Anaconda3\envs\EnvPy36\lib\site-packages\ifcopenshell\file.py", line 83, in create_entity

self.wrapped_data.add(e.wrapped_data)

File "C:\ProgramData\Anaconda3\envs\EnvPy36\lib\site-packages\ifcopenshell\ifcopenshell_wrapper.py", line 1478, in add

return _ifcopenshell_wrapper.file_add(self, entity)

TypeError: in method 'file_add', argument 2 of type 'IfcUtil::IfcBaseClass *'

Is the recipe still operating with the new updates ?

@IfcOpenBot
Copy link
Author

Original comment by Mohammad Najjar on 2021-07-01 16:40:19


This looks very interesting. I don't know how far this can go! Will we be able to create a bim creation tool starting from here? obviously we can create levels, wall, windows and maybe slabs. So it worth trying.

@IfcOpenBot
Copy link
Author

Original comment by Mohammad Najjar on 2021-07-01 16:40:19


This looks very interesting. I don't know how far this can go! Will we be able to create a bim creation tool starting from here? obviously we can create levels, wall, windows and maybe slabs. So it worth trying.

Original comment by thomas on 2021-08-07 12:49:18


Be sure to have a look at https://blenderbim.org/

Copy link

When I run the file, I get this error at this line -

 f.write(template)
TypeError: a bytes-like object is required, not 'str'

How do I get rid of this error?

Copy link
Member

aothms commented Jun 22, 2022

@keshavanarayan

Change open(temp_filename, "wb") into open(temp_filename, "w") to open the file in text mode.

Since this tutorial has been written there is also ifcopenshell.template.create() which does more or less the same without the temporary file. https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/template.py

Copy link

Hi @aothms,

Thank you for your insights.
I have one more question.
How to convert an existing mesh(say like an .obj file) into an IFCFURNISHINGELEMENT type using Ifcopenshell?

@Moult
Copy link

Moult commented Jun 23, 2022

@keshavanarayan this might help: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/blenderbim/scripts/obj2ifc.py

@aothms
Copy link
Member

aothms commented Jun 23, 2022

There is also ifcopenshell.geom.serialize() and ifcopenshell.geom.tesselate() that work based on the input of a Open Cascade shape. If you're reading mesh data from OBJ it's indeed more efficient to bypass opencascade and write as a IFC faceset directly as suggested by @Moult

Copy link

Hi @aothms @Moult,

Thank you so much for your help. I created an IFC wall file following this tutorial using my own inputs, I am getting the .IFC file and the python is also not showing errors. However, I am unable to open the ifc file. I have uploaded the python files I have used and a visual explanation of what I have done in the readme file. Please let me know of what mistake I am doing when you're free.

https://github.com/keshavanarayan/ifcwall-test/tree/main

@aothms
Copy link
Member

aothms commented Jun 23, 2022

@keshavanarayan you don't actually assign the wall to the building storey (IfcRelContainedInSpatialStructure) some viewers only show elements that are part of the spatial structure.

Copy link

Hi @aothms,

Thank you so much. :)
So for creating slabs replacing this function [ifcfile.createIfcWallStandardCase()] with [ifcfile.createIfcSlab()] helps? Is there any documentation that I can read on creating slabs, columns, etc in a similar manner?

Copy link

Hi @aothms,

I tried to create a custom wall mesh inspired by the obj2ifc.py file. On running the file I get this error as shown below. I have put my python file in this github repo for your reference.

https://github.com/keshavanarayan/ifcwall-test/tree/main

File "d:/00PortFolio/IFC/TOSEND_testwall/ifcwall-test/mesh2ifc.py", line 109, in <module>
    [file.createIfcCartesianPoint(vertices[index]) for index in face]
  File "d:/00PortFolio/IFC/TOSEND_testwall/ifcwall-test/mesh2ifc.py", line 109, in <listcomp>
    [file.createIfcCartesianPoint(vertices[index]) for index in face]
  File "C:\Users\kesha\AppData\Local\Programs\Python\Python38\lib\site-packages\ifcopenshell\file.py", line 276, in create_entity
    e[idx] = arg
  File "C:\Users\kesha\AppData\Local\Programs\Python\Python38\lib\site-packages\ifcopenshell\entity_instance.py", line 196, in __setitem__
    self.method_list[idx](self.wrapped_data, idx, entity_instance.unwrap_value(value))
  File "C:\Users\kesha\AppData\Local\Programs\Python\Python38\lib\site-packages\ifcopenshell\ifcopenshell_wrapper.py", line 4857, in setArgumentAsAggregateOfDouble
    return _ifcopenshell_wrapper.entity_instance_setArgumentAsAggregateOfDouble(self, i, v)
TypeError: Attribute of type AGGREGATE OF REAL needs a python sequence of floats

@aothms
Copy link
Member

aothms commented Jul 3, 2022

@keshavanarayan

If vertices[index] is a numpy float then ifcopenshell will not recognize it.

Try:

tuple(map(float, vertices[index])) to convert to a tuple of python floats.

Copy link

Hi,

Thanks for this nice tutorial to teach IFC.
I have tried code on Fedora 37 using Python 11 but when executing 'container_project = ifcfile.createIfcRelAggregates(create_guid(), owner_history, "Project Container", None, project, [site])' line I get a segfault.
I get also a segfault when reproducing in Github gitpod after a 'pip install ifcopenshell'.

I'm single to have a such segfault?

See https://github.com/EstebanDugueperoux2/ifc-test to reproduce.

Regards.

@aothms
Copy link
Member

aothms commented Jan 28, 2023

@EstebanDugueperoux2 I can't reproduce that. Can you try with the latest version here IfcOpenBot/IfcOpenShell@07ee62e#comments Otherwise open a bug at https://github.com/IfcOpenShell/IfcOpenShell/issues

Copy link

keshavanarayan commented Apr 2, 2023

Hi @aothms,
Does the variable point_list_extrusion_area represent the rectangle shown?
Are the coordinates mentioned in point_list_extrusion_area represent the coordinates respect to the global (0,0,0) or is it relative to the coordinates in the ifc_polyline?

The reason why I ask this is to create walls in any orinetation in plan and it does not make sense to hard code coordinates in the python file.
So the best way as I understand is to create all walls along the positive x-direction and orient the walls along the orientation required using a transformation and this is exactly where I am stuck.

Or editing the ifcaxis2placement should give the desirable outcome?

I think more explanation is needed for the ifcaxis2placement function in ifcopenshell.

Can the tutorial for this also be added to this simple wall? I hope that this will be useful for others as well.

!(https://www.dropbox.com/s/qtlhxe4xfbfhblf/base.png?dl=0)

@aothms
Copy link
Member

aothms commented Apr 8, 2023

afbeelding

Does the variable point_list_extrusion_area represent the rectangle shown?

point_list_extrusion_area = [(0.0, -0.1, 0.0), (5.0, -0.1, 0.0), (5.0, 0.1, 0.0), (0.0, 0.1, 0.0), (0.0, -0.1, 0.0)]

Yes, an IfcRectangleProfileDef could also have been used in this case. If you look at the coords, you see {0 ; 5.0} for X and {-0.1 ; 0.1} for Y. This is the idiomatic way to build a wall prism in IFC, the local direction should follow X.

Are the coordinates mentioned in point_list_extrusion_area represent the coordinates respect to the global (0,0,0) or is it relative to the coordinates in the ifc_polyline?

There are various placements involved. The IfcExtrudedAreaSolid has a placement itself and also the IfcWall.ObjectPlacement is a recursive placement. Both affect the eventual world coordinates of the polyline points.

The reason why I ask this is to create walls in any orinetation in plan and it does not make sense to hard code coordinates in the python file.

Exactly. But these days there have also been massive efforts on a high level API that does make more sense. See https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/api/geometry/add_axis_representation.py

@keshavanarayan
Copy link

Hi @aothms ,

Thank you so much for the detailed answer. How do I add color to this wall based on a material?
I am aware that an 'IfcColor' type exists, but if you can share a code snipper in the context of this wall, it would be great.

Thank you so much.

@aothms
Copy link
Member

aothms commented Apr 14, 2023

@keshavanarayan have a look at this API call:

https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/api/style/assign_material_style.py

Essentially you'd be building this structure:

IfcMaterial <- IfcMaterialDefinitionRepresentation -> IfcStyledRepresentation -> IfcStyledItem

@fdh-fdh
Copy link

fdh-fdh commented Sep 13, 2023

https://blenderbim.org/

Original comment by Mohammad Najjar on 2021-07-01 16:40:19

This looks very interesting. I don't know how far this can go! Will we be able to create a bim creation tool starting from here? obviously we can create levels, wall, windows and maybe slabs. So it worth trying.

Hii, there,
Are there any solutions without using blender add on ? only for using IFCOpenshell in python ?
or are there any update on solving this problem about
TypeError: in method 'entity_instance_setArgumentAsEntityInstance', argument 3 of type 'IfcUtil::IfcBaseClass *
i am currently tryting to create a void element on a existing IfcWall element, and i got this error while using createIfcLocalPlacement to creating a opeing placement related to wall placement generated by
wall_placement = numpy.asarray(ifcopenshell.util.placement.get_local_placement(containing_wall.ObjectPlacement)[:,3][:3])

Copy link

tomito6 commented Feb 5, 2024

Does someone know where the ifcfile.createIfcBuilding() method comes from? I cannot find it

@aothms
Copy link
Member

aothms commented Feb 5, 2024

@tomito6 ifcopenshell.file has a magic method getattr which uses the current associated schema at runtime. Therefore, for example for IFC4X3_ADD2 it means you can use the following entity names https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/annex-b1.html and type names https://ifc43-docs.standards.buildingsmart.org/IFC/RELEASE/IFC4x3/HTML/annex-b2.html

@Moult
Copy link

Moult commented Mar 17, 2024

@Moult
Copy link

Moult commented Mar 18, 2024

@yashreadytobox does the sample code work for you in the docs? If so, it must be an issue with your code. At a glance I don't see any errors in your code but you have debug print statements and can you check data types (e.g the error message seems to expect a sequence of ints presumably for the triangle indices).

@Moult
Copy link

Moult commented Mar 19, 2024

File "C:\instance_env\lib\site-packages\ifcopenshell\api\geometry\assign_representation.py", line 31, in execute
if self.settings["product"].is_a("IfcProduct"):

This suggests that you are not passing in the product kwarg properly. Are you sure element is an entity_instance? The error suggests it is an int.

@aothms
Copy link
Member

aothms commented Mar 26, 2024

That's odd. I don't have an explanation for this. The error happens during shutdown of the interpreter, somehow the cleanup order is affected that instances are still being deleted, but the ifcopenshell_wrapper module itself is already being destructed. The error seems to be relatively harmless because it only happens at the finalization time.

File "C:\IFCenv\lib\site-packages\ifcopenshell\ifcopenshell_wrapper.py", line 4826, in

line 4826 is in the generated swig code:

    __setattr__ = lambda self, name, value: _swig_setattr(self, entity_instance, name, value)

The NoneType object is not callable, probably refers to _swig_setattr.

I'm glad you found a workaround. If you manage to discover more information regarding this then let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants