.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Created View is not available after execution
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
105 Views, 4 Replies
07-25-2005 11:06 AM
Public Function ViewTest()
Dim oAcadDB As Database = Application.DocumentManager.MdiActiveDocument.Data
Dim oAcadTransactionManager As Autodesk.AutoCAD.DatabaseServices.TransactionManag
Dim oAcadTransaction As Transaction = oAcadTransactionManager.StartTransaction()
Dim oLayoutManager As Autodesk.AutoCAD.DatabaseServices.LayoutManager = Autodesk.AutoCAD.DatabaseServices.LayoutManager.Cu
Dim oLayoutDictionary As DBDictionary = CType(oAcadTransaction.GetObject(oAcadDB.LayoutDic
Dim oLayoutDbEntry As DictionaryEntry
Dim oLayoutID As ObjectId
For Each oLayoutDbEntry In oLayoutDictionary ' For test, get the object ID of Layout1 from the dictionary
If UCase(oLayoutDbEntry.Key) = UCase("Layout1") Then
oLayoutID = oLayoutDbEntry.Value
Exit For
End If
Next
'Get Layout1
Dim oLayout As Layout = CType(oAcadTransaction.GetObject(oLayoutID, OpenMode.ForWrite, False, False), Layout)
'Get the ViewTable
Dim oAcadViewTable As Autodesk.AutoCAD.DatabaseServices.ViewTable
oAcadViewTable = CType(oAcadTransaction.GetObject(oAcadDB.ViewTable
Dim oAcadViewTableRecord As Autodesk.AutoCAD.DatabaseServices.ViewTableRecord
Dim oAcadViewTableRecordID As Autodesk.AutoCAD.DatabaseServices.ObjectId
Dim strName As String = "TestViewA"
Dim blnViewExist As Boolean = False
'Iterate through the viewtable and check to see if the view "TestView" exist - notice that this is accomplished with a read transaction
For Each oAcadViewTableRecordID In oAcadViewTable ' search for a view with the same name in the table
oAcadViewTableRecord = CType(oAcadTransaction.GetObject(oAcadViewTableRec
If oAcadViewTableRecord.Name = strName Then
blnViewExist = True
Exit For
End If
Next
'If the view does not exist, create a view and add it to the ViewTableRecord - At this point, no X, Y or Center is defined
If Not blnViewExist Then 'if not, make a new view table (oAcadViewTable is open via a ForWrite transaction above)
oAcadViewTableRecord = New Autodesk.AutoCAD.DatabaseServices.ViewTableRecord
oAcadViewTableRecord.Name = strName
oAcadViewTable.Add(oAcadViewTableRecord)
oAcadViewTableRecordID = oAcadViewTableRecord.ObjectId
End If
'At this point, don't know (or care) if the view existed or was created. I need to iterate throught the view table and
'get the View Objects ID. Note that I have had some issues with exceptions trying to open the object after "Add" using
'the previous Object ID for the ViewTableRecord.
For Each oAcadViewTableRecordID In oAcadViewTable ' open ViewTable for Write
oAcadViewTableRecord = CType(oAcadTransaction.GetObject(oAcadViewTableRec
If oAcadViewTableRecord.Name = strName Then
blnViewExist = True
Exit For
End If
Next
oAcadViewTableRecord.Layout = oAcadDB.LayoutDictionaryId
oAcadViewTableRecord.Width = 34.0
oAcadViewTableRecord.Height = 22.0
Dim strCenterPoint As New Autodesk.AutoCAD.Geometry.Point2d(10.0, 20.0)
oAcadViewTableRecord.CenterPoint = strCenterPoint
oAcadViewTableRecord.ViewTwist = 0.0
oAcadViewTableRecord.CategoryName = "Test"
oAcadViewTableRecordID = Nothing
oAcadViewTableRecord = Nothing
oAcadViewTable = Nothing
blnViewExist = Nothing
strName = Nothing
oLayout = Nothing
oLayoutID = Nothing
oLayoutDictionary = Nothing
oLayoutManager = Nothing
oAcadTransaction.Commit()
oAcadTransaction.Dispose()
oAcadViewTableRecord = Nothing
strCenterPoint = Nothing
oAcadTransaction = Nothing
oAcadTransactionManager.Dispose()
oAcadTransactionManager = Nothing
oAcadDB = Nothing
End Function
Re: Created View is not available after execution
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-25-2005 11:08 AM in reply to:
Chris Ludtke
The above code appears to create a "View" or ViewTableRecord.
After execution, this view is not listed in AutoCAD as a view that is made available to the user.
After execution, this view is not listed in AutoCAD as a view that is made available to the user.
Re: Created View is not available after execution
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-25-2005 04:58 PM in reply to:
Chris Ludtke
I fixed this by using the "AddNewlyCreatedObjedt" method of the Transactionmanager after adding the viewtablerecord to the viewtable.
Re: Created View is not available after execution
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-23-2006 01:19 AM in reply to:
Chris Ludtke
The topic is old but I'm trying to do something similar and when i do as in your example:
aAcadViewTable.Add(oAcadViewTableRecord)
i get "eLockViolation" exception.
aAcadViewTable.Add(oAcadViewTableRecord)
i get "eLockViolation" exception.
Re: Created View is not available after execution
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-23-2006 02:59 AM in reply to:
Chris Ludtke
Application.DocumentManager.MdiActiveDocument.Lock Document()
The solution !!!
The solution !!!

