Author Topic: How can I place a text to the desired plane?  (Read 1616 times)

0 Members and 1 Guest are viewing this topic.

melomayo

  • Guest
How can I place a text to the desired plane?
« on: June 08, 2012, 08:09:14 AM »
How can I place a text to the desired plane?

static public ObjectId
DrawMText ( string text, Point3d p1, Vector3d vx, Vector3d vy )
{
.....
}

p1 = Insertion point of text;
vx, vy =  plane vector.


This a my current snippet:

        public static ObjectId AddToBlockDef(ObjectId blockDefId, Entity ent)
        {
            ObjectId id = new ObjectId();

            Autodesk.AutoCAD.DatabaseServices.TransactionManager manager = blockDefId.Database.TransactionManager;

            using (Transaction tr = manager.StartTransaction())
            {
                id = ((BlockTableRecord)tr.GetObject(blockDefId, OpenMode.ForWrite, false)).AppendEntity(ent);

                manager.AddNewlyCreatedDBObject((DBObject)ent, true);

                tr.Commit();
            }

            return id;
        }


        static public ObjectId MText ( Point3d pt, String txt, double height, AttachmentPoint ap )
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            MText _mt = new MText();

            _mt.SetDatabaseDefaults();

            _mt.Contents = txt;
            _mt.Location = pt;
            _mt.Attachment = ap;

            _mt.TextHeight = height;

            _mt.TextStyleId = db.Textstyle;

            return AddToBlockDef( db.CurrentSpaceId, _mt );

        }


Thy for all ...

zoltan

  • Guest
Re: How can I place a text to the desired plane?
« Reply #1 on: June 08, 2012, 10:28:13 AM »
Set the Normal property of the MText to the plane's Z-Axis.