.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VB.NET Xref help?

0 REPLIES 0
Reply
Message 1 of 1
michael.coffman
775 Views, 0 Replies

VB.NET Xref help?

I'm working on a vb.net routine that is supposed to attach an xref to a drawing file that is not open in the editor. I have a series of drawings that I want to xref a title block into and I don't want to have to open each file within the editor. I've attached the code I have thus far below. The issue I'm having is that when I get to the myDB.AttachXref(FromFile, "") line I get an eFileAccessErr exception. I've tried a few different things but no luck yet. Any help would be greatly appreciated!

Sincerely,
Michael Coffman

[code] Public Sub XrefInsertion(ByVal FromFile As String, ByVal ToFile As String, ByVal xrefName As String) If IO.File.Exists(FromFile) Then If IO.File.Exists(ToFile) Then 'Access the current drawing interface Dim myDB As New DatabaseServices.Database myDB.ReadDwgFile(ToFile, FileOpenMode.OpenForReadAndWriteNoShare, True, "") 'Create transaction within current drawing Dim myTransMan As DatabaseServices.TransactionManager = myDB.TransactionManager Dim myTrans As DatabaseServices.Transaction = myTransMan.StartTransaction Dim xrefObj As ObjectId = myDB.AttachXref(FromFile, "") Dim bt As BlockTable = myTrans.GetObject(myDB.BlockTableId, OpenMode.ForRead, False) Dim btr As BlockTableRecord = CType(myTrans.GetObject(xrefObj, OpenMode.ForWrite), BlockTableRecord) Dim PaperSpace As BlockTableRecord = myTrans.GetObject(myDB.CurrentSpaceId, OpenMode.ForWrite) Dim br As BlockReference = New BlockReference(New Point3d(0, 0, 0), xrefObj) PaperSpace.AppendEntity(br) myTrans.AddNewlyCreatedDBObject(br, True) myTrans.Commit() myTrans.Dispose() myDB.CloseInput(True) myDB = Nothing Else MessageBox.Show(ToFile & " does not exist", "Missing File", MessageBoxButtons.OK, MessageBoxIcon.Information) End If Else MessageBox.Show(FromFile & " does not exist", "Missing File", MessageBoxButtons.OK, MessageBoxIcon.Information) End If End Sub [/code]
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost