Code Red > .NET
how to delete xdata?
itcad:
hi:
please tell me how to delete xdata?
Keith™:
Not sure about in .net, but the process is pretty simple ... I do the same think in lisp very easily .. perhaps this code will give you some insight.
--- Code: ---(defun c:delxd (/ ent elist)
(setq ent (car (entsel)))
(setq elist (entget ent))
(entdel ent)
(entmake elist)
)
--- End code ---
The process is simple ... grab the entity and store the entity data in a variable, but don't store the XDATA, then delete the original object and recreate the object using the saved data.
Chuck Gabriel:
In VBA (and probably .NET as well) the method is to overwrite the xdata for the desired regapp name with a list that consists of nothing but the regapp info.
--- Code: ---Sub eraseXdata(ByRef ent As AcadEntity, ByRef regAppName As String)
Dim xDataType(0) As Integer
Dim xDataValue(0) As Variant
xDataType(0) = 1001
xDataValue(0) = regAppName
ent.SetXData xDataType, xDataValue
End Sub
--- End code ---
Roughly equivalent C# code:
--- Code: ---void eraseXdata(DBObject obj, string regAppName)
{
obj.XData = new ResultBuffer(new TypedValue((int)DxfCode.ExtendedDataRegAppName, regAppName));
}
--- End code ---
TonyT:
You might want to rethink your approach to deleting xdata.
(entmake) and (entget) do not have compatible argument/result
lists. Worse, you would also be trashing any references to the object
(e.g., draworder, field references and so on) not to mention its
extension dictionary.
--- Quote from: Keith™ on June 22, 2007, 03:01:58 PM ---Not sure about in .net, but the process is pretty simple ... I do the same think in lisp very easily .. perhaps this code will give you some insight.
--- Code: ---(defun c:delxd (/ ent elist)
(setq ent (car (entsel)))
(setq elist (entget ent))
(entdel ent)
(entmake elist)
)
--- End code ---
The process is simple ... grab the entity and store the entity data in a variable, but don't store the XDATA, then delete the original object and recreate the object using the saved data.
--- End quote ---
Kerry:
--- Quote from: TonyT on June 22, 2007, 05:25:04 PM ---............. Worse, you would also be trashing any references to the object
(e.g., draworder, field references and so on) not to mention its
extension dictionary.
--- Quote from: Keith™ on June 22, 2007, 03:01:58 PM ---
The process is simple ...
--- End quote ---
--- End quote ---
Yep, it's frustrating to find that "someones" code has wiped out your data ...
Navigation
[0] Message Index
[#] Next page
Go to full version