您的位置:首页 > 其它

EPLAN API 入门系列- 提高篇(How to Insert WindowMacro?)

2013-03-28 17:55 549 查看
internal const string NAME = "Example insert WindowMacro";
1             ProjectManager prjMngr = new ProjectManager();
SelectionSet oSelSet = new SelectionSet();
Page oPage = (Page)oSelSet.GetSelectedPages().GetValue(0);

if (prjMngr.CurrentProject == null)
{
MessageBox.Show("No project is open.", ActionInsertMark.NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

// get window macro file
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = prjMngr.Paths.Macros;
dlg.Title = "Select a window macro file";
dlg.Filter = "Window macros (*.ema)|*.ema|All files|*.*";
if (dlg.ShowDialog() != DialogResult.OK)
return true;

using (UndoStep us = (new UndoManager()).CreateUndoStep())
{
//insert macro
Eplan.EplApi.DataModel.MasterData.WindowMacro macro = new Eplan.EplApi.DataModel.MasterData.WindowMacro();
macro.Open(dlg.FileName, prjMngr.CurrentProject);

Insert insrt = new Insert();
StorableObject[] arrInsertedObjs = insrt.WindowMacro(macro, 0, oPage, new PointD(), Insert.MoveKind.Relative);

//if (MessageBox.Show(string.Format("{0} objects inserted on page '{1}'.\n Do you want to undo this operation ?", arrInsertedObjs.Length, oPage.Name)
//                    , ActionInsertMark.NAME
//                    , MessageBoxButtons.YesNo
//                    , MessageBoxIcon.Question) == DialogResult.Yes)
//{
//    us.DoUndo();
//}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: