I am using the ezdxf
package to postprocess DXF drawings.
Then, I convert the DXF to a SVG.
During the postprocessing, I need to delete some INSERT entitities that lie outside the drawing area so that the converted SVG has the right dimensions. I am doing something like this :
def dxftype(entity):
notHandled = []
if entity.dxftype() in notHandled:
return None
else:
return entity.dxftype()
def hasToBeDeleted(entity):
"""
Some criteria for deleting an entity
return a Boolean
"""
dwg = ezdxf.readfile("myDxfFile.dxf")
msp = dwg.modelspace()
group = msp.groupby(key=dxftype)
for entityType, entities in group.items():
for e in entities:
if hasToBedeleted(e):
msp.delete_entity(e)
The problem is that then, when converting the entity is not deleted. In fact, if I do another loop of suppression right after this one, the loop still takes the action to delete the entity proving the entity has not really been removed from the modelspace.
What is the correct way to delete an entity from the modelspace in ezdxf then ? I am using version 0.9 at the moment and can't upgrade to a new version right now