.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set UseBasePoint for DBText

4 REPLIES 4
Reply
Message 1 of 5
hoathuongphuoc
573 Views, 4 Replies

Set UseBasePoint for DBText

Hi All,

I have a problem, hope everybody can help me. This is, where can i put this code: ppo.UseBasePoint = True ,ppo.BasePoint = pt1,ppo.UseDashedLine = True into my program:

 <CommandMethod("dd")> Public Sub DrawText()
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim db As Database = doc.Database
        doc.LockDocument()
        Dim ppo As PromptPointOptions = New PromptPointOptions("")
        ppo.Message = vbLf & "Choose the first vertex of the square:  "
        Dim ppr As PromptPointResult = ed.GetPoint(ppo)
        If ppr.Status <> PromptStatus.OK Then
            Return
        End If
        Dim pt1 As Point3d = ppr.Value
        '' Start a transaction
        Using acTrants As Transaction = db.TransactionManager.StartTransaction()
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrants.GetObject(db.BlockTableId, _
            OpenMode.ForRead)
            '' Open the Block table record Model space for write
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrants.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                            OpenMode.ForWrite)
            ''Create a single-line text object
            Dim acText As DBText = New DBText()
            acText.SetDatabaseDefaults()
            acText.Position = ppr.Value
            acText.Height = 100
            acText.TextString = "Cadviet"
            acText.WidthFactor = 0.8
            acText.HorizontalMode = TextHorizontalMode.TextCenter
            acText.VerticalMode = TextVerticalMode.TextVerticalMid
            acText.AlignmentPoint = ppr.Value
            acBlkTblRec.AppendEntity(acText)
            acTrants.AddNewlyCreatedDBObject(acText, True)
            acTrants.Commit()
        End Using
        ppo.Message = vbLf & "Choose the second vertex of the square:  "
        ppo.UseBasePoint = True
        ppo.BasePoint = pt1
        ppo.UseDashedLine = True
        ppr = ed.GetPoint(ppo)
    End Sub

 I use "MULTIPLE" in comman line of autocad, so i want to create one more acText.  Thanks Everybody.

4 REPLIES 4
Message 2 of 5

Hi,

 

Sorry, didnt understand you question correctly.

What is the purpose of picking those two points ?

You want to place text at those two points ?

 

 

Message 3 of 5

This meaning. I want to create a lot of text "CadViet" and They have to aligned, i use UsebasePoint do that. Example: I want to draw 2 text "CadViet" into autocad. I will draw first text and next text have to align following the first text. Thanks very much.
Message 4 of 5
Hallex
in reply to: hoathuongphuoc

You can just clone text something like this:

        <CommandMethod("dctext")> _
        Public Sub DrawCopyText()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor
            Dim db As Database = doc.Database
            doc.LockDocument()
            Dim ppo As PromptPointOptions = New PromptPointOptions("")
            ppo.Message = vbLf & "Choose the first vertex of the square:  "
            Dim ppr As PromptPointResult = ed.GetPoint(ppo)
            If ppr.Status <> PromptStatus.OK Then
                Return
            End If
            Dim pt1 As Point3d = ppr.Value
            '' Start a transaction
            Using acTrants As Transaction = db.TransactionManager.StartTransaction()
                Dim acBlkTbl As BlockTable
                acBlkTbl = acTrants.GetObject(db.BlockTableId, _
                OpenMode.ForRead)
                '' Open the Block table record Model space for write
                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrants.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                                OpenMode.ForWrite)
                ''Create a single-line text object
                Dim acText As DBText = New DBText()
                acText.SetDatabaseDefaults()
                acText.Position = pt1
                acText.Height = 100
                acText.TextString = "Cadviet"
                acText.WidthFactor = 0.8
                acText.HorizontalMode = TextHorizontalMode.TextCenter
                acText.VerticalMode = TextVerticalMode.TextVerticalMid
                acText.AlignmentPoint = pt1
                acBlkTblRec.AppendEntity(acText)
                acTrants.AddNewlyCreatedDBObject(acText, True)

                ppo.Message = vbLf & "Choose the second vertex of the square:  "
                ppo.UseBasePoint = True
                ppo.BasePoint = pt1
                ppo.UseDashedLine = True
                ppr = ed.GetPoint(ppo)
                Dim pt2 As Point3d = ppr.Value
                Dim vec As Vector3d = pt2 - pt1
                Dim acText2 As DBText = CType(acText.Clone, DBText)
                acText2.TransformBy(Matrix3d.Displacement(vec))
                acBlkTblRec.AppendEntity(acText2)
                acTrants.AddNewlyCreatedDBObject(acText2, True)
                acTrants.Commit()
            End Using
        End Sub

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 5
hoathuongphuoc
in reply to: Hallex

Thanks so much

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost