internal const string NAME = "Example insert WindowMacro";
1 ProjectManager prjMngr = new ProjectManager();
2 SelectionSet oSelSet = new SelectionSet();
3 Page oPage = (Page)oSelSet.GetSelectedPages().GetValue(0);
4
5 if (prjMngr.CurrentProject == null)
6 {
7 MessageBox.Show("No project is open.", ActionInsertMark.NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
8 }
9
10 // get window macro file
11 OpenFileDialog dlg = new OpenFileDialog();
12 dlg.InitialDirectory = prjMngr.Paths.Macros;
13 dlg.Title = "Select a window macro file";
14 dlg.Filter = "Window macros (*.ema)|*.ema|All files|*.*";
15 if (dlg.ShowDialog() != DialogResult.OK)
16 return true;
17
19 using (UndoStep us = (new UndoManager()).CreateUndoStep())
20 {
21 //insert macro
22 Eplan.EplApi.DataModel.MasterData.WindowMacro macro = new Eplan.EplApi.DataModel.MasterData.WindowMacro();
23 macro.Open(dlg.FileName, prjMngr.CurrentProject);
24
25 Insert insrt = new Insert();
26 StorableObject[] arrInsertedObjs = insrt.WindowMacro(macro, 0, oPage, new PointD(), Insert.MoveKind.Relative);
27
28 //if (MessageBox.Show(string.Format("{0} objects inserted on page '{1}'.\n Do you want to undo this operation ?", arrInsertedObjs.Length, oPage.Name)
29 // , ActionInsertMark.NAME
30 // , MessageBoxButtons.YesNo
31 // , MessageBoxIcon.Question) == DialogResult.Yes)
32 //{
33 // us.DoUndo();
34 //}
35 }