I was thinking about having a place just to post known bug descriptions and solutions, eventually with few lines of code to demonstrate. If we start to debate here, then we have a real possibility to jam this topic and make it unreadable, so it was my fault to post here without acutally get consensus about bug before.
Let moderators of this forum think for a way to arrange this to be clean and easy to read and write some guide rules.
Since Jeff and Blackbox have already asked here, I'm posting here to demonstrate this last bug, will post entire listing so it's easy to copy+paste (and convert to C#). Maybe this was a way to go even first time, so everyone can test it.
Moderators can later rearange this to suite rules.
So to test the last one I've described, use this quick code in a way of:
open new autocad, new file, load app, draw rectancle, draw hatch, delete rectancle, start app with "mytest" command, and set a breakpoint to see that the hatch area is not populated.
Jeff and Blackbox, can you please confirm. And, please, contribute if you have a better solution than me.
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports System.ComponentModel
Imports System.Collections.Specialized
Imports System.Collections.ObjectModel
Imports System.Linq
<Assembly: CommandClass(GetType(tmpdel.MyCommands))>
<Assembly: ExtensionApplication(GetType(tmpdel.MyPlugin))>
Namespace tmpdel
Public Class MyPlugin
Implements IExtensionApplication
Public Sub Initialize() Implements IExtensionApplication.Initialize
End Sub
Public Sub Terminate() Implements IExtensionApplication.Terminate
End Sub
End Class
Public Class MyCommands
<CommandMethod("mytest")> _
Public Sub MyCommand()
AddHandler Application.DocumentManager.MdiActiveDocument.ImpliedSelectionChanged, (AddressOf sectionch)
End Sub
Public Sub sectionch(ByVal o As Object, ByVal e As EventArgs)
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.GetDocument(db)
Using l As DocumentLock = doc.LockDocument()
Using trans As OpenCloseTransaction = db.TransactionManager.StartOpenCloseTransaction()
Dim h As Hatch = trans.GetObject(get_selected_oids.First, OpenMode.ForRead)
'set breakpoint here to see that the hatch area property is not ready
Dim area As Double = h.Area
trans.Commit()
End Using
End Using
End Sub
Public Function get_selected_oids() As List(Of ObjectId)
Dim retval As New List(Of ObjectId)
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'' WARNING! THIS WILL SELECT ALL OBJECTS!!!
Dim psr As PromptSelectionResult = ed.SelectAll
If psr.Status = PromptStatus.OK Then
retval = psr.Value.GetObjectIds.ToList()
End If
Return retval
End Function
End Class
End Namespace