I kept learning as I can all about this C# stuff, not much, but I am, at least trying.... he he
Here is a tryout to convert an attach xref to overlay - without luck of course, it is something I never tried on objectARX by the way... and also, there is no single sample anywhere (I think).
[CommandMethod("ATOVERLAY")]
public void attachTooverlay()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
//PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect Xref: ");
//prOpt.SetRejectMessage("\nNot an Xref!");
//prOpt.AddAllowedClass(typeof(BlockReference), true);
//PromptEntityResult rs = ed.GetEntity(prOpt);
PromptEntityResult res = ed.GetEntity("\nSelect xref: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference blkRef = tr.GetObject(res.ObjectId, OpenMode.ForWrite, false) as BlockReference;
if (blkRef != null)
{
BlockTableRecord blkRec = (BlockTableRecord)tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForWrite);
if (blkRec.IsFromOverlayReference == false)
{
//db.DetachXref(blkRec.ObjectId);
//db.ResolveXrefs(true, true);
string fileName, blockName;
fileName = blkRec.PathName;
blockName = blkRec.Name;
ed.WriteMessage("\nPath: " + fileName);
ed.WriteMessage("\nBlockname: " + blockName);
ObjectId xrefId = db.OverlayXref(fileName, blockName);
if (xrefId.IsValid == true)
ed.WriteMessage("\nIs a valid object id...");
else
ed.WriteMessage("\nNo valid object id...");
db.ResolveXrefs(true, true);
}
}
tr.Commit();
}
}
Since the OverlayXref() returns an ID.... what I should do with it? or to make it work.... I tried first to detach the xref (it does that) but when I try to tun the overlay part... nothing.... nada.... niep.... nil
Thanks!