.NET

Reply
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 1 of 3 (217 Views)

Inserting Text in Autocad

217 Views, 2 Replies
05-24-2012 12:03 AM

Hi,

 

Could you please any body suggest on

 

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

 

 

Regards,

Raman

ADN Support Specialist
augusto.goncalves
Posts: 361
Registered: ‎04-30-2009
Message 2 of 3 (201 Views)

Re: Inserting Text in Autocad

05-24-2012 06:45 AM in reply to: RamanSBV

Hi,

 

Try this post: http://through-the-interface.typepad.com/through_the_interface/2010/06/creating-an-autocad-mtext-obj...

 

Regards

Regards,



Augusto Goncalves
Autodesk Developer Network
Valued Mentor
gasty1001
Posts: 487
Registered: ‎04-11-2010
Message 3 of 3 (185 Views)

Re: Inserting Text in Autocad

05-24-2012 04:20 PM 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

 

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.