Hi,
>> I am not sure about the difference between deleting only the text from the dwg and deleting object-data-record.
The OD-record is not the same as a record in the database and it can't exist without an entity that has the record assigned.
So if you delete the OD-record, the Map-ObjectData is removed from the geometry-object.
If you delete the DBText from the drawing then the OD-record is gone also (as it can't exist without an object it's assigned to)
>> Deleting only the text - does that mean the text would disapear from the dwg
>> but if I click on the properties window for the text, the text would still appear
>> on the properties window?
Now we have to make sure what wording is used (soory I'm not english-native speaking)
One is the geomtry-object TEXT (or DatabaseServices.DBText), if you delete it (command _ERASE and click onto the object) then it's gone from the drawing.
The other option is the content if the text-object (the string). If you select the text-object and remove the characters from the content of the geometry object ==> then yes, the geometry object stays in the drawing, but it's not visible (as there are no more characters to be displayed) and so it's also not selectable. And to be honest: this would be the worst way to remove text from a drawing, because the drawing-size is high even if you don't see any objects. I would suggest never to use this way.
I hope that makes it clear now (and I have described it in a readable way).
You have now four options (imho):
1)
- when selecting the polyline, read it's content from the OD-record to get the ID, then erase the polyline
- from the OD-record you can get the string to search a textobject that has this id (last characters)
- search for the text and erase it from the database
2)
- when selecting the polyline, read it's content from the OD-record to get the ID, then erase the polyline
- scan through all elements having OD-records from the same table assigned
- if the scaned object is of type text and the ID is the same as that from the erase poly ==> erase the text and end the loop
3)
- when selecting the polyline get it's extents
- scan through all text-objects on that layer and verify if the extents of the text is inside the extents of the erased poly
- if so erase the text-object and exit the loop
4)
- when selecting the polyline get it's extents
- zoom to the extents (and then ZOOM 0.8xp)
- create a selectionset with Window (or WindowPolygon) and use the extents (or the vertices of the poly) + a filter for text-objects on that specific layer (if the layer is constant)
- if found (and only one found) then erase the object otherwise report an error
1) is a stable way and should be quite fast/needs Map to work
2) is a stable way, not so fast as you have to scan for objects having the correct ID in the OD-records/needs Map to work
3) is critical as it might find other text-objects then. Ff the structure is as clear as your sample drawing, than no problem, but if there are more textobjects within this polyline, and maybe on the same layer, it could get problematic. But it does not need Map (if that is an advantage).
4) same critical as 3 + you have to make sure that the text-objects is on screen before creating a selection. That may sound slower first. But if you erase the polyline by manual selection then you don't need the zoom as you are alread there. Depends on the needs. Needs no Map.
HTH, - alfred -
------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ...
blog.ish-solutions.at ...
LinkedIn ...
CDay 2026------------------------------------------------------------------------------------
(not an Autodesk consultant)