View Full Version : Edit the reference name for a Xref via ObjectARX
abhitkg
2006-08-02, 12:52 PM
Hi,
If you open xref manager you can edit the reference name for xref. I want to do the same thing programatically using ObjectARX. Can anyone tell me how to do this?
Thanks,
Abhilash
rkmcswain
2006-08-02, 01:02 PM
You might want to ask in the Autodesk ObjectARX discussion group:
NNTP: news://discussion.autodesk.com/autodesk.autocad.objectarx
HTTP: http://discussion.autodesk.com/forum.jspa?forumID=34
Mike.Perry
2006-08-03, 12:00 AM
Hi Abhilash
Please note I have *moved* this thread from the AutoCAD 2007 General (http://forums.augi.com/forumdisplay.php?f=342) forum to this one, as I feel this particular forum is a more appropriate place for such a topic.
Thanks, Mike
Forum Manager
ivan.markov
2007-06-06, 04:53 PM
Hi Abhilash
I think I have solution to your question. Recently I had to change Xrefs in a dwg using objectARX. I will post some code below, and hopefully that will help you.
Database db = new Database();
XrefGraph Xref = null;
XrefGraphNode XrefNode = null;
Transaction trans=null;
BlockTable Btable = null;
BlockTableRecord BTrecord = null;
try
{
db.ReadDwgFile(file.FullName, FileShare.Read, false, "");
Xref = db.GetHostDwgXrefGraph(true);
for (int k = 1; k < Xref.NumNodes; k++)//i starts from 1 because the drawing is always counted as the first reference
{
XrefNode = Xref.GetXrefNode(k);
trans = db.TransactionManager.StartTransaction();
Btable = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BTrecord = (BlockTableRecord)trans.GetObject(Btable[XrefNode.Name], OpenMode.ForWrite);
BTrecord.Name="Assign the new name for the Xref here";
//or if you want to look for a specific reference to update
//you can you can use an if statement around the previous assignment.
trans.Commit();
trans.Dispose();
}
db.SaveAs("file destination to save",null);
}
finally
{
db.CloseInput(true);
}
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.