.NET

Reply
Valued Contributor
88 Posts
0 Kudos
Registered: ‎02-28-2012
Post 1 of 3

Inserting Text in Autocad

230 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
390 Posts
46 Kudos
Registered: ‎04-30-2009
Post 2 of 3

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
582 Posts
91 Kudos
Registered: ‎04-11-2010
Post 3 of 3

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
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!