Message 1 of 14
Not applicable
05-25-2012
06:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been trying to figure this out for a while and I just can't pin point why I get a fatal exception when running this code (see code below).
I have done this same code (for the mose part) to import pagesetups into the active document and it works fine. however when I run it as it is here to import the page setups into other drawings it seems to always crash autocad.
please help!!!!
Code:
Private Sub copy_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles copy.Click
Dim psdb As New Database(False, True)
psdb.ReadDwgFile("M:\CAD Management\CAD Files\Template\Basic.dwt", FileOpenMode.OpenForReadAndReadShare, True, "")
For Each item In ListBox1.Items
Dim db As New Database(True, False)
db.ReadDwgFile(item.ToString, FileOpenMode.OpenForReadAndAllShare, False, "")
Using trans As Transaction = psdb.TransactionManager.StartTransaction
Using trns As Transaction = db.TransactionManager.StartTransaction
Dim psd As DBDictionary = trans.GetObject(psdb.PlotSettingsDictionaryId, OpenMode.ForRead)
Dim id As ObjectId
Dim pd As DBDictionary = trns.GetObject(db.PlotSettingsDictionaryId, OpenMode.ForRead)
For Each entry As DBDictionaryEntry In pd
pd.UpgradeOpen()
pd.Remove(entry.Value)
pd.DowngradeOpen()
Next
For Each psent As DBDictionaryEntry In psd
id = psd.GetAt(psent.Key)
Dim ps As PlotSettings = id.GetObject(OpenMode.ForRead)
Dim curps As PlotSettings = New PlotSettings(False)
curps.CopyFrom(ps)
curps.AddToPlotSettingsDictionary(db)
curps.DowngradeOpen()
Next
trns.Commit()
db.SaveAs(item.ToString, DwgVersion.Current)
db.CloseInput(True)
db.Dispose()
trns.Dispose()
End Using
trans.Dispose()
End Using
Next
psdb.CloseInput(True)
psdb.Dispose()
Me.Close()
End Sub
Solved! Go to Solution.