public static _AcDb.TypedValue LispSaveFileDialog(_AcDb.ResultBuffer args) { if (args == null) { return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)); } string FileName, Ext, Title; bool Multiple; if (!GetArgsFromRb(args, out FileName, out Ext, out Title, out Multiple)) { return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)); } else { _AcWnd.SaveFileDialog sfd = new _AcWnd.SaveFileDialog(Title, FileName, Ext, "LispSFD", _AcWnd.SaveFileDialog.SaveFileDialogFlags.AllowAnyExtension); System.Windows.Forms.DialogResult dr = sfd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Text, sfd.Filename)); } else { return(new _AcDb.TypedValue((int)_AcBrx.LispDataType.Nil)); } } }
public static void Plan2AufteilungNet() { var acadApp = (Autodesk.AutoCAD.Interop.AcadApplication)_AcAp.Application.AcadApplication; _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument; _AcDb.Database db = doc.Database; _AcEd.Editor ed = doc.Editor; try { ed.Command("_.LAYER", "_TH", "*", "_ON", "*", "_UN", "*", ""); var selOp = new _AcEd.PromptSelectionOptions(); selOp.MessageForAdding = "Zu verschiebende Elemente wählen: "; _AcEd.SelectionFilter filter = new _AcEd.SelectionFilter(new _AcDb.TypedValue[] { new _AcDb.TypedValue((int)_AcDb.DxfCode.Operator, "<NOT"), new _AcDb.TypedValue((int)_AcDb.DxfCode.Operator, "<AND"), new _AcDb.TypedValue((int)_AcDb.DxfCode.Start, "*POLYLINE"), new _AcDb.TypedValue((int)_AcDb.DxfCode.LayerName, "A_AL_MANSFEN"), new _AcDb.TypedValue((int)_AcDb.DxfCode.Operator, "AND>"), new _AcDb.TypedValue((int)_AcDb.DxfCode.Operator, "NOT>") }); while (true) { var res = ed.GetSelection(selOp, filter); if (res.Status != _AcEd.PromptStatus.OK) { break; } else { var ss = res.Value; var selOpE = new _AcEd.PromptSelectionOptions(); _AcDb.ObjectId mf1 = default(_AcDb.ObjectId); if (!GetMansfen("Quell-Mansfen wählen: ", ref mf1)) { break; } _AcDb.ObjectId mf2 = default(_AcDb.ObjectId); if (!GetMansfen("Ziel-Mansfen wählen: ", ref mf2)) { break; } if (!SameMansfens(mf1, mf2)) { ed.WriteMessage("\nDie gewählten Mansfens sind nicht identisch!"); System.Windows.Forms.MessageBox.Show("\nDie gewählten Mansfens sind nicht identisch!", "Plan2AufteilungNet"); } else { _AcGe.Point3d fromPoint = GetLuPoint(mf1); _AcGe.Point3d toPoint = GetLuPoint(mf2); string dwgName = doc.Name; var dwgProposal = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(dwgName), System.IO.Path.GetFileNameWithoutExtension(dwgName) + "_X.dwg"); _AcWnd.SaveFileDialog sfd = new _AcWnd.SaveFileDialog("Ziel-Zeichnung", dwgProposal, "dwg", "TargetDrawing", _AcWnd.SaveFileDialog.SaveFileDialogFlags.NoFtpSites); System.Windows.Forms.DialogResult dr = sfd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { var ucs = ed.CurrentUserCoordinateSystem; var fromPointU = Globs.TransWcsUcs(fromPoint); // fromPoint.TransformBy(ucs); var toPointU = Globs.TransWcsUcs(toPoint); // toPoint.TransformBy(ucs); // only acad2015 - ed.Command("_.UNDO", "_M"); ed.Command("_.DIMDISASSOCIATE", ss, ""); ed.Command("_.MOVE", ss, "", fromPointU, toPointU); //ed.Command("_.MOVE", ss, "", "0,0", "100,100"); ed.Command("_.ERASE", "_ALL", "_R", ss, mf2, ""); doc.Database.SaveAs(sfd.Filename, false, _AcDb.DwgVersion.Current, doc.Database.SecurityParameters); ed.Command("_.UNDO", "_B"); //doc.SendStringToExecute("._UNDO B", true, false, true); // also supports acad2013 doc.SendStringToExecute(".'_UNDO M ", true, false, true); //acadApp.ActiveDocument.SendCommand("_.UNDO _M\n"); //acadApp.ActiveDocument.SendCommand("_.DIMDISASSOCIATE _P \n"); } } Globs.HightLight(mf1, onOff: false); Globs.HightLight(mf2, onOff: false); } } } catch (System.Exception ex) { string msg = string.Format(CultureInfo.CurrentCulture, "Fehler in (Plan2AufteilungNet): {0}", ex.Message); ed.WriteMessage("\n" + msg); System.Windows.Forms.MessageBox.Show(ex.Message, "Plan2AufteilungNet"); } }