public void CreateContour(BlockTableRecord btr) { if (panelBtr.ExtentsByTile.Diagonal() < endOffset) { return; } // из всех плиток отделить торцевые плитки???? // дерево границ плиток TreeTiles = new RTree<Tuple<ObjectId, Extents3d>>(); panelBtr.Tiles.ForEach(t => { try { var r = new Rectangle(t.Item2.MinPoint.X, t.Item2.MinPoint.Y, t.Item2.MaxPoint.X, t.Item2.MaxPoint.Y, 0, 0); TreeTiles.Add(r, t); } catch { } }); // Первый угол панели - левый нижний var pt1 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MinPoint, EnumCorner.LeftLower); var pt2 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MinPoint.X, panelBtr.ExtentsByTile.MaxPoint.Y, 0), EnumCorner.LeftTop); var pt3 = getCoordTileNoEnd(panelBtr.ExtentsByTile.MaxPoint, EnumCorner.RightTop); var pt4 = getCoordTileNoEnd(new Point3d(panelBtr.ExtentsByTile.MaxPoint.X, panelBtr.ExtentsByTile.MinPoint.Y, 0), EnumCorner.RightLower); Extents3d extNoEnd = new Extents3d(pt1, pt2); extNoEnd.AddPoint(pt3); extNoEnd.AddPoint(pt4); panelBtr.ExtentsNoEnd = extNoEnd; Point3dCollection pts = new Point3dCollection(); pts.Add(pt1); pts.Add(pt2); pts.Add(pt3); pts.Add(pt4); using (Polyline3d poly = new Polyline3d(Poly3dType.SimplePoly, pts, true)) { poly.LayerId = panelBtr.CPS.IdLayerContour; btr.AppendEntity(poly); btr.Database.TransactionManager.TopTransaction.AddNewlyCreatedDBObject(poly, true); } }
/// <summary> /// Возвращает маскировку, созданную по контуру с указанным отступом /// </summary> /// <param name="extents3d">Крайние границы</param> /// <param name="offset">Отступ</param> private static Wipeout GetBackgroundMask(Extents3d extents3d, double offset) { try { var minPoint = extents3d.MinPoint; var maxPoint = extents3d.MaxPoint; var bottomLeftPoint = new Point2d(minPoint.X - offset, minPoint.Y - offset); var topLeftPoint = new Point2d(minPoint.X - offset, maxPoint.Y + offset); var topRightPoint = new Point2d(maxPoint.X + offset, maxPoint.Y + offset); var bottomRightPoint = new Point2d(maxPoint.X + offset, minPoint.Y - offset); var wipeout = new Wipeout(); wipeout.SetFrom( new Point2dCollection { bottomLeftPoint, topLeftPoint, topRightPoint, bottomRightPoint, bottomLeftPoint }, Vector3d.ZAxis); return(wipeout); } catch (Autodesk.AutoCAD.Runtime.Exception ex) { if (ex.Message == "eNullExtents") { return(null); } throw; } }
bool get_layout_extents(Database db, Teigha.GraphicsSystem.View pView, ref BoundBlock3d bbox) { BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead); BlockTableRecord pSpace = (BlockTableRecord)bt[BlockTableRecord.PaperSpace].GetObject(OpenMode.ForRead); Layout pLayout = (Layout)pSpace.LayoutId.GetObject(OpenMode.ForRead); Extents3d ext = new Extents3d(); if (pLayout.GetViewports().Count > 0) { bool bOverall = true; foreach (ObjectId id in pLayout.GetViewports()) { if (bOverall) { bOverall = false; continue; } Teigha.DatabaseServices.Viewport pVp = (Teigha.DatabaseServices.Viewport)id.GetObject(OpenMode.ForRead); } ext.TransformBy(pView.ViewingMatrix); bbox.Set(ext.MinPoint, ext.MaxPoint); } else { ext = pLayout.Extents; } bbox.Set(ext.MinPoint, ext.MaxPoint); return(ext.MinPoint != ext.MaxPoint); }
private static Point3d GetGeometricCenter(Extents3d ext) { return(new Point3d( (ext.MaxPoint.X + ext.MinPoint.X) / 2, (ext.MaxPoint.Y + ext.MinPoint.Y) / 2, (ext.MaxPoint.Z + ext.MinPoint.Z) / 2)); }
public static MapValue ReadComponentOffsetX(BlockReference br, System.Data.DataTable fjvTable) { Matrix3d transform = br.BlockTransform; Matrix3d inverseTransform = transform.Inverse(); br.TransformBy(inverseTransform); Extents3d bbox = br.Bounds.GetValueOrDefault(); br.TransformBy(transform); double value = (bbox.MinPoint.X + bbox.MaxPoint.X) / 2; //Debug if (ReadComponentFlipState(br) != "_PP") { prdDbg(br.Handle.ToString() + ": " + ReadComponentFlipState(br)); } //Debug switch (ReadComponentFlipState(br)) { case "_NP": value = value * -1; break; default: break; } return(new MapValue(value)); }
public static Extents3d?SafeGetGeometricExtents(Entity entity) { // http://adndevblog.typepad.com/autocad/2012/12/entitygeometricextents-throws-an-exception-enullextents.html // Issue // When I calculate the extents of entities in a drawing, for some entities an exception is thrown with the "eNullExtents" message. // What is wrong? // Solution // This exception occurs for an insert of an empty block or for an empty block attribute. // It is "as designed", it's just a notification to the developer about an empty object. // An easy solution is to add a separate catch block for this particular exception: var extents = new Extents3d(); try { extents = entity.GeometricExtents; } catch (Autodesk.AutoCAD.Runtime.Exception ex) { // The entity is empty and has no extents if (ex.Message == "eNullExtents" || ex.Message == "eInvalidExtents") { // TODO. We can simply skip this entity... return(null); } } return(extents); }
private List <ObjectId> GetEndTiles(Extents3d extEndTiles, RTree <Tuple <ObjectId, Extents3d> > treeTiles) { var rect = new Rectangle(extEndTiles); var tiles = treeTiles.Intersects(rect); return(tiles.Select(s => s.Item1).ToList()); }
public AnnotationOverlapCheckResult(PolygonIntersect intersect) : base(ActionType.AnnotationOverlap, new ObjectId[0]) { using (var transaction = intersect.SourceId.Database.TransactionManager.StartTransaction()) { var polyline = transaction.GetObject(intersect.SourceId, OpenMode.ForRead) as AcadPolyline; if (polyline != null) { _intersectionPaths.Add((AcadPolyline)polyline.Clone()); } polyline = transaction.GetObject(intersect.TargetId, OpenMode.ForRead) as AcadPolyline; if (polyline != null) { _intersectionPaths.Add((AcadPolyline)polyline.Clone()); } } _extents = _intersectionPaths[0].GeometricExtents; for (int i = 1; i < _intersectionPaths.Count; i++) { _extents.AddExtents(_intersectionPaths[i].GeometricExtents); } _position = _extents.MinPoint + (_extents.MaxPoint - _extents.MinPoint) / 2; HighlightEntity = false; }
public static void TecTest() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; using (Transaction Tx = db.TransactionManager.StartTransaction()) { BlockTableRecord ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead); RXObject brClass = RXObject.GetClass(typeof(BlockReference)); Point3d lastrightpt = new Point3d(0, 0, 0); foreach (ObjectId id in ms) { if (id.ObjectClass == brClass) { BlockReference br = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite); ed.WriteMessage("NAME:{0}\n", br.Name); Extents3d bounds = br.GeometricExtents; ed.WriteMessage("BOUNDS: {0}\n", bounds.ToString()); Vector3d vec = (Vector3d)(lastrightpt - bounds.MinPoint); ed.WriteMessage("VECTOR: {0}\n", vec.ToString()); Point3d rightpt = new Point3d(bounds.MaxPoint.X, bounds.MinPoint.Y, 0);; Vector3d newrp = (Vector3d)(vec + rightpt.GetAsVector() + (new Vector3d(50, 0, 0))); lastrightpt = new Point3d(newrp.X, newrp.Y, 0); ed.WriteMessage("NEWLASTRIGHT SET to {0}\n", lastrightpt); Matrix3d mat = Matrix3d.Displacement(vec); br.TransformBy(mat); } } Tx.Commit(); } }
/// <summary> /// Sets the view in a viewport to contain the specified model extents. /// </summary> /// <param name="ext">The extents of the content to fit the viewport.</param> /// <param name="fac">Optional factor to provide padding.</param> public static void FitContentToViewport(this Viewport vp, Extents3d ext, double fac = 1.0) { // Let's zoom to just larger than the extents vp.ViewCenter = (ext.MinPoint + ((ext.MaxPoint - ext.MinPoint) * 0.5)).Strip(); // Get the dimensions of our view from the database extents var hgt = ext.MaxPoint.Y - ext.MinPoint.Y; var wid = ext.MaxPoint.X - ext.MinPoint.X; // We'll compare with the aspect ratio of the viewport itself // (which is derived from the page size) var aspect = vp.Width / vp.Height; // If our content is wider than the aspect ratio, make sure we // set the proposed height to be larger to accommodate the // content if (wid / hgt > aspect) { hgt = wid / aspect; } // Set the height so we're exactly at the extents vp.ViewHeight = hgt; // Set a custom scale to zoom out slightly (could also // vp.ViewHeight *= 1.1, for instance) vp.CustomScale *= fac; }
public void modified(object sender, EventArgs e) { Extents3d extents3d = (Extents3d)_Entity.Bounds; Point3d newPosition = new Point3d( (extents3d.MaxPoint.X + extents3d.MinPoint.X) / 2, (extents3d.MaxPoint.Y + extents3d.MinPoint.Y) / 2, (extents3d.MaxPoint.Z + extents3d.MinPoint.Z) / 2); Database db = Application.DocumentManager.MdiActiveDocument.Database; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; if (tm.TopTransaction == null) { tm.StartTransaction(); } foreach (var v in _BindedRoadways) { RoadwayWrapper bdrw = (RoadwayWrapper)tm.GetObject(v.roadway.ObjectId, OpenMode.ForWrite, false); if (v.whichSide == -1) { bdrw.EndPoint = newPosition; } else if (v.whichSide == 1) { bdrw.StartPoint = newPosition; } } }
static public void plottertruescaled() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { //get a point from user //use a jig to create a "window of the printed area" //point should be the center of the window //"tab" rotates from portrait and landscape //ask user for print window Extents3d plotWindow = BlockInserter(db, ed, doc); Extents2d window = coordinates(plotWindow.MinPoint, plotWindow.MaxPoint); //set up the plotter PlotInfo pi = plotSetUp(window, tr, db, ed, false, false); //call plotter engine to run plotEngine(pi, "Nameless", doc, ed, false); tr.Dispose(); } }
private static Extents3d OffsetExtToMarginCell(Extents3d ext, [NotNull] Cell cell) { return(new Extents3d( new Point3d(ext.MinPoint.X - cell.Borders.Horizontal.Margin ?? 0, ext.MinPoint.Y - cell.Borders.Top.Margin ?? 0, 0), new Point3d(ext.MaxPoint.X + cell.Borders.Horizontal.Margin ?? 0, ext.MaxPoint.Y + cell.Borders.Top.Margin ?? 0, 0) )); }
public static Extents3d OffsetAbs(this Extents3d ext, double offset = 10) { return(new Extents3d( new Point3d(ext.MinPoint.X - offset, ext.MinPoint.Y - offset, 0), new Point3d(ext.MaxPoint.X + offset, ext.MaxPoint.Y + offset, 0) )); }
private int getThickness(Extents3d extBlRefPanel) { var lenX = Convert.ToInt32(extBlRefPanel.MaxPoint.X - extBlRefPanel.MinPoint.X); var lenY = Convert.ToInt32(extBlRefPanel.MaxPoint.Y - extBlRefPanel.MinPoint.Y); return((lenX > lenY) ? roundTo10(lenY) : roundTo10(lenX)); }
public static void Zoom(this Database database, Extents3d ext) { BoundBlock3d box = new BoundBlock3d(); box.Set(ext.MinPoint, ext.MaxPoint); Zoom(database, box); }
/// <summary> /// 获取网格化后的surface类 /// </summary> /// <param name="gridSize">网格大小</param> /// <returns></returns> public Surface GetGridedSurface(double gridSize) { Extents3d extents = this.m_extents; int col = (int)((extents.MaxPoint.X - extents.MinPoint.X) / gridSize); int row = (int)((extents.MaxPoint.Y - extents.MinPoint.Y) / gridSize); List <double> elevations = new List <double>(); var xs = Enumerable.Range(0, col).Select(x => extents.MinPoint.X + x * gridSize).ToArray(); var ys = Enumerable.Range(0, row).Select(x => extents.MinPoint.Y + x * gridSize).ToArray(); for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { elevations.Add(this.GetElevationAt(xs[i], ys[j])); } } Surface surf = new Surface(); surf._pointsAreGrid = true; surf.m_extents = extents; surf.m_elevations = elevations.ToArray(); surf.m_nodatavalue = this.m_nodatavalue; surf.m_XSize = col; surf.m_YSize = row; return(surf); }
public static void ToDatFile(Surface surf, string path) { Surface surf1 = new Surface(); if (surf._pointsAreGrid == false) { Extents3d extentss = surf.m_extents; double gridSize = (extentss.MaxPoint.X - extentss.MinPoint.X) / 100; surf1 = surf.GetGridedSurface(gridSize); } else if (surf._pointsAreGrid == true) { surf1 = surf; } Extents3d extents = surf1.m_extents; int XSize = surf1.m_XSize; int YSize = surf1.m_YSize; System.IO.StreamWriter sw = new System.IO.StreamWriter(path); double gridXSize = (extents.MaxPoint.X - extents.MinPoint.X) / (XSize - 1); double gridYSize = (extents.MaxPoint.Y - extents.MinPoint.Y) / (YSize - 1); int col = (int)((extents.MaxPoint.X - extents.MinPoint.X) / gridXSize); int row = (int)((extents.MaxPoint.Y - extents.MinPoint.Y) / gridYSize); var xs = Enumerable.Range(0, col).Select(x => extents.MinPoint.X + x * gridXSize).ToArray(); var ys = Enumerable.Range(0, row).Select(x => extents.MinPoint.Y + x * gridYSize).ToArray(); for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { sw.WriteLine("{0} {1} {2}", xs[i], ys[j], surf.GetElevationAt(xs[i], ys[j])); } } sw.Close(); }
// Замена вхождения блока СБ на АР public void ReplaceBlockSbToAr(MarkAr markAr, Transaction t, BlockTableRecord ms) { var blRefMarkSb = t.GetObject(_idBlRefSb, OpenMode.ForWrite, false, true) as BlockReference; var blRefPanelAr = new BlockReference(blRefMarkSb.Position, markAr.IdBtrAr); blRefPanelAr.SetDatabaseDefaults(); blRefPanelAr.Layer = blRefMarkSb.Layer; _extents = blRefPanelAr.GeometricExtents; //_insPt = blRefPanelAr.Position; blRefMarkSb.Erase(true); _idBlRefAr = ms.AppendEntity(blRefPanelAr); t.AddNewlyCreatedDBObject(blRefPanelAr, true); //Database db = HostApplicationServices.WorkingDatabase; //using (var t = db.TransactionManager.StartTransaction()) //{ // var ms = t.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite) as BlockTableRecord; // var blRefMarkSb = t.GetObject(_idBlRefSb, OpenMode.ForWrite, false, true) as BlockReference; // var blRefPanelAr = new BlockReference(blRefMarkSb.Position, markAr.IdBtrAr); // blRefPanelAr.SetDatabaseDefaults(); // blRefPanelAr.Layer = blRefMarkSb.Layer; // _extents = blRefPanelAr.GeometricExtents; // //_insPt = blRefPanelAr.Position; // blRefMarkSb.Erase(true); // _idBlRefAr = ms.AppendEntity(blRefPanelAr); // t.AddNewlyCreatedDBObject(blRefPanelAr, true); // t.Commit(); //} }
public static Extents2d ReduceDimensions(this Extents3d origin) { var max = origin.MaxPoint; var min = origin.MinPoint; return(new Extents2d(min.X, min.Y, max.X, max.Y)); }
public Panel(BlockReference blRefPanel, MarkAr markAr) { _idBlRefSb = blRefPanel.ObjectId; _insPt = blRefPanel.Position; _extents = blRefPanel.GeometricExtents; _markAr = markAr; }
private void Init() { if (!init && !disposed && !Disposing && !IsDesigner) { extents = new Extents3d(); Autodesk.AutoCAD.GraphicsSystem.Manager gsm = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.GraphicsManager; Autodesk.AutoCAD.GraphicsSystem.KernelDescriptor descriptor = new Autodesk.AutoCAD.GraphicsSystem.KernelDescriptor(); descriptor.addRequirement(Autodesk.AutoCAD.UniqueString.Intern("3D Drawing")); Autodesk.AutoCAD.GraphicsSystem.GraphicsKernel kernel = Autodesk.AutoCAD.GraphicsSystem.Manager.AcquireGraphicsKernel(descriptor); device = gsm.CreateAutoCADOffScreenDevice(kernel); device.DeviceRenderType = Autodesk.AutoCAD.GraphicsSystem.RendererType.Default; device.BackgroundColor = BackColor; view = new Autodesk.AutoCAD.GraphicsSystem.View(); view.VisualStyle = new Autodesk.AutoCAD.GraphicsInterface.VisualStyle(Autodesk.AutoCAD.GraphicsInterface.VisualStyleType.Wireframe2D); model = gsm.CreateAutoCADModel(kernel); device.Add(view); init = true; } }
public static Extents3d PromptExtents([NotNull] this Editor ed, string msgPromptFirstPoint, string msgPromptsecondPoint) { var extentsPrompted = new Extents3d(); var prPtRes = ed.GetPoint(msgPromptFirstPoint); if (prPtRes.Status == PromptStatus.OK) { var prCornerRes = ed.GetCorner(msgPromptsecondPoint, prPtRes.Value); if (prCornerRes.Status == PromptStatus.OK) { extentsPrompted.AddPoint(prPtRes.Value); extentsPrompted.AddPoint(prCornerRes.Value); } else { throw new OperationCanceledException(); } } else { throw new OperationCanceledException(); } return(extentsPrompted); }
Extents() { m_db = Utils.Db.GetCurDwg(); Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = m_db.TransactionManager; while (true) { PromptEntityResult prEntRes = ed.GetEntity("\nSelect entity to show extents"); if (prEntRes.Status != PromptStatus.OK) { break; } using (Autodesk.AutoCAD.DatabaseServices.Transaction tr = tm.StartTransaction()) { AcDb.Entity ent = (AcDb.Entity)tr.GetObject(prEntRes.ObjectId, OpenMode.ForRead); Extents3d ext = ent.GeometricExtents; Point3d centerPt = Utils.Ge.Midpoint(ext.MinPoint, ext.MaxPoint); Utils.AcadUi.PrintToCmdLine(string.Format("\nEXTMIN: {0}", Utils.AcadUi.PtToStr(ext.MinPoint))); Utils.AcadUi.PrintToCmdLine(string.Format("\nEXTMAX: {0}", Utils.AcadUi.PtToStr(ext.MaxPoint))); Utils.AcadUi.PrintToCmdLine(string.Format("\nCENTER PT: {0}", Utils.AcadUi.PtToStr(centerPt))); tr.Commit(); MakeExtentsBlock(ext); } } }
public Extent(Extents3d ext) { this.XMin = new double?(Math.Min(ext.MinPoint.X, ext.MaxPoint.X)); this.YMin = new double?(Math.Min(ext.MinPoint.Y, ext.MaxPoint.Y)); this.XMax = new double?(Math.Max(ext.MinPoint.X, ext.MaxPoint.X)); this.YMax = new double?(Math.Max(ext.MinPoint.Y, ext.MaxPoint.Y)); }
/// <summary> /// Определят не пустой ли габаритный контейнер. /// </summary> /// <param name="ext">Габаритный контейнер.</param> /// <returns></returns> public static bool IsEmptyExt(ref Extents3d ext) { if (ext.MinPoint.DistanceTo(ext.MaxPoint) < Tolerance.Global.EqualPoint) return true; else return false; }
public static Extents3d Limits(Extents3d baseExtents, Point3dCollection points) { Extents3d ex = Limits(points); return(new Extents3d(new Point3d(Math.Min(ex.MinPoint.X, baseExtents.MinPoint.X), Math.Min(ex.MinPoint.Y, baseExtents.MinPoint.Y), Math.Min(ex.MinPoint.Z, baseExtents.MinPoint.Z)), new Point3d(Math.Max(ex.MaxPoint.X, baseExtents.MaxPoint.X), Math.Max(ex.MaxPoint.Y, baseExtents.MaxPoint.Y), Math.Max(ex.MaxPoint.Z, baseExtents.MaxPoint.Z)))); }
/// <summary> /// Расчетная область - от точки /// </summary> private Extents3d GetCalcExtents(double maxHeight) { // высота тени - отступ по земле от расчетной точки до линии движения тени double cSunPlane; double ySunPlane = values.YShadowLineByHeight(maxHeight, out cSunPlane); // растояние до точки пересечения луча и линии тени double xRayToStart = values.GetXRay(ySunPlane, StartAnglesIllum.AngleStartOnPlane); if (xRayToStart < 0) { xRayToStart = 0; } double xRayToEnd = values.GetXRay(ySunPlane, StartAnglesIllum.AngleEndOnPlane); if (xRayToEnd > 0) { xRayToEnd = 0; } Extents3d ext = new Extents3d(); ext.AddPoint(new Point3d(ptCalc.X + xRayToEnd, ptCalc.Y - ySunPlane, 0)); ext.AddPoint(new Point3d(ptCalc.X + xRayToStart, ptCalc.Y, 0)); #if TEST //EntityHelper.AddEntityToCurrentSpace(ext.GetPolyline()); #endif return(ext); }
/// <summary> /// Выделение объектов и зумирование по границе /// </summary> /// <param name="ids">Элементв</param> /// <param name="ed">Редактор</param> public static void SetSelectionAndZoom([NotNull] this List <ObjectId> ids, Editor ed = null) { try { var doc = AcadHelper.Doc; ed = doc.Editor; using (doc.LockDocument()) using (var t = doc.TransactionManager.StartTransaction()) { if (!ids.Any()) { "Нет объектов для выделения.".WriteToCommandLine(); return; } var ext = new Extents3d(); ids.Select(s => s.GetObject(OpenMode.ForRead)).Iterate(o => { if (o.Bounds.HasValue) { ext.AddExtents(o.Bounds.Value); } }); ed.Zoom(ext); Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids.ToArray()); t.Commit(); } } catch (Exception ex) { $"Ошибка выделения объектов - {ex.Message}.".WriteToCommandLine(); } }
/// <summary> /// Определение границ блока панели для вида формы или фасада /// </summary> private Extents3d getPanelExt(BlockReference blRef, bool isFacadeView) { Extents3d resVal = new Extents3d(); string ignoreLayer = isFacadeView ? Settings.Default.LayerDimensionForm : Settings.Default.LayerDimensionFacade; var btr = blRef.DynamicBlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord; foreach (ObjectId idEnt in btr) { if (!idEnt.IsValidEx()) { continue; } var ent = idEnt.GetObject(OpenMode.ForRead, false, true) as Entity; if (ent.Layer.Equals(ignoreLayer, StringComparison.OrdinalIgnoreCase)) { continue; } try { var curExt = ent.GeometricExtents; if (!IsEmptyExt(ref curExt)) { resVal.AddExtents(curExt); } } catch { } } resVal.TransformBy(blRef.BlockTransform); return(resVal); }
public static List <ObjectId> SelectObjectsByEntityBoundingBox(Editor editor, SelectionFilter filter, Entity entity, double extraBuffer) { var result = new List <ObjectId>(); var database = editor.Document.Database; using (var transaction = database.TransactionManager.StartTransaction()) { var extent = GeometryUtils.SafeGetGeometricExtents(entity); if (extent != null) { var boundaryInModelSpace = new Point3dCollection { new Point3d(extent.Value.MinPoint.X - extraBuffer, extent.Value.MinPoint.Y - extraBuffer, 0), new Point3d(extent.Value.MinPoint.X - extraBuffer, extent.Value.MaxPoint.Y + extraBuffer, 0), new Point3d(extent.Value.MaxPoint.X + extraBuffer, extent.Value.MaxPoint.Y + extraBuffer, 0), new Point3d(extent.Value.MaxPoint.X + extraBuffer, extent.Value.MinPoint.Y - extraBuffer, 0) }; var extentWithBuffer = new Extents3d(boundaryInModelSpace[0], boundaryInModelSpace[2]); // SelectCrossingPolygon要求图一定要在视口内部,要不然会查不到,或者漏掉。 // 需要设定一下viewPort后abort. ZoomToWin(editor, extentWithBuffer, 2.0); var res = editor.SelectCrossingPolygon(boundaryInModelSpace, filter); if (res != null && res.Status == PromptStatus.OK) { // Aboort viewport change result.AddRange(res.Value.GetObjectIds()); } transaction.Abort(); } } return(result); }
/// <summary> 是否包含某一点(包括边界) </summary> public static Point3d GetCenter(this Extents3d ext) { var min = ext.MinPoint; var max = ext.MaxPoint; return(new Point3d((max.X + min.X) / 2, (max.Y + min.Y) / 2, (max.Z + min.Z) / 2)); }
/// <summary> /// Creates a new Polyline that is the result of projecting the transformed MinPoint and MaxPoint of 'extents' /// parallel to 'direction' onto 'plane' and returns it. /// </summary> /// <param name="extents">The Extents3d of a transformed from World to dirPlane Polyline.</param> /// <param name="plane">The plane onto which the points are to be projected.</param> /// <param name="direction">Direction (in WCS coordinates) of the projection</param> /// <param name="dirPlane">The plane which origin is 0, 0, 0 and 'direction' is the normal.</param> /// <returns>The newly created Polyline.</returns> internal static Polyline ProjectExtents(Extents3d extents, Plane plane, Vector3d direction, Plane dirPlane) { Point3d pt1 = extents.MinPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane)); Point3d pt2 = extents.MaxPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane)); Polyline projectedPline = new Polyline(2); projectedPline.AddVertexAt(0, pt1.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0); projectedPline.AddVertexAt(1, pt2.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0); return projectedPline; }
public static void Zoom(this Editor ed, Extents3d ext) { if (ed == null) return; using (ViewTableRecord view = ed.GetCurrentView()) { ext.TransformBy(view.WorldToEye()); view.Width = ext.MaxPoint.X - ext.MinPoint.X; view.Height = ext.MaxPoint.Y - ext.MinPoint.Y; view.CenterPoint = new Point2d( (ext.MaxPoint.X + ext.MinPoint.X) / 2.0, (ext.MaxPoint.Y + ext.MinPoint.Y) / 2.0); ed.SetCurrentView(view); } }
public Error(string message, Entity ent) { _msg = message; if (_msg.Length >100) _shortMsg = _msg.Substring(0, 100); else _shortMsg = _msg; if (ent == null) { _hasEntity = false; } else { _hasEntity = true; _idEnt = ent.Id; _extents = ent.GeometricExtents; } }
private Extents3d convertText(ObjectId idDbText, int angle, Point3d pos, bool isMarkOrPaint) { Extents3d resVal = new Extents3d(); if (idDbText.IsNull) { return resVal; } using (var text = idDbText.GetObject(OpenMode.ForWrite, false, true) as DBText) { text.TextStyleId = idDbText.Database.GetTextStylePIK(); double lenMax = panelBtr.HeightByTile; // Аннотативность??? if (panelBtr.HeightByTile >= 2000) { text.Position = pos; double angleRadian = Math.PI * angle / 180.0; text.Rotation = angleRadian; } else { lenMax = panelBtr.ExtentsNoEnd.MaxPoint.X - panelBtr.ExtentsNoEnd.MinPoint.X; // Небольшая корректировка положения текста if (isMarkOrPaint) { text.Position = new Point3d(10, 315,0); } else { text.Position = new Point3d(10, 65, 0); } } // Проверка длины текста - если не вписывается в размер панели то сжатие ControlTextLength(text, lenMax); resVal = text.GeometricExtents; } return resVal; }
public static Extents3d PromptExtents(this Editor ed, string msgPromptFirstPoint, string msgPromptsecondPoint) { Extents3d extentsPrompted = new Extents3d(); var prPtRes = ed.GetPoint(msgPromptFirstPoint); if (prPtRes.Status == PromptStatus.OK) { var prCornerRes = ed.GetCorner(msgPromptsecondPoint, prPtRes.Value); if (prCornerRes.Status == PromptStatus.OK) { extentsPrompted.AddPoint(prPtRes.Value); extentsPrompted.AddPoint(prCornerRes.Value); } else { throw new Exception("Отменено пользователем."); } } else { throw new Exception("Отменено пользователем."); } return extentsPrompted; }
public void CalcRolls() { // Вычисление разверток помещения using (var pl = IdPolyline.GetObject(OpenMode.ForRead, false, true) as Polyline) { if (pl.Area < 500) { return; } Roll roll = new Roll(this); var segSomes = new List<RollSegment>(); Vector2d direction = Vector2d.XAxis; RollSegment segFirst = null; RollSegment segLast = null; RollSegment seg = null; for (int i = 0; i < pl.NumberOfVertices; i++) { var segType = pl.GetSegmentType(i); if (segType == SegmentType.Line) { var segLine = pl.GetLineSegment2dAt(i); var segLen = segLine.Length; // Создане сегмента и определение вида который в упор смотрит на этот сегмент seg = new RollSegment(this, segLine, i); // Если этот сегмент не сонаправлен предыдущему if (checkNewRoll(segSomes, direction, seg)) { roll.AddSegments(segSomes); AddRoll(roll); roll = new Roll(this); segSomes = new List<RollSegment>(); } if (!seg.IsPartition) { direction = seg.Direction; if (segFirst == null) segFirst = seg; segLast = seg; } if (seg.View != null && !seg.IsPartition) { // определен вид. roll.Num = seg.View.Name; roll.View = seg.View; } segSomes.Add(seg); } else if (segType == SegmentType.Arc) { var segBounds = pl.GetArcSegmentAt(i).BoundBlock; Extents3d segExt = new Extents3d(segBounds.GetMinimumPoint(), segBounds.GetMaximumPoint()); // Пока ошибка Inspector.AddError($"Дуговой сегмент полилинии помещения. Пока не обрабатываеься.", segExt, TransToModel, System.Drawing.SystemIcons.Warning); } else { //Inspector.AddError($"Cегмент полилинии помещения типа {segType}. Пока не обрабатываеься.", // pl.GeometricExtents, TransToModel, System.Drawing.SystemIcons.Warning); } } // Проверка последнего сегмента, если для него еще не определена развертка if (seg.Roll == null && segFirst != null) { // Проверка что последний сегмент входит в первую развертку помещения Roll rollFirst = segFirst.Roll; if (seg.IsPartition) { //rolFirst.AddSegments(new List<RollSegment>() { seg }); seg = segLast; direction = seg.Direction; } // Проверка - может это сегмент первой развертки в помещении var dirFirst = segFirst.Direction; if (checkNewRoll(segSomes, dirFirst, seg)) { // Новая развертка roll.AddSegments(segSomes); AddRoll(roll); } else { // Добавляем в первую развертку segSomes.Reverse(); rollFirst.AddSegments(segSomes); } } } }
/// <summary> /// Рекурсивное получение габаритного контейнера для выбранного примитива. /// </summary> /// <param name="en">Имя примитива</param> /// <param name="ext">Габаритный контейнер</param> /// <param name="mat">Матрица преобразования из системы координат блока в МСК.</param> private static Extents3d GetBlockExtents(Entity en, ref Matrix3d mat, Extents3d ext) { if (en is BlockReference) { var bref = en as BlockReference; Matrix3d matIns = mat * bref.BlockTransform; using (var btr = bref.BlockTableRecord.Open(OpenMode.ForRead) as BlockTableRecord) { foreach (ObjectId id in btr) { // Пропускаем все тексты. if (id.ObjectClass.IsDerivedFrom(DbTextRXClass) || id.ObjectClass.IsDerivedFrom(MTextRXClass) || id.ObjectClass.IsDerivedFrom(MLeaderRXClass) || id.ObjectClass.IsDerivedFrom(DimensionRXClass)) { continue; } using (DBObject obj = id.Open(OpenMode.ForRead) as DBObject) { Entity enCur = obj as Entity; if (enCur == null || enCur.Visible != true) continue; if (IsEmptyExt(ref ext)) { ext.AddExtents(GetBlockExtents(enCur, ref matIns, ext)); } else { ext = GetBlockExtents(enCur, ref matIns, ext); } } } } } else { if (mat.IsUniscaledOrtho()) { using (Entity enTr = en.GetTransformedCopy(mat)) { if (enTr is Dimension) (enTr as Dimension).RecomputeDimensionBlock(true); if (enTr is Table) (enTr as Table).RecomputeTableBlock(true); if (IsEmptyExt(ref ext)) { try { ext = enTr.GeometricExtents; } catch { }; } else { try { ext.AddExtents(enTr.GeometricExtents); } catch { }; } return ext; } } else { try { Extents3d curExt = en.GeometricExtents; curExt.TransformBy(mat); if (IsEmptyExt(ref ext)) ext = curExt; else ext.AddExtents(curExt); } catch { } return ext; } } return ext; }
private void createBlock() { // создание определения блока using (var bt = CPS.DbExport.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable) { IdBtrEnd = getIdBtrEnd(bt); } // для каждой панели - копирование объектв торца с преобразование в координаты модели // список копируемых объектов торуа с привязкой к объекту блока панели для дальнейшего перемещения объектов в 0,0 в блоке торца foreach (var panelBlRef in itemLefEndsByY) { Dictionary<ObjectId, PanelBlRefExport> dictIdsEndEnts = new Dictionary<ObjectId, PanelBlRefExport>(); if (isLeftSide) { panelBlRef.PanelBtrExport.IdsEndsLeftEntity.ForEach(e => dictIdsEndEnts.Add(e, panelBlRef)); } else { panelBlRef.PanelBtrExport.IdsEndsRightEntity.ForEach(e => dictIdsEndEnts.Add(e, panelBlRef)); } ObjectIdCollection ids = new ObjectIdCollection(dictIdsEndEnts.Keys.ToArray()); using (IdMapping mapping = new IdMapping()) { CPS.DbExport.DeepCloneObjects(ids, IdBtrEnd, mapping, false); //перемещение объектов в блоке var moveMatrix = Matrix3d.Displacement(new Vector3d(0, panelBlRef.Position.Y - Position.Y, 0)); foreach (ObjectId id in ids) { var ent = mapping[id].Value.GetObject(OpenMode.ForWrite, false, true) as Entity; ent.TransformBy(moveMatrix); } } } // перемещение вех объектов торца в 0 var btr = IdBtrEnd.GetObject(OpenMode.ForRead) as BlockTableRecord; Extents3d extFull = new Extents3d(); extFull.AddBlockExtents(btr); foreach (ObjectId idEnt in btr) { using (var ent = idEnt.GetObject(OpenMode.ForWrite, false, true) as Entity) { ent.TransformBy(Matrix3d.Displacement(new Vector3d(-extFull.MinPoint.X, 0, 0))); } } ////сопоставление скопированных объектов с панелями //Dictionary<ObjectId, PanelBlRefExport> dictIdsCopyedEndEnts = new Dictionary<ObjectId, PanelBlRefExport>(); //foreach (IdPair itemIdMap in mapping) //{ // var panelBlRef = dictIdsEndEnts[itemIdMap.Key]; // dictIdsCopyedEndEnts.Add(itemIdMap.Key, panelBlRef); //} //// удаление выбранных объектов //foreach (ObjectId idEnt in ids) //{ // var ent = t.GetObject(idEnt, OpenMode.ForWrite, false, true) as Entity; // ent.Erase(); //} // вставка блока if (!IsExistsBlockEnd) { using (var blRef = new BlockReference(Position, IdBtrEnd)) { blRef.SetDatabaseDefaults(CPS.DbExport); using (var ms = SymbolUtilityServices.GetBlockModelSpaceId(CPS.DbExport).GetObject(OpenMode.ForWrite) as BlockTableRecord) { ms.AppendEntity(blRef); ms.Database.TransactionManager.TopTransaction.AddNewlyCreatedDBObject(blRef, true); } } } }
/// <summary> /// Определение границ блока панели для вида формы или фасада /// </summary> private Extents3d getPanelExt(BlockReference blRef, bool isFacadeView) { Extents3d resVal = new Extents3d(); string ignoreLayer = isFacadeView ? Settings.Default.LayerDimensionForm : Settings.Default.LayerDimensionFacade; var btr = blRef.DynamicBlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord; foreach (ObjectId idEnt in btr) { var ent = idEnt.GetObject(OpenMode.ForRead, false, true) as Entity; if (ent.Layer.Equals(ignoreLayer, StringComparison.OrdinalIgnoreCase)) { continue; } try { var curExt = ent.GeometricExtents; if (!IsEmptyExt(ref curExt)) { resVal.AddExtents(curExt); } } catch { } } resVal.TransformBy(blRef.BlockTransform); return resVal; }
// Zooms to given objects public static void ZoomToObjects(IEnumerable<ObjectId> ids) { Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; Extents3d outerext = new Extents3d(); Database db = HostApplicationServices.WorkingDatabase; using (Transaction tr = db.TransactionManager.StartTransaction()) { try { foreach (ObjectId id in ids) { Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity; Extents3d ext = ent.GeometricExtents; outerext.AddExtents(ext); } } catch { ; } } outerext.TransformBy(ed.CurrentUserCoordinateSystem.Inverse()); Point2d min2d = new Point2d(outerext.MinPoint.X, outerext.MinPoint.Y); Point2d max2d = new Point2d(outerext.MaxPoint.X, outerext.MaxPoint.Y); ViewTableRecord view = new ViewTableRecord(); view.CenterPoint = min2d + ((max2d - min2d) / 2.0); view.Height = max2d.Y - min2d.Y; view.Width = max2d.X - min2d.X; ed.SetCurrentView(view); }
public static void AddError(string msg, Entity ent, Extents3d ext, Icon icon = null) { var err = new Error(msg, ext, ent, icon); Errors.Add(err); }
public static void AddError(string msg, Entity ent, Extents3d ext) { var err = new Error(msg, ext, ent); Errors.Add(err); }
private void Init() { if (!init && !disposed && !Disposing && !IsDesigner) { extents = new Extents3d(); Autodesk.AutoCAD.GraphicsSystem.Manager gsm = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.GraphicsManager; #if REBARPOS2015 Autodesk.AutoCAD.GraphicsSystem.KernelDescriptor descriptor = new Autodesk.AutoCAD.GraphicsSystem.KernelDescriptor(); descriptor.addRequirement(Autodesk.AutoCAD.UniqueString.Intern("3D Drawing")); Autodesk.AutoCAD.GraphicsSystem.GraphicsKernel kernel = Autodesk.AutoCAD.GraphicsSystem.Manager.AcquireGraphicsKernel(descriptor); device = gsm.CreateAutoCADDevice(kernel, this.Handle); device.DeviceRenderType = RendererType.Default; device.BackgroundColor = BackColor; view = new Autodesk.AutoCAD.GraphicsSystem.View(); view.VisualStyle = new Autodesk.AutoCAD.GraphicsInterface.VisualStyle(Autodesk.AutoCAD.GraphicsInterface.VisualStyleType.Wireframe2D); model = gsm.CreateAutoCADModel(kernel); #elif REBARPOS2013 device = gsm.CreateAutoCADDevice(this.Handle); device.DeviceRenderType = RendererType.Default; device.BackgroundColor = BackColor; view = new Autodesk.AutoCAD.GraphicsSystem.View(); view.VisualStyle = new Autodesk.AutoCAD.GraphicsInterface.VisualStyle(Autodesk.AutoCAD.GraphicsInterface.VisualStyleType.Wireframe2D); model = gsm.CreateAutoCADModel(); #elif REBARPOS2010 device = gsm.CreateAutoCADDevice(this.Handle); device.DeviceRenderType = RendererType.Default; device.BackgroundColor = BackColor; view = new Autodesk.AutoCAD.GraphicsSystem.View(); view.VisualStyle = new Autodesk.AutoCAD.GraphicsInterface.VisualStyle(Autodesk.AutoCAD.GraphicsInterface.VisualStyleType.Wireframe2D); model = gsm.CreateAutoCADModel(); #endif device.Add(view); device.Update(); init = true; } }
public void ClearItems() { if (IsDesigner) return; Init(); view.EraseAll(); extents = new Extents3d(); Refresh(); }
/// <summary> /// Gets a value indicating whether the specified point is inside the extents. /// </summary> /// <param name="pt">The instance to which the method applies.</param> /// <param name="extents">The extents 3d supposed to contain the point.</param> /// <returns>true if the point is inside the extents; otherwise, false.</returns> public static bool IsInside(this Point3d pt, Extents3d extents) { return pt.X >= extents.MinPoint.X && pt.Y >= extents.MinPoint.Y && pt.Z >= extents.MinPoint.Z && pt.X <= extents.MaxPoint.X && pt.Y <= extents.MaxPoint.Y && pt.Z <= extents.MaxPoint.Z; }
public static void AddError(string msg, Extents3d ext, ObjectId idEnt) { var err = new Error(msg, ext, idEnt); Errors.Add(err); }
public void DefineGeom(ObjectId idBtrPanelAkr) { string blName; _extentsTiles = new Extents3d(); using (var btrAkr = idBtrPanelAkr.Open(OpenMode.ForRead) as BlockTableRecord) { blName = btrAkr.Name; foreach (ObjectId idEnt in btrAkr) { if (idEnt.ObjectClass.Name == "AcDbBlockReference") { using (var blRefTile = idEnt.Open(OpenMode.ForRead, false, true) as BlockReference) { if (string.Equals(blRefTile.GetEffectiveName(), Settings.Default.BlockTileName, StringComparison.CurrentCultureIgnoreCase)) { _extentsTiles.AddExtents(blRefTile.GeometricExtents); } } } } Image = AcadLib.Blocks.Visual.BlockPreviewHelper.GetPreview(btrAkr); } HeightPanelByTile = _extentsTiles.MaxPoint.Y - _extentsTiles.MinPoint.Y + Settings.Default.TileSeam; double shiftEnd = 0; if (blName.IndexOf(Settings.Default.EndLeftPanelSuffix, StringComparison.OrdinalIgnoreCase) != -1) { shiftEnd = -Settings.Default.FacadeEndsPanelIndent * 0.5;// 445;// Торец слева - сдвинуть влево FacadeEndsPanelIndent } else if (blName.IndexOf(Settings.Default.EndRightPanelSuffix, StringComparison.OrdinalIgnoreCase) != -1) { shiftEnd = -Settings.Default.FacadeEndsPanelIndent * 0.5;// 445;// Торец спрва - сдвинуть вправо } var test = _extentsTiles.MaxPoint.X - _extentsTiles.MinPoint.X; //_distToCenterFromBase = (_extentsTiles.MaxPoint.X - _extentsTiles.MinPoint.X) * 0.5 + shiftEnd; }
public ViewportPanel(Viewport vp, BlockReference blRef, bool isFacadeView) { this.vp = vp; panelExt = getPanelExt(blRef, isFacadeView); }
private static Extents3d createChangePlan(List<ChangePanel> chPanels, Point3d ptPlan, ObjectId idBtrFloor, BlockTableRecord btr,Transaction t) { // Вставить блок монтажки var blRefFloor = new BlockReference(ptPlan, idBtrFloor); btr.AppendEntity(blRefFloor); t.AddNewlyCreatedDBObject(blRefFloor, true); // Обвести облачком каждую панель с изменившейся покраской foreach (var chPanel in chPanels) { // Границы монт. панели на монт. плане в координатах Модели. var extMP = chPanel.ExtMountPanel; extMP.TransformBy(blRefFloor.BlockTransform); Point3d ptCloudMin; Point3d ptCloudMax; Point3d ptText; if (chPanel.IsHorizontal) { ptCloudMin = new Point3d(extMP.MinPoint.X + 150, extMP.MinPoint.Y - 150, 0); ptCloudMax = new Point3d(extMP.MaxPoint.X - 150, extMP.MaxPoint.Y + 150, 0); ptText = new Point3d(ptCloudMin.X, ptCloudMin.Y - 100, 0); } else { ptCloudMin = new Point3d(extMP.MinPoint.X - 150, extMP.MinPoint.Y + 150, 0); ptCloudMax = new Point3d(extMP.MaxPoint.X + 150, extMP.MaxPoint.Y - 150, 0); ptText = new Point3d(ptCloudMax.X+100, ptCloudMin.Y+(ptCloudMax.Y-ptCloudMin.Y)*0.5, 0); } var extCloud = new Extents3d(ptCloudMin, ptCloudMax); // Полилиния облака изменения var pl = extCloud.GetPolyline(); var plCloud = getCloudPolyline(pl); plCloud.SetDatabaseDefaults(); plCloud.Color = ColorChange; btr.AppendEntity(plCloud); t.AddNewlyCreatedDBObject(plCloud, true); // Текст изменения MText text = new MText(); text.SetDatabaseDefaults(); text.Color = ColorChange; text.TextHeight = 250; text.Contents = $"Старая марка покраски: {chPanel.PaintOld}, \n\rНовая марка покраски: {chPanel.PaintNew} " + $"\n\rПанель: {chPanel.MarkSb}"; text.Location = ptText; btr.AppendEntity(text); t.AddNewlyCreatedDBObject(text, true); chPanel.PanelMount.SetPaintingToAttr(chPanel.PanelAKR.MarkAr); } // Разбить //blRefFloor.ExplodeToOwnerSpace(); return blRefFloor.GeometricExtents; }
private double getCoordY(Extents3d extentsByTile, EnumCorner corner) { switch (corner) { case EnumCorner.LeftLower: case EnumCorner.RightLower: return extentsByTile.MinPoint.Y; case EnumCorner.LeftTop: case EnumCorner.RightTop: return extentsByTile.MaxPoint.Y; default: return 0; } }
private void сreateHatch(Extents3d extText, BlockTableRecord btr) { if (extText.Diagonal() < 100) { return; } // Отступ контура штриховки от границ текста Extents3d ext = new Extents3d(new Point3d(extText.MinPoint.X - 10, extText.MinPoint.Y - 10, 0), new Point3d(extText.MaxPoint.X + 10, extText.MaxPoint.Y + 10, 0)); var h = new Hatch(); h.SetDatabaseDefaults(btr.Database); if (!panelBtr.CaptionLayerId.IsNull) h.LayerId = panelBtr.CaptionLayerId; h.LineWeight = LineWeight.LineWeight015; h.Linetype = SymbolUtilityServices.LinetypeContinuousName; h.Color = Color.FromRgb(250, 250, 250); h.Transparency = new Transparency(80); h.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE"); h.PatternScale = 25.0; btr.AppendEntity(h); var t = btr.Database.TransactionManager.TopTransaction; t.AddNewlyCreatedDBObject(h, true); h.Associative = true; h.HatchStyle = HatchStyle.Normal; // Полилиния по контуру текста Polyline pl = new Polyline(); pl.SetDatabaseDefaults(btr.Database); pl.LineWeight = LineWeight.LineWeight015; pl.Linetype = SymbolUtilityServices.LinetypeContinuousName; pl.ColorIndex = 256; // ПоСлою if (!panelBtr.CaptionLayerId.IsNull) pl.LayerId = panelBtr.CaptionLayerId; pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0); pl.AddVertexAt(0, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0); pl.AddVertexAt(0, ext.MaxPoint.Convert2d(), 0, 0, 0); pl.AddVertexAt(0, new Point2d(ext.MinPoint.X, ext.MaxPoint.Y), 0, 0, 0); pl.Closed = true; ObjectId idPl = btr.AppendEntity(pl); t.AddNewlyCreatedDBObject(pl, true); // добавление контура полилинии в гштриховку var ids = new ObjectIdCollection(); ids.Add(idPl); h.AppendLoop(HatchLoopTypes.Default, ids); h.EvaluateHatch(true); // Замена текстов - чтобы они стали поверх штриховки. panelBtr.IdCaptionMarkSb = replaceText(panelBtr.IdCaptionMarkSb, btr); panelBtr.IdCaptionPaint = replaceText(panelBtr.IdCaptionPaint, btr); }
public static void AddError(string msg, Extents3d ext, Matrix3d trans, Icon icon = null) { var err = new Error(msg, ext, trans, icon); Errors.Add(err); }
public static void ShowEnt(this ObjectId id, Extents3d ext, Document docOrig) { Document curDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; if (docOrig != curDoc) { Application.ShowAlertDialog($"Должен быть активен документ {docOrig.Name}"); } else { if (ext.Diagonal() > 1) { docOrig.Editor.Zoom(ext); id.FlickObjectHighlight(2, 100, 100); } else { Application.ShowAlertDialog("Границы элемента не определены"); } } }