Skip to content

[ifcopenshell-python] file.remove() on rooted elem without globalid gives error message #2796

@Martin15135215

Description

@Martin15135215

to reproduce use this code:

import ifcopenshell

ifc = ifcopenshell.file(schema='IFC4')

wall = ifc.createIfcWall()

print("Wall is here")
print(wall)


print("Wall is deleted")
ifc.remove(wall)

print("Wall should be deleted")
print(wall)
print("Is it?")

and the error traceback was:

Wall is here
#1=IfcWall($,$,$,$,$,$,$,$,$)
Wall is deleted
Traceback (most recent call last):
  File "C:\Users\martin\remove_test\remove_test.py", line 19, in <module>
    ifc.remove(wall)
  File "C:\Users\martin\Documents\miniforge\envs\ifcopenshell\Lib\site-packages\ifcopenshell\file.py", line 428, in remove
    return self.wrapped_data.remove(inst.wrapped_data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\martin\Documents\miniforge\envs\ifcopenshell\Lib\site-packages\ifcopenshell\ifcopenshell_wrapper.py", line 4497, in remove
    return _ifcopenshell_wrapper.file_remove(self, entity)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Invalid cast

i found the remove method in the doc, see https://blenderbim.org/docs-python/ifcopenshell-python/hello_world.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions