Author Topic: Run a macro from .NET  (Read 1926 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
Run a macro from .NET
« on: December 19, 2011, 03:18:33 AM »
If you want to run a simple macro like one defined in a tool palette to do MText with justification and width set like
^C^C_mtext;\J;MC;W;0;
How can you do that?
 

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Run a macro from .NET
« Reply #1 on: December 19, 2011, 06:47:57 AM »
Hi,

Code: [Select]
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptPointResult ppr = ed.GetPoint("\nSpecify insertion point: ");
            if (ppr.Status == PromptStatus.OK)
            {
                Point3d pt = ppr.Value;
                string cmd = string.Format("_mtext\n{0},{1},{2}\n_j\n_mc\n_w\n0\n", pt.X, pt.Y, pt.Z);
                doc.SendStringToExecute(cmd, false, false, true);
            }
Speaking English as a French Frog

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Run a macro from .NET
« Reply #2 on: December 19, 2011, 06:55:47 AM »
Sweet!!!
 
I was not sure how to change the settings then pass the points to MText command and did not want to have re-write command.
 
Thanks gile!!!
Works perfect!