Code Red > .NET

Xref dialog not updating when attaching an xref

(1/2) > >>

Chumplybum:
hey,

I have created a routine that attaches a dwg to the current working database or a database which has not been opened.
The problem i'm having is, when i attach a dwg to the current working database, the file attaches fine (and shows up in the ClasssicXref command) but the xref palette does not update.  This is not the case when i attach a drawing to an un opened drawing and open it manually. The xref displays fine in the palette.

I'm guessing there is some type of event or flag that fires when you open a drawing to populate the xrefgraph.
Does anyone know what this is or how to make the newly attached xref show up in the xref palette???

Thanks in advance

cheers

Ben

Glenn R:
Database.ResolveXrefs(false, true); perhaps...?

Chumplybum:
thanks glen, already tried that but it doesn't seem to work... i think i need to raise an event (i think its the XrefAttachEnded event), but from what i can tell, i can't raise events that are declared in another class, i'm pretty new to events (and delegates) so i don't fully understand how to get them to work.

and after looking a bit deeper into the acadmgd.dll i found a few subs and functions that should do the trick,
Autodesk.autocad.databaseservices.CmgdDatabaseEventImpl.FireXrefAttachEnded...
Or
DatabaseServices.Database.XrefAttachEnded (Event)

but they're all friend classes and hence, i can't get access to them either.


thanks again, looks like i'll be doing plenty of reading on events :-/

mohnston:

--- Quote from: Chumplybum on April 03, 2007, 06:46:42 PM ---thanks glen, already tried that but it doesn't seem to work... i think i need to raise an event (i think its the XrefAttachEnded event), but from what i can tell, i can't raise events that are declared in another class, i'm pretty new to events (and delegates) so i don't fully understand how to get them to work.

and after looking a bit deeper into the acadmgd.dll i found a few subs and functions that should do the trick,
Autodesk.autocad.databaseservices.CmgdDatabaseEventImpl.FireXrefAttachEnded...
Or
DatabaseServices.Database.XrefAttachEnded (Event)

but they're all friend classes and hence, i can't get access to them either.


thanks again, looks like i'll be doing plenty of reading on events :-/


--- End quote ---

I have the exact same problem. Have you made any progress?
I found this in the arx docs.

--- Quote ---External references (xrefs) can be created and manipulated through several global functions. These global functions mimic the AutoCAD XREF command capabilities. The functions provided are

acedXrefAttach()
acedXrefOverlay()
acedXrefUnload()
acedXrefDetach()
acedXrefResolve()
acedXrefBind()
acedXrefXBind()
acedXrefCreateBlockname()
acedXrefReload()
For information on the AutoCAD XREF command, see the AutoCAD User's Guide.

The main programming consideration concerning xrefs is that, for every xref that is attached to a drawing, a separate database is created to represent the drawing containing the xref. A block table record in the main drawing contains the name of the external drawing and points to the entities of the model space of the externally referenced drawing. The xref database also contains other block table records and symbol table entries required to resolve all references from the main block table record (layers, linetypes, and so on).

--- End quote ---

The global functions in c++ may work (I have no way of knowing) but the closest thing in managed code I could find is the XrefOperation enum which is part of DatabaseServices.


mohnston:

--- Quote from: Glenn R on April 02, 2007, 08:47:25 PM ---Database.ResolveXrefs(false, true); perhaps...?

--- End quote ---
Thanks for the suggestion. Tried it. Still not in xref palette.
Interesting, it works just fine. Behaves like an xref should.
When I examine xrefs using the -xref command it is listed as an attach type xref.
Could it be that it's just the palette that doesn't recognize it?

Another thing that bothers me is that AttachXref method returns an ObjectID but I don't see where any entity gets added to the blocktablerecord.
On the other hand when you insert an instance of the xref (as a blockreference) that entity is added to the blocktablerecord.
Xrefs have a definition like blockrefs do.
It is the xref definition that isn't showing up in the palette. Maybe I need to save or record the definition in some other way.


--- Code: ---Autodesk.AutoCAD.ApplicationServices.Document doc = acadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
ObjectId oid = ObjectId.Null;
ObjectId bid = ObjectId.Null;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
    using (DocumentLock dlock = doc.LockDocument())
    {
        try
        {
           oid = db.AttachXref(finFile, "Finishes");
           BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
           //BlockTableRecord xbt = (BlockTableRecord)trans.GetObject(oid, OpenMode.ForRead);
           //Database xdb = xbt.GetXrefDatabase(true);
           BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
           BlockReference bref = new BlockReference(new Autodesk.AutoCAD.Geometry.Point3d(1046, 0, 0), oid);
           bid = btr.AppendEntity(bref);
           trans.AddNewlyCreatedDBObject(bref, true);
           trans.Commit();
           db.ResolveXrefs(false, true);
        }
        catch { }
     }
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version