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

Inserting Text in Autocad

2 REPLIES 2
Reply
Message 1 of 3
RamanSBV
404 Views, 2 Replies

Inserting Text in Autocad

Hi,

 

Could you please any body suggest on

 

Inserting text into Autocad drawing file (like inserting image )using c#.

 

 

Regards,

Raman

2 REPLIES 2
Message 2 of 3
Message 3 of 3
hgasty1001
in reply to: RamanSBV

Hi,

 

Try this simple text (no style) insert:

 

Public Sub addText(ByVal p1 As Point3d, ByVal txt As String, ByVal h As Double)
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = HostApplicationServices.WorkingDatabase()

        Using acTrans As Transaction = db.TransactionManager.StartTransaction()
            Dim t As New DBText
            t.Position = p1
            t.TextString = txt
            t.Height = h
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead)
            '' Open the Block table record Model space for write
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

            t.SetDatabaseDefaults()
            acBlkTblRec.AppendEntity(t)
            acTrans.AddNewlyCreatedDBObject(t, True)
            acTrans.Commit()

        End Using



    End Sub

 

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