.NET

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

Inserting Text in Autocad

226 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: 374
Registered: ‎04-30-2009
Message 2 of 3 (210 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
Distinguished Mentor
gasty1001
Posts: 544
Registered: ‎04-11-2010
Message 3 of 3 (194 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

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

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