Here is one that will work if it does / doesn't have an xclip already.
[CommandMethod( "TestCopyXClip" )]
public void TestCopyXClip() {
PromptEntityResult per;
ObjectId tempId;
DBDictionary nFltDict;
Document Doc = acadApp.DocumentManager.MdiActiveDocument;
Database Db = Doc.Database;
Editor Ed = Doc.Editor;
using ( Transaction Trans = Db.TransactionManager.StartTransaction() ) {
per = Ed.GetEntity( "\n Select xref to copy xclip from: " );
Entity FromEnt = Trans.GetObject( per.ObjectId, OpenMode.ForRead ) as Entity;
per = Ed.GetEntity( "\n Select xref to copy xclip to: " );
Entity ToEnt = Trans.GetObject( per.ObjectId, OpenMode.ForRead ) as Entity;
DBDictionary xDictFrom = Trans.GetObject( FromEnt.ExtensionDictionary, OpenMode.ForRead ) as DBDictionary;
tempId = xDictFrom.GetAt( "ACAD_FILTER" );
DBDictionary FltDict = Trans.GetObject( tempId, OpenMode.ForRead ) as DBDictionary;
tempId = FltDict.GetAt( "SPATIAL" );
SpatialFilter SptFlt = Trans.GetObject( tempId, OpenMode.ForRead ) as SpatialFilter;
if ( ToEnt.ExtensionDictionary == ObjectId.Null ) {
ToEnt.UpgradeOpen();
ToEnt.CreateExtensionDictionary();
ToEnt.DowngradeOpen();
}
DBDictionary xDictTo = Trans.GetObject( ToEnt.ExtensionDictionary, OpenMode.ForRead ) as DBDictionary;
if ( xDictTo.Contains( "ACAD_FILTER" ) ) {
tempId = xDictTo.GetAt( "ACAD_FILTER" );
nFltDict = Trans.GetObject( tempId, OpenMode.ForWrite ) as DBDictionary;
if ( nFltDict.Contains( "SPATIAL" ) )
nFltDict.Remove( "SPATIAL" );
SpatialFilter nSptFlt = SptFlt.DeepClone( nFltDict, new IdMapping(), true ) as SpatialFilter;
nFltDict.SetAt( "SPATIAL", nSptFlt );
Trans.AddNewlyCreatedDBObject( nSptFlt, true );
}
else {
xDictTo.UpgradeOpen();
nFltDict = FltDict.DeepClone( xDictTo, new IdMapping(), true ) as DBDictionary;
xDictTo.SetAt( "ACAD_FILTER", nFltDict );
Trans.AddNewlyCreatedDBObject( nFltDict, true );
}
Db.ResolveXrefs( true, true );
//Ed.Regen();
Trans.Commit();
}
}