Exemplo n.º 1
0
        public override bool Execute(UICommandContext ctx)
        {
            var dlg = new OpenFileDialog();

            dlg.Filter = "IGES Files(*.iges;*.igs)|*.iges;*.igs";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                var shape = IgesIO.Open(dlg.FileName);
                if (shape != null)
                {
                    var transaction = new UndoTransaction(ctx.Document);
                    transaction.Start(this.Name);

                    var shapeElement = new ShapeElement();
                    shapeElement.SetName(ImportStepCommand.ExtractName(dlg.SafeFileName));
                    ctx.Document.AddElement(shapeElement);
                    shapeElement.SetMaterialId(ctx.DefaultMaterialId);
                    shapeElement.SetShape(shape);
                    ctx.ShowElement(shapeElement);
                    transaction.Commit();

                    ctx.RequestUpdate();
                }
            }
            return(true);
        }