.NET

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

Inserting Text in Autocad

206 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: 310
Registered: ‎04-30-2009
Message 2 of 3 (190 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: 437
Registered: ‎04-11-2010
Message 3 of 3 (174 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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community