public void UpdatePariProj() { log.Info("\nUpdatePariProj"); try { var doc = Application.DocumentManager.MdiActiveDocument; var editor = doc.Editor; var lg = new Logger(editor, log); lg.Info("Starte Update..."); var factory = new Factory(); IPariDatabase database = factory.CreatePariDatabase(); if (!CheckTableValidity(database)) { return; } var blockReader = new BlockReader(); blockReader.ReadBlocksFromModelspace(); var blockInfos = blockReader.BlockInfos; var wohnungInfos = blockReader.WohnungInfos; if (CheckBlockWohnungConsistencyAskUser(blockInfos, wohnungInfos)) { return; } var projektInfo = blockReader.ProjektInfo; if (projektInfo == null) { var msg = string.Format(CultureInfo.CurrentCulture, "Der ProjektInfo-Block existiert nicht in der Zeichnung!"); log.Error(msg); Application.ShowAlertDialog(msg); return; } lg.Info(string.Format(CultureInfo.CurrentCulture, "Projekt-ID: {0}", database.GetProjektId(projektInfo))); var tableUpdater = new TableUpdater(); tableUpdater.Update(blockInfos, wohnungInfos, projektInfo, database); tableUpdater.LogStatus(lg); if (CheckInvalidCategoriesAskUser(tableUpdater)) { return; } database.UpdateDatabase(tableUpdater, projektInfo); lg.Info("\n\nUpdatebeendet."); } catch (Exception ex) { log.Error(ex.Message, ex); Application.ShowAlertDialog(ex.Message); } }
#pragma warning restore 1591 //// ReSharper restore InconsistentNaming private void AutoCadMessageHandler(object sender, PreTranslateMessageEventArgs e) { if (e.Message.message == (int)WndMsg.WM_KEYDOWN) { if ((int)e.Message.wParam == (int)WndKey.VK_F1) { // F1 pressed if (_currentTooltip != null && _currentTooltip.Length > 8 && _currentTooltip.StartsWith("https://modplus.org/")) { // Another implementation could be to look up the help topic in an index file matching it to URLs. _dropNextHelpCall = true; // Even though we don't forward this F1 keypress, AutoCAD sends a message to itself to open the AutoCAD help file object nomutt = AcApp.GetSystemVariable("NOMUTT"); string cmd = $"._BROWSER {_currentTooltip} _NOMUTT {nomutt} "; AcApp.SetSystemVariable("NOMUTT", 1); AcApp.DocumentManager.MdiActiveDocument.SendStringToExecute(cmd, true, false, false); e.Handled = true; } } } else if (e.Message.message == (int)WndMsg.WM_ACAD_HELP && _dropNextHelpCall) { // Seems this is the message AutoCAD generates itself to open the help file. Drop this if help was called from a ribbon tooltip. _dropNextHelpCall = false; // Reset state of help calls e.Handled = true; // Stop this message from being passed on to AutoCAD } }
/// <summary>ObjectId блока для стрелки</summary> /// <param name="newArrName">Имя блока для стрелки</param> /// <returns>ObjectId нового блока стрелки</returns> public static ObjectId GetArrowObjectId(string newArrName) { ObjectId arrObjId; var doc = AcApp.DocumentManager.MdiActiveDocument; var db = doc.Database; // Получаем текущее значение переменной DIMBLK var oldArrName = AcApp.GetSystemVariable("DIMBLK") as string; // Устанавливаем новое значение DIMBLK // (если такой блок отсутствует в чертеже, то он будет создан) AcApp.SetSystemVariable("DIMBLK", newArrName); // Возвращаем предыдущее значение переменной DIMBLK if (!string.IsNullOrEmpty(oldArrName)) { AcApp.SetSystemVariable("DIMBLK", oldArrName); } // Теперь получаем objectId блока var tr = db.TransactionManager.StartTransaction(); using (tr) { var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); arrObjId = bt[newArrName]; tr.Commit(); } return(arrObjId); }
/// <summary> /// This method creates an instance for Commands /// This constructor is called once per document /// on first call of the method 'CommandMethod' /// </summary> public Commands() { // Initialization of private fields (initial default values) doc = AcAp.DocumentManager.MdiActiveDocument; radius = 10.0; layer = (string)AcAp.GetSystemVariable("clayer"); }
public static void SelectInsideCommand() { var _e = new Point3d(double.MinValue, double.MinValue, double.MinValue); try { var options = new PromptEntityOptions("\nSelect a point on a polyline: "); options.SetRejectMessage("Invalid Object."); options.AddAllowedClass(typeof(Curve), false); options.AllowObjectOnLockedLayer = false; var result = Quick.Editor.GetEntity(options); if (result.Status != PromptStatus.OK) { return; } var curveId = result.ObjectId; using (var tr = new QuickTransaction()) { var ent = (Polyline)tr.GetObject(curveId, OpenMode.ForRead, false); var c = Quick.Editor.SelectAll().Value.GetObjectIds().Select(o => tr.GetObject(o, OpenMode.ForRead, true)).Where(o => ent.IsInsidePolygon(o.GetPosition(_e))).ToArray(); c.SetSelected(); //ent.BreakOnPoint(result.PickedPoint.ToPoint2D(), tr, true).SetSelected(); } } catch (Autodesk.AutoCAD.Runtime.Exception ex) { Application.ShowAlertDialog(ex.Message + "\n" + ex.StackTrace); } }
private void lbNewConnections_SelectionChanged(object sender, SelectionChangedEventArgs e) { base.Close(); SelectConnection.WindowOpen = true; AddNewServer addNewServer = new AddNewServer(); Application.ShowModalWindow(addNewServer); }
public override bool WorldDraw(Drawable drawable, WorldDraw wd) { if (!wd.Context.IsPlotGeneration) // Не в состоянии печати! { var ent = drawable as Entity; if (ent != null && !ent.IsAProxy && !ent.IsCancelling && !ent.IsDisposed && !ent.IsErased) { try { if (ent.IsModPlusProduct()) { double height = (double)AcApp.GetSystemVariable("VIEWSIZE"); var scale = height / 1500; var offset = 20; var plane = ent.GetPlane(); Matrix3d ucs = AcApp.DocumentManager.MdiActiveDocument.Editor.CurrentUserCoordinateSystem; var extents = ent.GeometricExtents; var pt = extents.MaxPoint.TransformBy(ucs.Inverse()); Point3dCollection points = new Point3dCollection(); points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 10) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 10) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 40) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 40) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 20) * scale), pt.Y + ((offset + 30) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 20) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 10) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 30) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z)); points.Add(new Point3d(pt.X + ((offset + 00) * scale), pt.Y + ((offset + 00) * scale), plane.PointOnPlane.Z)); short backupColor = wd.SubEntityTraits.Color; FillType backupFillType = wd.SubEntityTraits.FillType; wd.SubEntityTraits.FillType = FillType.FillAlways; wd.SubEntityTraits.Color = 150; wd.Geometry.Polygon(points); wd.SubEntityTraits.FillType = FillType.FillNever; // restore wd.SubEntityTraits.Color = backupColor; wd.SubEntityTraits.FillType = backupFillType; } } catch (System.Exception exception) { // not showing. Only sending by AppMetrica Statistic.SendException(exception); } } } return(base.WorldDraw(drawable, wd)); }
public void DynToStaticCommmand() { Document doc = Application.DocumentManager.MdiActiveDocument; Database database = doc.Database; if (!DynToStaticDwg(database)) { Application.ShowAlertDialog("An error occurred!"); } }
private static bool ShouldSupressRunningOSnap() { if (!supressRunningOSnap) { return(false); } int num = (short)AcadApp.GetSystemVariable("OSMODE"); return(num != 0 && (num & 16384) == 0); }
public void ZeroOpacityCommand() { Document doc = Application.DocumentManager.MdiActiveDocument; Database database = doc.Database; if (!ZeroOpacityDwg(database)) { Application.ShowAlertDialog("Une erreur est survenue."); } }
public static bool?ShowDialog([NotNull] List <IError> errors) { var errVM = new ErrorsVM(errors) { IsDialog = true }; var errView = new ErrorsView(errVM); var res = Application.ShowModalWindow(errView); return(res); }
private static TileConfig VraagConfiguratie() { var tilesConfig = TilesConfig.Get(); var tileNames = tilesConfig.Select(t => t.Naam).ToArray(); var tileName = AutocadUtils.GetCommand("\nSelecteer de achtergrond: ", tileNames, tileNames.First()); Application.ShowAlertDialog(tileName); var tileConfig = tilesConfig.Single(t => t.Naam == tileName); return(tileConfig); }
public static bool?ShowDialog(ViewModelBase viewModel) { Type view; if (dictVmViews.TryGetValue(viewModel.GetType(), out view)) { var win = (Window)Activator.CreateInstance(view); win.DataContext = viewModel; return(Application.ShowModalWindow(win)); } throw new Exception("Окно не определено - тип = " + viewModel.GetType()); }
private bool SelectService() { bool result; try { this.btnCancel.IsEnabled = false; this.btnNext.IsEnabled = false; base.IsEnabled = false; AGSConnection aGSConnection = this.lbConnections.SelectedItem as AGSConnection; if (aGSConnection.ConnectionFailed) { this.RefreshConnection(aGSConnection); } if (!aGSConnection.ConnectionFailed) { if (this.PopulateConnection(aGSConnection)) { base.Close(); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { this.ClearProgressBar(); Application.ShowModelessWindow(selectService); base.Close(); result = true; return(result); } } else { this.btnCancel.IsEnabled = true; this.btnNext.IsEnabled = true; base.IsEnabled = true; SelectConnection.WindowOpen = false; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = "Populating Connection failed"; } ErrorReport.ShowErrorMessage(text); aGSConnection.ErrorMessage = ""; } } result = false; } catch { result = false; } return(result); }
public void ReplaceBlockWithFileStart() { Application.SetSystemVariable("FILEDIA", 1); var editorUtility = new EditorHelper(Application.DocumentManager.MdiActiveDocument); PromptEntityResult blockToReplaceResult = editorUtility.PromptForObject("Select the block to replace : ", typeof(BlockReference), false); if (blockToReplaceResult.Status != PromptStatus.OK) { return; } var openFileDialog = new System.Windows.Forms.OpenFileDialog(); if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } if (!File.Exists(openFileDialog.FileName)) { _ed.WriteMessage("File does not exists."); return; } if (!openFileDialog.FileName.EndsWith(".dwg", StringComparison.InvariantCultureIgnoreCase)) { _ed.WriteMessage("File is not a DWG."); return; } Point3d selectedEntityPoint; using (Transaction transaction = _db.TransactionManager.StartTransaction()) { BlockTable blockTable = (BlockTable)transaction.GetObject(_db.BlockTableId, OpenMode.ForWrite); Entity selectedEntity = (Entity)transaction.GetObject(blockToReplaceResult.ObjectId, OpenMode.ForWrite); selectedEntityPoint = ((BlockReference)selectedEntity).Position; selectedEntity.Erase(); blockTable.DowngradeOpen(); blockTable.Dispose(); transaction.Commit(); } ReplaceBlockRefWithDWG(_doc, openFileDialog.FileName, selectedEntityPoint, _ed.CurrentUserCoordinateSystem); _logger.Info(MethodBase.GetCurrentMethod().Name); }
private String GetIsoPlane( ) { String result = "Left"; if (Application.GetSystemVariable("Snapisopair").ToString( ) == "1") { result = "Top"; } else if (Application.GetSystemVariable("Snapisopair").ToString( ) == "2") { result = "Right"; } return(result); }
private void btnNext_Click(object sender, RoutedEventArgs e) { base.Close(); if (!this.SelectService()) { Application.ShowModalWindow(new SelectConnection { lbConnections = { ItemsSource = App.Connections } }); } }
public static void ShowLast() { if (LastErrors?.Any() != true) { return; } var errVM = new ErrorsVM(LastErrors) { IsDialog = false }; var errView = new ErrorsView(errVM); Application.ShowModelessWindow(errView); }
public static int Command(params object[] args) { if (AcadApp.DocumentManager.IsApplicationContext) { return(0); } int stat = 0; int cnt = 0; bool supressOSnap = ShouldSupressRunningOSnap(); bool transform = ShouldTransformCoords(); using (ResultBuffer buffer = new ResultBuffer()) { foreach (object o in args) { if (supressOSnap && (o is Point3d || o is Point2d)) { buffer.Add(new TypedValue(RTSTR, "_non")); } if (transform && (o is Point3d)) { buffer.Add(new TypedValue(RT3DPOINT, WorldToCurrent((Point3d)o))); } else { buffer.Add(TypedValueFromObject(o)); } ++cnt; } if (cnt > 0) { string s = (string)AcadApp.GetSystemVariable("USERS1"); bool debug = string.Compare(s, "DEBUG", true) == 0; int val = debug ? 1 : 0; object cmdecho = AcadApp.GetSystemVariable("CMDECHO"); Int16 c = (Int16)cmdecho; if (c != 0 || debug) { AcadApp.SetSystemVariable("CMDECHO", val); } stat = acedCmd(buffer.UnmanagedObject); if (c != 0 || debug) { AcadApp.SetSystemVariable("CMDECHO", cmdecho); } } } return(stat); }
public void Main() { try { var win = new SettingsWindow(); var viewModel = new SettingsViewModel(win); win.DataContext = viewModel; win.Closed += (sender, args) => viewModel.ApplySettings(); AcApp.ShowModalWindow(AcApp.MainWindow.Handle, win); } catch (System.Exception exception) { ExceptionBox.Show(exception); } }
getCommandList() { string[] cmds = null; string cmd = (string)Application.GetSystemVariable("CMDNAMES"); if (cmd.Length > 0) { int cmdNum = cmd.Split(new char[] { '\'' }).Length; cmds = cmd.Split(new char[] { '\'' }); } return(cmds); }
public static void Show([NotNull] List <IError> errors) { try { var errVM = new ErrorsVM(errors) { IsDialog = false }; var errView = new ErrorsView(errVM); Application.ShowModelessWindow(errView); } catch (Exception ex) { Logger.Log.Error(ex); } }
private void OnClickNext(object sender, RoutedEventArgs e) { this.lblErrorMessage.Content = ""; if (string.IsNullOrEmpty(this.tbName.Text)) { this.lblErrorMessage.Content = AfaStrings.NameCannotBeBlank; return; } string text = this.tbName.Text; if (!string.IsNullOrEmpty(text)) { text = text.Trim(); } if (string.IsNullOrEmpty(text)) { this.lblErrorMessage.Content = AfaStrings.NameCannotBeBlank; return; } text = NewFeatureClass.FixFeatureClassName(text); MSCDataset docDataset = AfaDocData.ActiveDocData.DocDataset; MSCFeatureClass mSCFeatureClass = new MSCFeatureClass(docDataset); this.tbName.Text = text; mSCFeatureClass.Name = text; mSCFeatureClass.SetGeometryType(this.cbType.SelectedValue.ToString()); mSCFeatureClass.Query = new ResultBuffer(new TypedValue[] { new TypedValue(8, "*") }); mSCFeatureClass.Write(AfaDocData.ActiveDocData.Document); docDataset.FeatureClasses.Add(mSCFeatureClass.Name, mSCFeatureClass); docDataset.FeatureClassViewList.Add(new FCView(mSCFeatureClass)); base.Close(); FeatureClassProperties featureClassProperties = new FeatureClassProperties(mSCFeatureClass); try { Application.ShowModalWindow(featureClassProperties); } catch (Exception) { } AfaDocData.ActiveDocData.SetActiveFeatureClass(mSCFeatureClass); ArcGISRibbon.SetActiveFeatureClass(mSCFeatureClass); }
private void ListBox_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2 && this.lbConnections.SelectedItem != null) { base.Close(); if (!this.SelectService()) { Application.ShowModalWindow(new SelectConnection { lbConnections = { ItemsSource = App.Connections } }); } } }
public void TestTestMergePolyline() { var doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument; var db = doc.Database; var ed = doc.Editor; var selRes = ed.Select("Выбери полилинии для объединения"); if (selRes.Count == 0) { return; } using (var t = db.TransactionManager.StartTransaction()) { var pls = new List <Polyline>(); foreach (var item in selRes) { if (!item.IsValidEx()) { continue; } var pl = item.GetObject(OpenMode.ForRead) as Polyline; if (pl != null) { pls.Add(pl); } } try { var plMerged = pls.Merge(); var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord; cs.AppendEntity(plMerged); t.AddNewlyCreatedDBObject(plMerged, true); plMerged.ColorIndex = 5; } catch (System.Exception ex) { Application.ShowAlertDialog(ex.ToString()); } t.Commit(); } }
public static void OpenStyleEditor() { if (_styleEditor == null) { _styleEditor = new StyleEditor(); _styleEditor.Closed += (sender, args) => _styleEditor = null; } if (_styleEditor.IsLoaded) { _styleEditor.Activate(); } else { AcApp.ShowModalWindow(AcApp.MainWindow.Handle, _styleEditor, false); } }
public void Start() { Statistic.SendCommandStarting(new ModPlusConnector()); try { MoveDwgBase(); // Директория расположения базы создается при первом обращении к свойству Constants.DwgBaseDirectory! var win = new MpDwgBaseMainWindow(); AcApp.ShowModalWindow(AcApp.MainWindow.Handle, win, false); } catch (System.Exception exception) { ExceptionBox.Show(exception); } }
private static void GetSelectionWithFilter() { // 创建一个 TypedValue 数组,用于定义过滤条件 var filterTypes = new TypedValue[] { new TypedValue((int)DxfCode.Color, 5), new TypedValue((int)DxfCode.Start, "CIRCLE"), new TypedValue((int)DxfCode.LayerName, "0") }; /* * var pso = new PromptSelectionOptions(); * pso.Keywords.Add("NoFilter", "无(N)", "无(N)"); // */ /* * var filterType = new[] * { * new TypedValue((int) DxfCode.Start, "DIMENSION"), * // 将标注类型限制为转角标注与对齐标注 * new TypedValue((int) DxfCode.Operator, "<OR"), * new TypedValue(100, "AcDbAlignedDimension"), * new TypedValue(100, "AcDbRotatedDimension"), * new TypedValue((int) DxfCode.Operator, "OR>") * }; */ //获取当前文档编辑器 Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor; // 请求在图形区域选择对象 var res = acDocEd.GetSelection(new SelectionFilter(filterTypes)); // 如果提示状态OK,表示对象已选 if (res.Status == PromptStatus.OK) { var acSSet = res.Value; Application.ShowAlertDialog("Number of objects selected: " + acSSet.Count.ToString()); } else { Application.ShowAlertDialog("Number of objects selected: 0"); } }
public void StartFunction() { Statistic.SendCommandStarting(new ModPlusConnector()); if (_mpDimJustif == null) { _mpDimJustif = new MpDimJustif(); _mpDimJustif.Closed += win_Closed; } if (_mpDimJustif.IsLoaded) { _mpDimJustif.Activate(); } else { AcApp.ShowModelessWindow(AcApp.MainWindow.Handle, _mpDimJustif); } }
public void PariAutoFill() { log.Info("PariAutoFill"); try { var filler = new AttributeFiller(); filler.Fill(); var doc = Application.DocumentManager.MdiActiveDocument; var editor = doc.Editor; editor.WriteMessage("\n\nFill beendet."); } catch (Exception ex) { log.Error(ex.Message, ex); Application.ShowAlertDialog(ex.Message); } }