Author Topic: I'm having problems creating the element in DBTEXT BackgroundWorker in VB! Help?  (Read 3635 times)

0 Members and 1 Guest are viewing this topic.

Offline prmgame

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
  • Gender: Male
    • prefered language: VB
    • Prog expertise: Good
    • View Profile
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.

Code: [Select]
Public NotInheritable Class AcadGeneralFunctions
    ''' <summary>
    ''' Método responsavel por criar DBText em documento corrente
    ''' </summary>
    ''' <param name="InsertPoint">Ponto de inserção do DBText</param>
    ''' <param name="Rotation">Rotação do DBText</param>
    ''' <param name="LayerName">Nome do Layer</param>
    ''' <param name="ForceColor">Indique um numero inteiro ou ByLayer</param>
    ''' <param name="AttacPoint">Ponto de atachamento do DBText</param>
    ''' <param name="TextValue">Valor do DBText</param>
    ''' <param name="Height">Altura do DBText</param>
    ''' <returns>ObjectID do DBText Criado</returns>
    ''' <remarks>Rertorna NULL se ouve erro na criação do elemento</remarks>
    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
            Dim DBTextBase As New DBText
            DBTextBase.Rotation = Rotation
            DBTextBase.Layer = LayerName
            DBTextBase.Height = Height
            DBTextBase.TextString = TextValue
            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)
            WTransaction.AddNewlyCreatedDBObject(DBTextBase, True)
            Return DBTextBase.ObjectId()
        Catch ex As System.Exception
            MsgBox("Erro ao executar (NewDBText)!" + vbNewLine + ex.Message + vbNewLine + ex.Source + vbNewLine + ex.StackTrace, MsgBoxStyle.Critical, "AcadGeneralFunctions")
            Return Nothing
        End Try
    End Function
End Class
« Last Edit: June 01, 2012, 05:57:36 PM by prmgame »