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

MText internal workings

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
BrentBurgess1980
476 Views, 2 Replies

MText internal workings

I have created a command the sets all the values for our CAD Standards (ie textsize, colours, styles etc) and then executes the Mtext command (I have used Tony T's code for executing the command http://www.caddzone.com/CommandLine.cs) Everything seems work fine, but when the MText command is executed, the Mtext dialog box is not there.

 

Does anyone know a way around this? Do I need to do a P/Invoke and if so, how do I go about finding the correct method?

 

 

2 REPLIES 2
Message 2 of 3
Hallex
in reply to: BrentBurgess1980

Have to set MTEXTED system variable to "." (dot) before

 

I tested quickly seems working good for me

       
//added into Examples class
 public static int Add_Mtext(Point3d corner1, string stylename, double dblheight, Point3d corner2, string strText)
        {
            return CommandLine.Command("._MTEXT", corner1, "_ST", stylename, "_H", dblheight, corner2, strText, "");
        }
        public static int Mtext_ED(string strEd)
        {
            return CommandLine.Command("._MTEXTED ", strEd);
        }
//added to calling class
      public static void TryMText()
        {
            Examples.Add_Mtext(new Point3d(0, 0, 0), "Standard", 100, new Point3d(1000, 300, 0), @"Blabla1\PBlaBla2");
            Examples.Mtext_ED(@".");
        }
  

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 3
Anonymous
in reply to: Hallex

You may not need to script the MTEXT command to get the desired results.  Have a look at InplaceTextEditor.

 

Example (untested):

 

 

[CommandMethod("mymtext")]
public void mymtext()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    PromptPointOptions ppo = new PromptPointOptions("Specify first corner: ");
    PromptPointResult ppr = ed.GetPoint(ppo);
    Point3d corner1 = ppo.BasePoint = ppr.Value;
    PromptCornerOptions pco = new PromptCornerOptions("Specify opposite corner: ", corner1);
    pco.UseDashedLine = false;
    ppr = ed.GetCorner(pco);
    Point3d corner2 = ppr.Value;
    Vector3d vec = corner2 - corner1;
                
    using (Transaction t = db.TransactionManager.StartTransaction())
    {
        BlockTableRecord curspace =
            t.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
        
        MText mt = new MText();
        mt.Location = corner1;
        mt.Width = vec.X;
        mt.Height = vec.Y;
        curspace.AppendEntity(mt);
        t.AddNewlyCreatedDBObject(mt, true);

        InplaceTextEditor.Invoke(mt, new InplaceTextEditorSettings());

        t.Commit();
    }
}

 

 

 

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