.NET

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

Inserting Text in Autocad

227 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: 390
Registered: ‎04-30-2009
Message 2 of 3 (211 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: 582
Registered: ‎04-11-2010
Message 3 of 3 (195 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
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.