Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - prmgame

Pages: [1]
1
Text / Create DBTEXT element in Background?Worker vb .net?
« on: June 06, 2012, 08:18:02 PM »
Even after much searching and asking for help, I have not come to a solution for creating DBTEXT elements within a BackgroundWorker, this element has problem with the alignment point. So there is an example ZIP to anyone who can help, just run the command and check the elements created, you will see that I'm creating the element with the point in alinahmento MIDLECENTER but the result is not correct.
I am creating other elements in the same way and they had no problems (MTEXT, POLYLINE, CIRCLE, SPLINE, LINE, etc. ..), they are correct, but the element and the element DBTEXT block that contains attributes present problems in the alignment points.

2
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
        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
            GC.Collect()
            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

3
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.

Pages: [1]