.NET

Reply
Valued Contributor
netcai
Posts: 66
Registered: ‎07-22-2004
Message 11 of 13 (82 Views)

Re: AttachExternalReference problem

06-15-2005 03:01 AM in reply to: netcai
I tried another mothod ,and it work fine,so I think it's a bug in objectdbx.
by the way ,could someone know how to attach external reference with arx, and how to close a docment with arx.

the following is my modified codes ,it works fine.


private static void CreateRefDrawing(string subFolder)
{
string[] fileNames = new string[] { "Ref_S_Plan", "Ref_S_Beam", "Ref_S_Foot" };

AxDbDocumentClass axdoc = new AxDbDocumentClass();
string newName = subFolder + "\\" + fileNames[0] + ".dwg";
axdoc.SaveAs(newName, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(axdoc);

AxDbDocumentClass axdoc1 = new AxDbDocumentClass();
string newName1 = subFolder + "\\" + fileNames[1] + ".dwg";
axdoc1.SaveAs(newName1, null);
//System.Runtime.InteropServices.Marshal.ReleaseComObject(axdoc);

AxDbDocumentClass axdoc2 = new AxDbDocumentClass();
string newName2 = subFolder + "\\" + fileNames[2] + ".dwg";
axdoc2.SaveAs(newName2, null);


double[] insertPnt = new double[] { 0, 0, 0 };
double scale = 1;
double rotation = 0;
bool bOverlay = false;

try
{
//// the following comment line will cause a fatal error

//Database curdb = HostApplicationServices.WorkingDatabase;
//Database db = Database.FromAcadDatabase(axdoc1.Database);
//HostApplicationServices.WorkingDatabase = db;
//axdoc1.ModelSpace.AttachExternalReference(newName, fileNames[0], insertPnt, scale, scale, scale, rotation, bOverlay, null);
//axdoc1.SaveAs(newName1, null);
//HostApplicationServices.WorkingDatabase = curdb;

string refName = ".\\" + fileNames[0] + ".dwg";
AcadDocument doc1 = ActiveX.AcadApp.Documents.Open(newName1, false, null);
doc1.ModelSpace.AttachExternalReference(refName, fileNames[0], insertPnt, scale, scale, scale, rotation, bOverlay, null);
doc1.Close(true, newName1);

AcadDocument doc2 = ActiveX.AcadApp.Documents.Open(newName2, false, null);
doc2.ModelSpace.AttachExternalReference(refName, fileNames[0], insertPnt, scale, scale, scale, rotation, bOverlay, null);
doc2.Close(true, newName2);
}
catch { }

}
Valued Contributor
netcai
Posts: 66
Registered: ‎07-22-2004
Message 12 of 13 (82 Views)

Re: AttachExternalReference problem

06-21-2005 05:29 PM in reply to: netcai
Is my judgement correct? has External reference a bug in objectdbx?
*Albert Szilvasy
Message 13 of 13 (82 Views)

Re: AttachExternalReference problem

06-21-2005 05:45 PM in reply to: netcai
This was logged in our bug tracking database. Nobody looked into it yet so I
can't confirm or deny. It looks suspeciously like a bug.

Albert

wrote in message news:4881355@discussion.autodesk.com...
Is my judgement correct? has External reference a bug in objectdbx?
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.