代码
/// <summary>
/// 移除实体应用程序名(xdata) houlinbo QQ420021327
/// 移除实体应用程序名(xdata) houlinbo QQ420021327
/// </summary>
/// <param name="Objid"></param>
/// <param name="sAppName"></param>
public void RemoveAppName(Database db, ObjectId objId, string sAppName)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBObject obj = tr.GetObject(objId, OpenMode.ForWrite);
ResultBuffer rb = obj.XData;
if (rb != null)
{
TypedValue[] values = rb.AsArray();
for (int i = 0; i < values.Length; i++)
{
if (values[i].TypeCode ==
(int)DxfCode.ExtendedDataRegAppName && values[i].Value.ToString() ==
sAppName)
{
//移除之
TypedValue[] values_New ={ new TypedValue((int)DxfCode.ExtendedDataRegAppName, values[i].Value.ToString()) };
ResultBuffer rb_New = new ResultBuffer(values_New);
obj.UpgradeOpen();
obj.XData = rb_New;
obj.DowngradeOpen();
}
}
}
tr.Commit();
}
}
/// <param name="Objid"></param>
/// <param name="sAppName"></param>
public void RemoveAppName(Database db, ObjectId objId, string sAppName)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBObject obj = tr.GetObject(objId, OpenMode.ForWrite);
ResultBuffer rb = obj.XData;
if (rb != null)
{
TypedValue[] values = rb.AsArray();
for (int i = 0; i < values.Length; i++)
{
if (values[i].TypeCode ==
(int)DxfCode.ExtendedDataRegAppName && values[i].Value.ToString() ==
sAppName)
{
//移除之
TypedValue[] values_New ={ new TypedValue((int)DxfCode.ExtendedDataRegAppName, values[i].Value.ToString()) };
ResultBuffer rb_New = new ResultBuffer(values_New);
obj.UpgradeOpen();
obj.XData = rb_New;
obj.DowngradeOpen();
}
}
}
tr.Commit();
}
}