Message 1 of 3
I'm having problems creating the element in DBTEXT BackgroundWorker in VB! HELP?

Not applicable
06-01-2012
10:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having problems creating the element in DBTEXT BackgroundWorker in VB! Develop a function to create the element dbtext in the current document, when I use this function within <Autodesk.AutoCAD.Runtime.CommandMethod("")> it works perfectly, but when it is used within BackgroundWorker raises the point of different alignment indicated. And the problem is solved when you run the AUDIT command in the project, then the alignment points are corrected. The same problem is occurring for the blocks that have attributes, in this case the alignment points are also displaced the attributes of the standard indicated.
Public Function NewDBText(ByVal InsertPoint As Point3d, ByVal Rotation As Double, ByVal LayerName As String, ByVal ForceColor As String, ByVal AttacPoint As AttachmentPoint, ByVal TextValue As String, ByVal Height As Double) As ObjectId Try Dim DBTextBase As New DBText DBTextBase.Rotation = Rotation DBTextBase.Layer = LayerName DBTextBase.Height = Height DBTextBase.TextString = TextValue DBTextBase.SetFromStyle() DBTextBase.Annotative = AnnotativeStates.False If (ForceColor <> "ByLayer") Then DBTextBase.ColorIndex = ForceColor End If DBTextBase.Position = InsertPoint DBTextBase.Justify = AttacPoint DBTextBase.AlignmentPoint = InsertPoint Dim WorkDataBase As Database = HostApplicationServices.WorkingDatabase() Dim WTransaction As Transaction = WorkDataBase.TransactionManager.StartTransaction() Dim BlockTab As BlockTable = WTransaction.GetObject(WorkDataBase.BlockTableId, OpenMode.ForRead) Dim ObjectIdBlockTabRec As ObjectId = BlockTab.Item(BlockTableRecord.ModelSpace) Dim BlockTabRec As BlockTableRecord = WTransaction.GetObject(ObjectIdBlockTabRec, OpenMode.ForWrite) DBTextBase.SetDatabaseDefaults() BlockTabRec.AppendEntity(DBTextBase) WTransaction.AddNewlyCreatedDBObject(DBTextBase, True) WTransaction.Commit() BlockTabRec.Dispose() BlockTab.Dispose() WTransaction.Dispose() WorkDataBase.Dispose() Return DBTextBase.ObjectId() Catch ex As System.Exception My.Application.Log.DefaultFileLogWriter.CustomLocation = My.Application.Info.DirectoryPath & "\Logs" My.Application.Log.DefaultFileLogWriter.BaseFileName = "SgmPlusCode" My.Application.Log.WriteEntry("Class (AcadGeometricManager) " & DateAndTime.DateString & " " & DateAndTime.TimeString) My.Application.Log.WriteException(ex, TraceEventType.Error, "Method (NewDBText)") GC.Collect() Return Nothing End Try End Function