.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set the Justification of an MTEXT to middel Centre.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Irvin
3740 Views, 2 Replies

How to set the Justification of an MTEXT to middel Centre.

Hello there,

 

How do i set the Justification property of a MTEXT.

 

Here i create the MTEXT:

public void CreateMText()
        {
            // Get the current document and database
            Document acDoc = acadApp.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                // Create a multiline text object
                MText acMText = new MText();
                acMText.SetDatabaseDefaults();
                acMText.Location = new Point3d(2, 2, 0);
                acMText.TextStyleId = CreateTextStyle();
                acMText.LayerId = Layer.CreateLayer("Mijn Tekst laag!!!");
                //acMText.Width = 4;
                acMText.Contents = "This is a text string for the MText object. \nWith annotationscale added!!!";

                acBlkTblRec.AppendEntity(acMText);
                acTrans.AddNewlyCreatedDBObject(acMText, true);

                SetScale("1:1", acMText);
                SetScale("1:50", acMText);
                SetScale("1:100", acMText);

                acadApp.ShowAlertDialog(acMText.Handle.Value.ToString());

                // Save the changes and dispose of the transaction
                acTrans.Commit();
            }
        }

I hope someone can help me.

 

Kind regards,

 

Irvin

2 REPLIES 2
Message 2 of 3
jamierobertson1
in reply to: Irvin

Mtext.Attachment

Message 3 of 3
wayne
in reply to: Irvin

Hi,

 

Here is how I fixed it:

MText mt = new MText();
mt.Attachment = AttachmentPoint.MiddleLeft;

 

Regards,

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost