public ValueArrow(Vector3d axisVector, Matrix3d ucs) : base(new List <Entity>(), AnnotativeStates.True, ucs) { _axisVector = axisVector; if (_dataProvider == null) { _dataProvider = new MainMenu.HostProvider(this); } _toleranceBottom = _dataProvider.Read("tolerance", 0.005d); _isToleranceOnly = _dataProvider.Read("isToleranceOnly", false); }
public EntitiesRandomEditor() { if (_dataHost == null) { _dataHost = new MainMenu.HostProvider(this); } _culture = System.Globalization.CultureInfo.GetCultureInfo("en-US"); _maxTolerance = /*0.50;*/ _dataHost.Read("maxTolerance", 0.05d); _minTolerance = /*-0.50;*/ _dataHost.Read("minTolerance", -0.05d); _format = _dataHost.Read("format", ""); _entities = new List <Entity>(); }
public void _drawGridCartogramma2() { _step = _dataHost.Read("step", 20d); //Создаем представление (форму) CivilSurfaces.Views.SurfaceSelectorUserControl control = new CivilSurfaces.Views.SurfaceSelectorUserControl(); var surfInfos = CivilSurfaces.SurfaceTools.GetAllVolumeSurfaces(); control.comboBox_surfaces.Tag = surfInfos; foreach (var si in surfInfos) { int item = control.comboBox_surfaces.Items.Add(si); } if (surfInfos.Count > 0) { control.comboBox_surfaces.SelectedIndex = 0; } else { Tools.GetAcadEditor().WriteMessage($"\nВ проекте нет ни одной подходящей поверхности."); return; } /*Autodesk.AutoCAD.Windows.PaletteSet acWindow = new Autodesk.AutoCAD.Windows.PaletteSet($"{nameof(_drawGridCartogramma2)}"); * var palette = acWindow.AddVisual("Картограмма", control, true); * acWindow.Visible = true;*/ var mwin = Autodesk.AutoCAD.ApplicationServices.Application.MainWindow; System.Windows.Window acadWin = new CustomWindows.KeywordWindow(mwin, CustomWindows.AcadWindow.Dock.BottomRight); acadWin.Content = control; acadWin.Visibility = System.Windows.Visibility.Visible; KeywordCollection keywords = new KeywordCollection(); keywords.Add("Step", "Шаг", "Шаг сетки", true, true); //keywords.Add("View", "Список", "Список поверхностей", true, true); Func <PromptEntityResult, PromptStatus> promptStep = per => { switch (per.StringResult) { case "Step": { PromptDoubleOptions pdo = new PromptDoubleOptions("\nУкажите шаг сетки картограммы: "); pdo.UseDefaultValue = true; pdo.DefaultValue = _step; pdo.AllowZero = false; pdo.AllowNegative = false; pdo.AllowNone = false; var pdr = Tools.GetAcadEditor().GetDouble(pdo); if (pdr.Status == PromptStatus.OK) { _step = pdr.Value; _dataHost.Write("step", _step); } return(pdr.Status); } } return(PromptStatus.Error); }; ObjectId surfaceId = ObjectId.Null; Autodesk.Civil.DatabaseServices.TinVolumeSurface surface; if (!ObjectCollector.TrySelectAllowedClassObject(out surface, keywords, promptStep)) { surfaceId = ((KeyValuePair <string, ObjectId>)control.comboBox_surfaces.SelectedItem).Value; } else { surfaceId = surface.Id; } Polyline polygon = null; Tools.StartTransaction(() => { surface = surfaceId.GetObjectForRead <CivilSurface>() as Autodesk.Civil.DatabaseServices.TinVolumeSurface; if (surface == null) { return; } polygon = surface.ExtractBorders().ConvertToPolyline(); }); Matrix3d ucs = Tools.GetAcadEditor().CurrentUserCoordinateSystem; polygon.TransformBy(ucs); Extents3d bounds = polygon.Bounds.Value; Vector3d hVector = Matrix3d.Identity.CoordinateSystem3d.Xaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).X); Vector3d vVector = Matrix3d.Identity.CoordinateSystem3d.Yaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).Y); ObjectId btrId = ObjectId.Null; ObjectId brId = ObjectId.Null; List <Entity> rectgs = null; CartogrammLabels labelsFactory = null; gride = new SimpleGride(bounds.MinPoint, vVector, hVector, _step, _step); labelsFactory = new CartogrammLabels(gride); int rowsCount = SimpleGride.CalculateCeilingCount(vVector, _step); int columnCount = SimpleGride.CalculateCeilingCount(hVector, _step); rectgs = new List <Entity>(rowsCount * columnCount); for (int r = 0; r < rowsCount; r++) { for (int c = 0; c < columnCount; c++) { Polyline line = gride.CalculateRectagle(r, c, polygon, true); if (line != null) { line.TransformBy(ucs.Inverse()); rectgs.Add(line); } } } labelsFactory.CreateTeble(columnCount); Tools.StartTransaction(() => { rectgs.AddRange(labelsFactory.CreateGridLabels(rectgs.Cast <Polyline>(), surface)); }); rectgs.AddRange(labelsFactory.Entities.Select(x => x.GetTransformedCopy(ucs.Inverse()))); btrId = AcadBlocks.BlockTools.CreateBlockTableRecord("*U", bounds.MinPoint.TransformBy(ucs.Inverse()), rectgs.Cast <Entity>(), AnnotativeStates.NotApplicable, false); brId = AcadBlocks.BlockTools.AppendBlockItem(bounds.MinPoint.TransformBy(ucs.Inverse()), btrId, null); acadWin.Visibility = System.Windows.Visibility.Hidden; acadWin.Close(); //acWindow.Close(); }
public void EditCogoPointLocation() {//SymbolUtilityServices. MethodOfRandomEdition method = MethodOfRandomEdition.ByCoordinate; List <CogoPoint> points; if (!ObjectCollector.TrySelectObjects(out points, "\nУкажите точки COGO для редактирования: ")) { return; } Polyline pline = null; double tolerance = _dataProvider.Read("tolerance", 0.01); PromptDoubleOptions dopt = new PromptDoubleOptions("Укажите максимальное значение (абс.) смещение, м: "); dopt.AllowNone = false; dopt.AllowNegative = false; dopt.DefaultValue = tolerance; PromptDoubleResult dres = Tools.GetAcadEditor().GetDouble(dopt); if (dres.Status != PromptStatus.OK) { return; } _dataProvider.Write("tolerance", dres.Value); tolerance = dres.Value; PromptKeywordOptions pkwopt = new PromptKeywordOptions("\nУкажите метод расчета: "); pkwopt.Keywords.Add("RADius", "ПОРадиусу", "ПОРадиусу"); pkwopt.Keywords.Add("SIMple", "Координаты", "Координаты"); pkwopt.Keywords.Add("FROmBaseDirection", "ОТЛинии", "ОТЛинии"); pkwopt.Keywords.Add("EXit", "ВЫХод", "ВЫХод"); pkwopt.AllowNone = false; PromptResult kwres = Tools.GetAcadEditor().GetKeywords(pkwopt); if (kwres.Status != PromptStatus.OK) { return; } switch (kwres.StringResult) { case "EXit": { return; } case "SIMple": { method = MethodOfRandomEdition.ByCoordinate; break; } case "FROmBaseDirection": { method = MethodOfRandomEdition.FromBaseDirection; if (!ObjectCollector.TrySelectAllowedClassObject(out pline, "\nУкажите базовую линию: ")) { return; } break; } case "RADius": { method = MethodOfRandomEdition.ByVector; break; } } foreach (var p in points) { Point3d location = p.Location; var rndLoc = _editPointLocationRandomByVector(location, tolerance, method, pline); if (rndLoc == null || !rndLoc.HasValue) { continue; } Tools.StartTransaction(() => { var editedPoint = p.Id.GetObject <CogoPoint>(OpenMode.ForWrite); editedPoint.TransformBy(Matrix3d.Displacement(rndLoc.Value - location)); }); } Tools.GetAcadEditor().Regen(); }
public void _drawGridCartogramma2() { _step = _dataHost.Read("step", 20d); KeywordCollection keywords = new KeywordCollection(); keywords.Add("Step", "Шаг", "Шаг сетки", true, true); keywords.Add("View", "Список", "Список поверхностей", true, true); Func <PromptEntityResult, PromptStatus> promptStep = per => { switch (per.StringResult) { case "Step": { PromptDoubleOptions pdo = new PromptDoubleOptions("\nУкажите шаг сетки картограммы: "); pdo.UseDefaultValue = true; pdo.DefaultValue = _step; pdo.AllowZero = false; pdo.AllowNegative = false; pdo.AllowNone = false; var pdr = Tools.GetAcadEditor().GetDouble(pdo); if (pdr.Status == PromptStatus.OK) { _step = pdr.Value; _dataHost.Write("step", _step); } return(pdr.Status); } } return(PromptStatus.Error); }; Autodesk.Civil.DatabaseServices.TinVolumeSurface surface; if (!ObjectCollector.TrySelectAllowedClassObject(out surface, keywords, promptStep)) { return; } Polyline polygon = null; Tools.StartTransaction(() => { surface = surface.Id.GetObjectForRead <CivilSurface>() as Autodesk.Civil.DatabaseServices.TinVolumeSurface; if (surface == null) { return; } polygon = surface.ExtractBorders().ConvertToPolyline(); }); Matrix3d ucs = Tools.GetAcadEditor().CurrentUserCoordinateSystem; polygon.TransformBy(ucs); Extents3d bounds = polygon.Bounds.Value; Vector3d hVector = Matrix3d.Identity.CoordinateSystem3d.Xaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).X); Vector3d vVector = Matrix3d.Identity.CoordinateSystem3d.Yaxis.MultiplyBy((bounds.MaxPoint - bounds.MinPoint).Y); ObjectId btrId = ObjectId.Null; ObjectId brId = ObjectId.Null; List <Entity> rectgs = null; CartogrammLabels labelsFactory = null; gride = new SimpleGride(bounds.MinPoint, vVector, hVector, _step, _step); labelsFactory = new CartogrammLabels(gride); int rowsCount = SimpleGride.CalculateCeilingCount(vVector, _step); int columnCount = SimpleGride.CalculateCeilingCount(hVector, _step); rectgs = new List <Entity>(rowsCount * columnCount); for (int r = 0; r < rowsCount; r++) { for (int c = 0; c < columnCount; c++) { Polyline line = gride.CalculateRectagle(r, c, polygon, true); if (line != null) { line.TransformBy(ucs.Inverse()); rectgs.Add(line); } } } labelsFactory.CreateTeble(columnCount); Tools.StartTransaction(() => { rectgs.AddRange(labelsFactory.CreateGridLabels(rectgs.Cast <Polyline>(), surface)); }); rectgs.AddRange(labelsFactory.Entities.Select(x => x.GetTransformedCopy(ucs.Inverse()))); btrId = AcadBlocks.BlockTools.CreateBlockTableRecord("*U", bounds.MinPoint.TransformBy(ucs.Inverse()), rectgs.Cast <Entity>(), AnnotativeStates.NotApplicable, false); brId = AcadBlocks.BlockTools.AppendBlockItem(bounds.MinPoint.TransformBy(ucs.Inverse()), btrId, null); }