예제 #1
0
        // 由圆心、引线附着点、引线长度、尺寸文本和标注样式创建半径标注的函数.
        public static ObjectId AddDimRadial(Point3d cenPt, Point3d ptChord, double leaderLength, string text, ObjectId style)
        {
            RadialDimension ent   = new RadialDimension(cenPt, ptChord, leaderLength, text, style);
            ObjectId        entId = AppendEntity(ent);

            return(entId);
        }
예제 #2
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var plane = Plane.WorldXY;

            var cp = new Point3d(2.0, 2.0, 0.0);
            var p1 = new Point3d(4.0, 4.0, 0.0);
            var p2 = new Point3d(8.0, 6.0, 0.0);

            var style = doc.DimStyles.Current;

            if (style.LeaderContentAngleType == DimensionStyle.LeaderContentAngleStyle.Aligned)
            {
                p2.Y = 8.0;
            }

            var dim = RadialDimension.Create(style, AnnotationType.Radius, plane, cp, p1, p2);

            if (null != dim)
            {
                doc.Objects.Add(dim);
                doc.Views.Redraw();
            }

            return(Result.Success);
        }
예제 #3
0
        public static ObjectId AddDimRadial(Point3d cenPt, Point3d ptChord, double leaderLength)
        {
            Database        workingDatabase = HostApplicationServices.WorkingDatabase;
            ObjectId        dimstyle        = workingDatabase.Dimstyle;
            string          text            = "R" + Math.Round(cenPt.DistanceTo(ptChord), workingDatabase.Dimdec).ToString();
            RadialDimension ent             = new RadialDimension(cenPt, ptChord, leaderLength, text, dimstyle);

            return(ModelSpace.AddEnt(ent));
        }
예제 #4
0
        // 由圆心、引线附着点和引线长度创建半径标注的函数.
        public static ObjectId AddDimRadial(Point3d cenPt, Point3d ptChord, double leaderLength)
        {
            Database        db    = HostApplicationServices.WorkingDatabase;
            ObjectId        style = db.Dimstyle;
            string          text  = "R" + Math.Round(cenPt.DistanceTo(ptChord), db.Dimdec).ToString();
            RadialDimension ent   = new RadialDimension(cenPt, ptChord, leaderLength, text, style);
            ObjectId        entId = AppendEntity(ent);

            return(entId);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="cir"></param>
        /// <param name="angle"></param>
        /// <param name="leaderLength"></param>
        /// <returns></returns>
        public RadialDimension RadialDimension(Circle cir, double angle, double leaderLength)
        {
            Point3d         cenPt = new Point3d(cir.Center.X, cir.Center.Y, 0);
            Point3d         pt1   = new Point3d(cenPt.X + cir.Radius * Math.Cos(angle), cenPt.Y + cir.Radius * Math.Sin(angle), cenPt.Z);
            Database        db    = HostApplicationServices.WorkingDatabase;
            ObjectId        style = db.Dimstyle;
            RadialDimension ent   = new RadialDimension(cenPt, pt1, leaderLength, "<>", style);

            return(ent);
        }
예제 #6
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            ObjRef obj_ref;
            var    rc = RhinoGet.GetOneObject("Select curve for radius dimension",
                                              true, ObjectType.Curve, out obj_ref);

            if (rc != Result.Success)
            {
                return(rc);
            }
            double curve_parameter;
            var    curve = obj_ref.CurveParameter(out curve_parameter);

            if (curve == null)
            {
                return(Result.Failure);
            }

            if (curve.IsLinear() || curve.IsPolyline())
            {
                RhinoApp.WriteLine("Curve must be non-linear.");
                return(Result.Nothing);
            }

            // in this example just deal with planar curves
            if (!curve.IsPlanar())
            {
                RhinoApp.WriteLine("Curve must be planar.");
                return(Result.Nothing);
            }

            var point_on_curve   = curve.PointAt(curve_parameter);
            var curvature_vector = curve.CurvatureAt(curve_parameter);
            var len = curvature_vector.Length;

            if (len < RhinoMath.SqrtEpsilon)
            {
                RhinoApp.WriteLine("Curve is almost linear and therefore has no curvature.");
                return(Result.Nothing);
            }

            var   center = point_on_curve + (curvature_vector / (len * len));
            Plane plane;

            curve.TryGetPlane(out plane);
            var radial_dimension =
                new RadialDimension(center, point_on_curve, plane.XAxis, plane.Normal, 5.0);

            doc.Objects.AddRadialDimension(radial_dimension);
            doc.Views.Redraw();
            return(Result.Success);
        }
        public void AddEntityObject()
        {
            AddToModelSpace(DbText(new Point3d(-10, 20, 0), "fck13", 5));//创建一个基点为(0, 50, 0),文字高度为20的文字,添加到模型空间
            Line L = new Line(new Point3d(40, 0, 0), new Point3d(60, 15, 0));
            //创建直线
            OrdinateDimension ODX = OrdinateDimensionX(L.StartPoint, L.EndPoint, 10, true);

            //创建X增量标注
            AddToModelSpace(L);
            AddToModelSpace(ODX);
            Circle          C  = new Circle(Point3d.Origin, Vector3d.ZAxis, 15); //创建圆
            RadialDimension RD = RadialDimension(C, 3 * Math.PI / 4, 10);        //创建半径标注

            AddToModelSpace(C);
            AddToModelSpace(RD);
        }
예제 #8
0
    public crawlAcDbRadialDimension(RadialDimension dim)
    {
        Entity ent = (Entity)dim;

        this.ObjectId = ent.ObjectId.ToString();

        this.Center       = new crawlPoint3d(dim.Center.X, dim.Center.Y, dim.Center.Z);
        this.ChordPoint   = new crawlPoint3d(dim.ChordPoint.X, dim.ChordPoint.Y, dim.ChordPoint.Z);
        this.TextPosition = new crawlPoint3d(dim.TextPosition.X, dim.TextPosition.Y, dim.TextPosition.Z);

        this.Layer      = dim.Layer;
        this.Linetype   = dim.Linetype;
        this.LineWeight = dim.LineWeight.ToString();
        this.Color      = dim.Color.ToString();

        this.DimensionText      = dim.DimensionText;
        this.DimensionStyleName = dim.DimensionStyleName;
    }
예제 #9
0
        public static void CreateRadialDimension(Point3d _center, ObjectId _dimstyle, string _text)
        {
            Document mdiActiveDocument = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
            Database database          = mdiActiveDocument.Database;

            using (mdiActiveDocument.LockDocument())
            {
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    BlockTable       blockTable       = transaction.GetObject(database.BlockTableId, OpenMode.ForRead) as BlockTable;
                    BlockTableRecord blockTableRecord = transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                    RadialDimension  radialDimension  = new RadialDimension();
                    radialDimension.SetDatabaseDefaults();
                    radialDimension.Center         = _center;
                    radialDimension.ChordPoint     = new Point3d(_center.X + 0.1, _center.Y + 0.1, 0.0);
                    radialDimension.LeaderLength   = 0.5;
                    radialDimension.DimensionStyle = _dimstyle;
                    radialDimension.DimensionText  = _text;
                    blockTableRecord.AppendEntity(radialDimension);
                    transaction.AddNewlyCreatedDBObject(radialDimension, true);
                    transaction.Commit();
                }
            }
        }
예제 #10
0
        internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobjectIndex)
        {
            if (IntPtr.Zero == pGeometry)
            {
                return(null);
            }

            var type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);

            if (type < 0)
            {
                return(null);
            }
            GeometryBase rc = null;

            switch (type)
            {
            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Curve: //1
                rc = new Curve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsCurve: //2
                rc = new NurbsCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolyCurve: // 3
                rc = new PolyCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolylineCurve: //4
                rc = new PolylineCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ArcCurve: //5
                rc = new ArcCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_LineCurve: //6
                rc = new LineCurve(pGeometry, parent, subobjectIndex);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Mesh: //7
                rc = new Mesh(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Point: //8
                rc = new Point(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_TextDot: //9
                rc = new TextDot(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Surface: //10
                rc = new Surface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Brep: //11
                rc = new Brep(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsSurface: //12
                rc = new NurbsSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_RevSurface: //13
                rc = new RevSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PlaneSurface: //14
                rc = new PlaneSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ClippingPlaneSurface: //15
                rc = new ClippingPlaneSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Hatch: // 17
                rc = new Hatch(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SumSurface: //19
                rc = new SumSurface(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepFace: //20
            {
                int    faceindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
                if (ptr_brep != IntPtr.Zero && faceindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Faces[faceindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepEdge: // 21
            {
                int    edgeindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
                if (ptr_brep != IntPtr.Zero && edgeindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Edges[edgeindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_InstanceReference: // 23
                rc = new InstanceReferenceGeometry(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Extrusion: //24
                rc = new Extrusion(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointCloud: // 26
                rc = new PointCloud(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DetailView: // 27
                rc = new DetailView(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Light: //32
                rc = new Light(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointGrid: //33
                rc = new Point3dGrid(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_MorphControl: //34
                rc = new MorphControl(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepLoop: //35
            {
                int    loopindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
                if (ptr_brep != IntPtr.Zero && loopindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Loops[loopindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepTrim: // 36
            {
                int    trimindex = -1;
                IntPtr ptr_brep  = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
                if (ptr_brep != IntPtr.Zero && trimindex >= 0)
                {
                    Brep b = new Brep(ptr_brep, parent);
                    rc = b.Trims[trimindex];
                }
            }
            break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Leader: // 38
                rc = new Leader(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SubD: // 39
                rc = new SubD(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimLinear: //40
                rc = new LinearDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimAngular: //41
                rc = new AngularDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimRadial: //42
                rc = new RadialDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimOrdinate: //43
                rc = new OrdinateDimension(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Centermark: //44
                rc = new Centermark(pGeometry, parent);
                break;

            case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Text: //45
                rc = new TextEntity(pGeometry, parent);
                break;

            default:
                rc = new UnknownGeometry(pGeometry, parent, subobjectIndex);
                break;
            }

            return(rc);
        }
예제 #11
0
        private void MyMirror(List <Entity> listEnt, Line line, string xY)
        {
            if (listEnt == null || line == null)
            {
                return;
            }

            Line3d line3d = new Line3d(line.StartPoint, line.EndPoint);

            for (int i = 0; i < listEnt.Count; i++)
            {
                var entity = listEnt[i];

                Entity ent = entity;

                //if((ent as Dimension) != null)
                //{
                //    continue;
                //}


                if (ent is DBText || ent is MText)
                {
                    listOId.Add(ent.ToSpace(blkRef.Database));
                }
                else
                {
                    ent = entity.GetTransformedCopy(Matrix3d.Mirroring(line3d));

                    if ((ent as Dimension) == null)
                    {
                        list.Add(ent);
                    }

                    //continue;
                }

                /* var ptMin = ent.Bounds.Value.MinPoint;
                 *
                 * var ptMax = ent.Bounds.Value.MaxPoint;
                 *
                 * var w = Math.Abs(ptMax.X - ptMin.X);
                 * var h = Math.Abs(ptMax.Y - ptMin.Y);
                 *
                 * var ptCenter = new Point3d((ptMin.X + ptMax.X) / 2, (ptMin.Y + ptMax.Y) / 2, 0);*/
                if (ent is DBText)
                {
                    var a = ent as DBText;
                    MirrorText(a, line3d);
                }
                else if (ent is MText)
                {
                    var a = ent as MText;

                    MirrorText(a, line3d);
                }
                else if ((ent as Dimension) != null)
                {
                    var dim = ent as Dimension;



                    Plane p = null;

                    if (xY == "X")
                    {
                        p   = new Plane(dim.TextPosition, dim.Normal);
                        ent = dim.GetTransformedCopy(Matrix3d.Mirroring(p));
                    }
                    else if (xY == "Y")
                    {
                        p = new Plane(dim.TextPosition, dim.Normal);

                        ent = dim.GetTransformedCopy(Matrix3d.Mirroring(p));
                    }
                    if (ent is RotatedDimension)
                    {
                        var rDim = ent as RotatedDimension;

                        var rDim1 = new RotatedDimension(rDim.Rotation, rDim.XLine1Point, rDim.XLine2Point, rDim.DimLinePoint, rDim.DimensionText, rDim.DimensionStyle);
                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }

                    else if (ent is AlignedDimension)
                    {
                        var rDim = ent as AlignedDimension;

                        var rDim1 = new AlignedDimension(rDim.XLine1Point, rDim.XLine2Point, rDim.DimLinePoint, rDim.DimensionText, rDim.DimensionStyle);
                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is ArcDimension)
                    {
                        var rDim = ent as ArcDimension;

                        var rDim1 = new ArcDimension(rDim.CenterPoint, rDim.XLine1Point, rDim.XLine2Point, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle);

                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is DiametricDimension)
                    {
                        var rDim = ent as DiametricDimension;

                        var rDim1 = new DiametricDimension(rDim.ChordPoint, rDim.FarChordPoint, rDim.LeaderLength, rDim.DimensionText, rDim.DimensionStyle);

                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is LineAngularDimension2)
                    {
                        var rDim = ent as LineAngularDimension2;

                        var rDim1 = new LineAngularDimension2(rDim.XLine1Start, rDim.XLine1End, rDim.XLine2Start, rDim.XLine2End, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle);

                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is Point3AngularDimension)
                    {
                        var rDim = ent as Point3AngularDimension;

                        var rDim1 = new Point3AngularDimension(rDim.CenterPoint, rDim.XLine1Point, rDim.XLine2Point, rDim.ArcPoint, rDim.DimensionText, rDim.DimensionStyle);

                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is RadialDimension)
                    {
                        var rDim = ent as RadialDimension;

                        var rDim1 = new RadialDimension(rDim.Center, rDim.ChordPoint, rDim.LeaderLength, rDim.DimensionText, rDim.DimensionStyle);


                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                    else if (ent is RadialDimensionLarge)
                    {
                        var rDim = ent as RadialDimensionLarge;

                        var rDim1 = new RadialDimensionLarge(rDim.Center, rDim.ChordPoint, rDim.OverrideCenter, rDim.JogPoint, rDim.JogAngle, rDim.DimensionText, rDim.DimensionStyle);

                        Dim2Dim(rDim1, rDim);
                        list.Add(rDim1);
                    }
                }
            }



            listEnt.ForEach(ent => ent.Dispose());
        }
예제 #12
0
        /// <summary>
        /// 读取dwg中entities信息
        /// </summary>
        public static void GetDwgGeometry(string layerName)
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForRead);
                if (lt.Has(layerName))
                {
                    BlockTableRecord ltr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
                    int a, r, g, b = 0;
                    foreach (ObjectId objId in ltr)
                    {
                        Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForRead);

                        #region 遍历entities
                        if (ent.Layer == layerName)
                        {
                            string type = ent.GetType().ToString().Replace("Autodesk.AutoCAD.DatabaseServices.", "");
                            if (type == "Line")
                            {
                                Line line = (Line)ent;
                                //EntityLayer.Add(line.Layer);
                                //EntityType.Add(type);
                                //LineType.Add(line.Linetype);
                                a = line.Color.ColorValue.A;
                                r = line.Color.ColorValue.R;
                                g = line.Color.ColorValue.G;
                                b = line.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                EntityHandle.Add(line.Handle);
                                TextRotation.Add("null");
                                //Coordinate.Add(line.StartPoint + "," + line.EndPoint);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add(line.LineWeight);
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "AttributeDefinition")
                            {
                                AttributeDefinition attribute = (AttributeDefinition)ent;
                                //EntityLayer.Add(attribute.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(attribute.Handle);
                                //LineType.Add("null");
                                a = attribute.Color.ColorValue.A;
                                r = attribute.Color.ColorValue.R;
                                g = attribute.Color.ColorValue.G;
                                b = attribute.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(attribute.Position);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(attribute.ExtensionDictionary);
                            }
                            else if (type == "DBPoint")
                            {
                                DBPoint dbpoint = (DBPoint)ent;
                                //EntityLayer.Add(dbpoint.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(dbpoint.Handle);
                                //LineType.Add(dbpoint.Linetype);
                                a = dbpoint.Color.ColorValue.A;
                                r = dbpoint.Color.ColorValue.R;
                                g = dbpoint.Color.ColorValue.G;
                                b = dbpoint.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(dbpoint.Position);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "Ellipse")
                            {
                                Ellipse ellipse = (Ellipse)ent;
                                //EntityLayer.Add(ellipse.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(ellipse.Handle);
                                //LineType.Add("null");
                                a = ellipse.Color.ColorValue.A;
                                r = ellipse.Color.ColorValue.R;
                                g = ellipse.Color.ColorValue.G;
                                b = ellipse.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(ellipse.GetPlane().GetCoordinateSystem());
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "DBText")
                            {
                                DBText dbtext = (DBText)ent;
                                //EntityLayer.Add(dbtext.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(dbtext.Handle);
                                TextRotation.Add(dbtext.Rotation);
                                //LineType.Add("null");
                                a = dbtext.Color.ColorValue.A;
                                r = dbtext.Color.ColorValue.R;
                                g = dbtext.Color.ColorValue.G;
                                b = dbtext.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                //Coordinate.Add(dbtext.Position);
                                Text.Add(dbtext.TextString);
                                //Height.Add(dbtext.Height);
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                                if (dbtext.TextString.Contains("说明"))
                                {
                                    _position = dbtext.Position.ToString();
                                }
                            }
                            else if (type == "RadialDimension")
                            {
                                RadialDimension radial = (RadialDimension)ent;
                                //EntityLayer.Add(radial.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(radial.Handle);
                                //LineType.Add("null");
                                a = radial.Color.ColorValue.A;
                                r = radial.Color.ColorValue.R;
                                g = radial.Color.ColorValue.G;
                                b = radial.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(radial.GetPlane().GetCoordinateSystem());
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(radial.ExtensionDictionary);
                            }
                            else if (type == "AlignedDimension")
                            {
                                AlignedDimension aligned = (AlignedDimension)ent;
                                //EntityLayer.Add(aligned.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(aligned.Handle);
                                //LineType.Add("null");
                                a = aligned.Color.ColorValue.A;
                                r = aligned.Color.ColorValue.R;
                                g = aligned.Color.ColorValue.G;
                                b = aligned.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(aligned.GeometricExtents);
                                //Text.Add(aligned.TextAttachment);
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "Spline")
                            {
                                Spline spline = (Spline)ent;
                                //EntityLayer.Add(spline.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(spline.Handle);
                                //LineType.Add(spline.Linetype);
                                a = spline.Color.ColorValue.A;
                                r = spline.Color.ColorValue.R;
                                g = spline.Color.ColorValue.G;
                                b = spline.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //List<Point3d> points_spline = new List<Point3d>();
                                //for(int i = 0; i < spline.NumControlPoints; i++)
                                //{
                                //    points_spline.Add(spline.GetControlPointAt(i));
                                //}
                                //Coordinate.Add(points_spline);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add(spline.LineWeight);
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "RotatedDimension")
                            {
                                RotatedDimension rotate = (RotatedDimension)ent;
                                //EntityLayer.Add(rotate.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(rotate.Handle);
                                //LineType.Add("null");
                                a = rotate.Color.ColorValue.A;
                                r = rotate.Color.ColorValue.R;
                                g = rotate.Color.ColorValue.G;
                                b = rotate.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(rotate.GeometricExtents);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(rotate.ExtensionDictionary);
                            }
                            else if (type == "Polyline")
                            {
                                Polyline pline = (Polyline)ent;
                                //EntityLayer.Add(pline.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(pline.Handle);
                                //LineType.Add(pline.Linetype);
                                a = pline.Color.ColorValue.A;
                                r = pline.Color.ColorValue.R;
                                g = pline.Color.ColorValue.G;
                                b = pline.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //CRadius.Add("null");
                                //List<Point3d> points_polyline = new List<Point3d>();
                                //for(int i = 0; i < pline.NumberOfVertices; i++)
                                //{
                                //    points_polyline.Add(pline.GetPoint3dAt(i));
                                //}
                                //Coordinate.Add(points_polyline);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add(pline.LineWeight);
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "MText")
                            {
                                MText mtext = (MText)ent;
                                //EntityLayer.Add(mtext.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(mtext.Handle);
                                TextRotation.Add(mtext.Rotation);
                                //LineType.Add("null");
                                a = mtext.Color.ColorValue.A;
                                r = mtext.Color.ColorValue.R;
                                g = mtext.Color.ColorValue.G;
                                b = mtext.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                //Coordinate.Add(mtext.Location);
                                //Text.Add(mtext.Contents);
                                //Height.Add(mtext.Height);
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                                if (mtext.Text.Contains("说明"))
                                {
                                    _position = mtext.Location.ToString();
                                }
                            }
                            else if (type == "Arc")
                            {
                                Arc arc = (Arc)ent;
                                //EntityLayer.Add(arc.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(arc.Handle);
                                //LineType.Add("null");
                                a = arc.Color.ColorValue.A;
                                r = arc.Color.ColorValue.R;
                                g = arc.Color.ColorValue.G;
                                b = arc.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(arc.Center);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add(arc.Radius);
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "Hatch")
                            {
                                Hatch hatch = (Hatch)ent;
                                //EntityLayer.Add(hatch.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(hatch.Handle);
                                //LineType.Add("null");
                                a = hatch.Color.ColorValue.A;
                                r = hatch.Color.ColorValue.R;
                                g = hatch.Color.ColorValue.G;
                                b = hatch.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(hatch.GeometricExtents);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(hatch.ExtensionDictionary);
                            }
                            else if (type == "Dimension")
                            {
                                Dimension dim = (Dimension)ent;
                                //EntityLayer.Add(dim.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(dim.Handle);
                                //LineType.Add("null");
                                a = dim.Color.ColorValue.A;
                                r = dim.Color.ColorValue.R;
                                g = dim.Color.ColorValue.G;
                                b = dim.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(dim.TextPosition);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(dim.ExtensionDictionary);
                            }
                            else if (type == "Circle")
                            {
                                Circle circle = (Circle)ent;
                                //EntityLayer.Add(circle.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(circle.Handle);
                                //LineType.Add("null");
                                a = circle.Color.ColorValue.A;
                                r = circle.Color.ColorValue.R;
                                g = circle.Color.ColorValue.G;
                                b = circle.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(circle.Center);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add(circle.Radius);
                                //ExtenedEntity.Add("null");
                            }
                            else if (type == "BlockReference")
                            {
                                BlockReference block = (BlockReference)ent;
                                //EntityLayer.Add(block.Layer);
                                //EntityType.Add(type);
                                EntityHandle.Add(block.Handle);
                                //LineType.Add("null");
                                a = block.Color.ColorValue.A;
                                r = block.Color.ColorValue.R;
                                g = block.Color.ColorValue.G;
                                b = block.Color.ColorValue.B;
                                EntityColor.Add(RgbToHex(a, r, g, b));
                                TextRotation.Add("null");
                                //Coordinate.Add(block.GeometricExtents);
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add(block.ExtensionDictionary);
                            }
                            else
                            {
                                //EntityLayer.Add("null");
                                //EntityType.Add("null");
                                //EntityHandle.Add("null");
                                //LineType.Add("null");
                                //EntityColor.Add("null");
                                //Coordinate.Add("null");
                                //Text.Add("null");
                                //Height.Add("null");
                                //LineWidth.Add("null");
                                //CRadius.Add("null");
                                //ExtenedEntity.Add("null");
                            }
                            #endregion
                        }
                    }
                }
                trans.Commit();
            }
        }
예제 #13
0
        // draw the lower three lines
        // nFlag: dimension control
        private void DrawProfile(Plate pl, Point3d p0, int nFlag)
        {
            Point3d[] pt = new Point3d[26];  // geometry helpers
            Line[]    ln = new Line[26];     // database objects

            // create points
            pt[0]  = p0;
            pt[1]  = new Point3d(p0.X + (pl.dW - pl.R1), p0.Y, p0.Z);
            pt[2]  = new Point3d(p0.X + pl.dW, pl.R1, p0.Z);
            pt[3]  = new Point3d(pt[1].X, pt[2].Y, p0.Z);
            pt[4]  = new Point3d(pt[3].X, pt[3].Y + pl.L9, p0.Z);
            pt[5]  = new Point3d(pt[4].X + pl.L2, pt[4].Y + pl.L8, p0.Z);
            pt[6]  = new Point3d(pt[5].X, pt[5].Y + pl.L7, p0.Z);
            pt[7]  = new Point3d(pt[4].X, pt[6].Y + pl.L6, p0.Z);
            pt[8]  = new Point3d(pt[7].X, pt[7].Y + pl.L5, p0.Z);
            pt[9]  = new Point3d(p0.X + pl.L3, pt[8].Y + pl.L4, p0.Z);
            pt[10] = new Point3d(p0.X, pt[9].Y, p0.Z);

            // symmetry - create points on negative x-axis
            int k = 9;

            for (int i = 11; i < 20; i++)
            {
                pt[i] = new Point3d(-pt[k].X, pt[k].Y, pt[k].Z);
                k--;
            }

            // Draw Center symmetry symbol
            Line lnc = new Line(new Point3d(p0.X, p0.Y - 2 * pl.dT, p0.Z), new Point3d(pt[10].X, pt[10].Y + 2 * pl.dT, p0.Z));

            lnc.ColorIndex    = pl.nColor[CENTER];
            lnc.Linetype      = "DASHDOT";
            lnc.LinetypeScale = 50.0;
            AcTrans.Add(lnc);

            // create lines and store them into the database
            for (int i = 0; i < 20; i++)
            {
                if (i != 1 & i != 18)
                {
                    ln[i]            = new Line(pt[i], pt[(i + 1)]);
                    ln[i].ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(ln[i]);
                }
                else if (i == 1)
                {
                    double st_angle0  = 270 * (Math.PI / 180);
                    double end_angle0 = 0;

                    Arc a0 = new Arc(pt[3], pl.R1, st_angle0, end_angle0);
                    a0.ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(a0);

                    // create the holes dimension instance
                    RadialDimension radDim = new RadialDimension();
                    radDim.Center     = a0.Center;
                    radDim.ChordPoint = new Point3d(a0.Center.X + pl.R1,
                                                    a0.Center.Y, 0.0);
                    radDim.LeaderLength = 10.0;  // !!! not optimal
                    radDim.Dimscale     = pl.dDimScale;
                    // set current dimensionstyle
                    radDim.ColorIndex = pl.nColor[DIMENSION];
                    AcTrans.Add(radDim);
                }
                else if (i == 18)
                {
                    double st_angle1  = 180 * (Math.PI / 180);
                    double end_angle1 = 270 * (Math.PI / 180);

                    Arc a1 = new Arc(pt[17], pl.R1, st_angle1, end_angle1);
                    a1.ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(a1);
                }
                else
                {
                    continue;
                }
            }

            // draw points for centre hole
            pt[20] = new Point3d(p0.X + pl.R2, pt[3].Y + pl.R2, 0.0);
            pt[21] = new Point3d(pt[20].X, pt[7].Y - pl.R2, 0.0);
            pt[22] = new Point3d(-pt[20].X, pt[7].Y - pl.R2, 0.0);
            pt[23] = new Point3d(-(p0.X + pl.R2), pt[3].Y + pl.R2, 0.0);
            pt[24] = new Point3d(p0.X, pt[20].Y, 0.0);
            pt[25] = new Point3d(p0.X, pt[21].Y, 0.0);

            // draw lines for centre hole
            for (int i = 20; i < 24; i++)
            {
                if (i != 21 & i != 23)
                {
                    ln[i]            = new Line(pt[i], pt[(i + 1)]);
                    ln[i].ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(ln[i]);
                }
                else if (i == 21)
                {
                    double st_angle2  = 0;
                    double end_angle2 = 180 * (Math.PI / 180);

                    Arc a2 = new Arc(pt[25], pl.R2, st_angle2, end_angle2);
                    a2.ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(a2);

                    // create the holes dimension instance
                    RadialDimension radDim = new RadialDimension();
                    radDim.Center     = a2.Center;
                    radDim.ChordPoint = new Point3d(a2.Center.X + pl.R2,
                                                    a2.Center.Y, 0.0);
                    radDim.LeaderLength = 10.0;  // !!! not optimal
                    radDim.Dimscale     = pl.dDimScale;
                    // set current dimensionstyle
                    radDim.ColorIndex = pl.nColor[DIMENSION];
                    AcTrans.Add(radDim);
                }
                else if (i == 23)
                {
                    double st_angle3  = 180 * (Math.PI / 180);
                    double end_angle3 = 0;

                    Arc a3 = new Arc(pt[24], pl.R2, st_angle3, end_angle3);
                    a3.ColorIndex = pl.nColor[CONTOUR];      // 0:index
                    AcTrans.Add(a3);
                }
                else
                {
                    continue;
                }
            }
        }
예제 #14
0
        public void MyHook()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            List <Entity> entityList     = new List <Entity>();
            List <Entity> centerMarkList = new List <Entity>();
            List <Entity> MarkList       = new List <Entity>();



            Point3d pt1 = new Point3d(0, 0, 0);
            Point3d pt2 = new Point3d(5, -3, 0);
            Point3d pt3 = new Point3d(0, 70, 0);
            Point3d pt4 = new Point3d(-18, 46, 0);

            //已知圆心的圆
            Circle c1 = new Circle(pt1, Vector3d.ZAxis, 20);
            Circle c2 = new Circle(pt2, Vector3d.ZAxis, 45);
            Circle c3 = new Circle(pt3, Vector3d.ZAxis, 10);
            Circle c4 = new Circle(pt3, Vector3d.ZAxis, 20);
            Circle c5 = new Circle(pt4, Vector3d.ZAxis, 8);



            //已知两条辅助线

            Line l1 = new Line(new Point3d(5, -3 - 45, 0), new Point3d(-60, -3 - 45, 0));

            l1.ColorIndex = 2;
            Line l2 = new Line(new Point3d(5, -3 - 45 + 64, 0), new Point3d(-60, -3 - 45 + 64, 0));

            l2.ColorIndex = 2;

            //圆心线
            Line lc1x = new Line(new Point3d(-30, 0, 0), new Point3d(30, 0, 0));
            Line lc1y = new Line(new Point3d(0, -30, 0), new Point3d(0, 30, 0));
            Line lc2x = new Line(new Point3d(-30 + 5, 0 - 3, 0), new Point3d(30 + 5, 0 - 3, 0));
            Line lc2y = new Line(new Point3d(-30 + 5, 0 - 3, 0), new Point3d(30 + 5, 0 - 3, 0));
            Line lc3x = new Line(new Point3d(-30, 0 + 70, 0), new Point3d(30, 0 + 70, 0));
            Line lc3y = new Line(new Point3d(-30, 0 + 70, 0), new Point3d(30, 0 + 70, 0));


            //需要求解的圆-->弧

            //第一个切圆-->裁剪弧
            Circle            fc1 = new Circle(pt4, Vector3d.ZAxis, 8 + 18);
            Circle            fc2 = new Circle(pt3, Vector3d.ZAxis, 20 + 18);
            Point3dCollection pc  = new Point3dCollection();

            fc1.IntersectWith(fc2, Intersect.OnBothOperands, pc, new IntPtr(0), new IntPtr(0));
            fc1.Dispose();
            fc2.Dispose();
            foreach (Point3d p in pc)
            {
                if (p.X < c4.Center.X)
                {
                    double sa = new Line(p, pt4).Angle;
                    double sb = new Line(p, pt3).Angle;
                    Arc    a  = new Arc(p, 18, sa, sb);
                    entityList.Add(a);
                    //第一条弧
                    break;
                }
            }

            //第二个切圆-->裁剪弧
            Circle fc3 = new Circle(pt2, Vector3d.ZAxis, 45 + 86);
            Circle fc4 = new Circle(pt3, Vector3d.ZAxis, 20 + 86);

            pc.Clear();
            fc3.IntersectWith(fc4, Intersect.OnBothOperands, pc, new IntPtr(0), new IntPtr(0));
            fc3.Dispose();
            fc4.Dispose();
            foreach (Point3d p in pc)
            {
                if (p.X > c2.Center.X)
                {
                    double sa = new Line(p, pt3).Angle;
                    double sb = new Line(p, pt2).Angle;
                    Arc    a  = new Arc(p, 86, sa, sb);
                    entityList.Add(a);
                    //第二条弧
                    break;
                }
            }

            //第三个切圆-->裁剪弧
            Circle fc5 = new Circle(pt1, Vector3d.ZAxis, 20 + 9.7144);
            Circle fc6 = new Circle(pt2, Vector3d.ZAxis, 45 - 9.7144);

            pc.Clear();
            fc5.IntersectWith(fc6, Intersect.OnBothOperands, pc, new IntPtr(0), new IntPtr(0));
            fc5.Dispose();
            fc6.Dispose();
            foreach (Point3d p in pc)
            {
                if (p.X < c1.Center.X && p.Y < (-3 - 45 + 64))
                {
                    double sa = new Line(p, pt1).Angle;
                    double sb = new Line(pt2, p).Angle;
                    Arc    a  = new Arc(p, 9.7144, sa, sb);
                    entityList.Add(a);
                    //第三条弧
                    break;
                }
            }

            //线
            Line fl3 = new Line(new Point3d(0, -30, 0), new Point3d(0, 100, 0));

            fl3.TransformBy(Matrix3d.Rotation((Math.PI * 15 / 180), doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, fl3.EndPoint));
            Point3d fp1 = fl3.GetClosestPointTo(c1.Center, true);
            Line    l3  = new Line(c1.Center, fp1);

            pc.Clear();
            l3.IntersectWith(c1, Intersect.ExtendThis, pc, new IntPtr(0), new IntPtr(0));
            Point3d fp2 = l3.StartPoint;

            foreach (Point3d p in pc)
            {
                if (p.X > c1.Center.X)
                {
                    fp2 = p;
                    break;
                }
            }

            l3.Extend(50);
            l3.TransformBy(Matrix3d.Rotation((Math.PI * 90 / 180), doc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis, fp2));

            //l3.GetOffsetCurvesGivenPlaneNormal(Vector3d.XAxis, 18);
            Vector3d ve = new Vector3d(fp2.X, fp2.Y, fp2.Z);

            ve = ve.GetNormal();
            //DBObjectCollection lc= l3.GetOffsetCurvesGivenPlaneNormal(ve, 14);
            DBObjectCollection lc = l3.GetOffsetCurves(14);


            //第四个切圆-->弧
            Circle  fc7 = new Circle(pt4, Vector3d.ZAxis, 22);
            Point3d sc1 = new Point3d();

            foreach (Entity l in lc)
            {
                Point3dCollection fc = new Point3dCollection();
                fc7.IntersectWith(l, Intersect.ExtendBoth, fc, new IntPtr(0), new IntPtr(0));
                foreach (Point3d p in fc)
                {
                    if (p.Y < pt4.Y)
                    {
                        //Circle tmpc = new Circle(p, Vector3d.ZAxis, 14);
                        Arc a = new Arc(p, 14, new Line(pt1, fp1).Angle, new Line(p, pt4).Angle);
                        entityList.Add(a);
                        //第四条弧
                        break;
                    }
                }
            }

            //公切线修剪
            l3.StartPoint = fp2;
            l3.EndPoint   = ((Arc)(entityList[entityList.Count - 1])).StartPoint;

            //修剪c5圆-->弧
            Arc a1 = new Arc(c5.Center, c5.Radius, new Line(c5.Center, ((Arc)(entityList[0])).StartPoint).Angle, new Line(c5.Center, ((Arc)(entityList[3])).EndPoint).Angle);

            entityList.Add(a1);//第五条弧

            //修剪C2号圆-->弧
            Arc a2 = new Arc(c2.Center, c2.Radius, new Line(c2.Center, ((Arc)(entityList[2])).EndPoint).Angle, new Line(c2.Center, ((Arc)(entityList[1])).EndPoint).Angle);

            entityList.Add(a2);//第6条弧

            //修剪C4号圆-->弧
            Arc a3 = new Arc(c4.Center, c4.Radius, new Line(c4.Center, ((Arc)(entityList[1])).StartPoint).Angle, new Line(c4.Center, ((Arc)(entityList[0])).EndPoint).Angle);

            entityList.Add(a3);//第7条弧

            //修剪c1号圆-->弧
            Arc a4 = new Arc(c1.Center, c1.Radius, new Line(c1.Center, ((Arc)(entityList[2])).StartPoint).Angle, new Line(c1.Center, l3.StartPoint).Angle);

            entityList.Add(a4);//第8条弧

            //画十字线
            Point3d[] points = { pt1, pt2, pt3, pt4 };
            foreach (Point3d p in points)
            {
                Line tmpl1 = new Line(new Point3d(p.X - 20, p.Y, 0), new Point3d(p.X + 20, p.Y, 0));
                Line tmpl2 = new Line(new Point3d(p.X, p.Y - 20, 0), new Point3d(p.X, p.Y + 20, 0));
                //tmpl1.Linetype = "CENTER2";
                //tmpl2.Linetype = "CENTER2";
                tmpl1.ColorIndex = 4;
                tmpl2.ColorIndex = 4;
                centerMarkList.Add(tmpl1);
                centerMarkList.Add(tmpl2);
            }

            //标注
            //c3直径
            DiametricDimension d1 = new DiametricDimension();
            Line tmpl             = new Line(c3.Center, new Point3d(c3.Center.X - 1, c3.Center.Y + 1, 0));

            pc.Clear();
            c3.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            d1.ChordPoint    = pc[0];
            d1.FarChordPoint = pc[1];
            d1.LeaderLength  = 20;
            d1.ColorIndex    = 2;
            MarkList.Add(d1);

            //半径
            RadialDimension r1     = new RadialDimension();
            Arc             tmparc = entityList[0] as Arc;

            tmpl = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 1, tmparc.Center.Y - 0.5, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r1.Center       = tmparc.Center;
            r1.ChordPoint   = pc[1].X > pc[0].X?pc[1]:pc[0];
            r1.ColorIndex   = 2;
            r1.LeaderLength = -5;
            MarkList.Add(r1);

            RadialDimension r2 = new RadialDimension();

            tmparc = entityList[1] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X - 1, tmparc.Center.Y - 0.5, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r2.Center       = tmparc.Center;
            r2.ChordPoint   = pc[1].X > pc[0].X ? pc[0] : pc[1];
            r2.ColorIndex   = 2;
            r2.LeaderLength = -30;
            MarkList.Add(r2);

            RadialDimension r3 = new RadialDimension();

            tmparc = entityList[2] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 1, tmparc.Center.Y - 0.2, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r3.Center     = tmparc.Center;
            r3.ChordPoint = pc[1].X > pc[0].X ? pc[0] : pc[1];
            r3.ColorIndex = 2;
            MarkList.Add(r3);

            RadialDimension r4 = new RadialDimension();

            tmparc = entityList[3] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 0.35, tmparc.Center.Y + 1, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r4.Center     = tmparc.Center;
            r4.ChordPoint = pc[1].X < pc[0].X ? pc[0] : pc[1];
            r4.ColorIndex = 2;
            MarkList.Add(r4);

            RadialDimension r5 = new RadialDimension();

            tmparc = entityList[4] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 0.35, tmparc.Center.Y + 1, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r5.Center     = tmparc.Center;
            r5.ChordPoint = pc[1].X > pc[0].X ? pc[0] : pc[1];
            r5.ColorIndex = 2;
            MarkList.Add(r5);

            RadialDimension r6 = new RadialDimension();

            tmparc = entityList[5] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 1, tmparc.Center.Y - 1, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r6.Center       = tmparc.Center;
            r6.ChordPoint   = pc[1].X < pc[0].X ? pc[0] : pc[1];
            r6.ColorIndex   = 2;
            r6.LeaderLength = 20;
            MarkList.Add(r6);

            RadialDimension r7 = new RadialDimension();

            tmparc = entityList[6] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X + 1, tmparc.Center.Y + 1, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r7.Center       = tmparc.Center;
            r7.ChordPoint   = pc[1].X < pc[0].X ? pc[0] : pc[1];
            r7.ColorIndex   = 2;
            r7.LeaderLength = 20;
            MarkList.Add(r7);

            RadialDimension r8 = new RadialDimension();

            tmparc = entityList[7] as Arc;
            tmpl   = new Line(tmparc.Center, new Point3d(tmparc.Center.X - 1, tmparc.Center.Y - 1, 0));
            pc.Clear();
            tmparc.IntersectWith(tmpl, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            r8.Center       = tmparc.Center;
            r8.ChordPoint   = pc[1].X > pc[0].X ? pc[0] : pc[1];
            r8.ColorIndex   = 2;
            r8.LeaderLength = 13;
            MarkList.Add(r8);

            //对齐标注1
            AlignedDimension am1 = new AlignedDimension();

            am1.XLine1Point  = pt1;
            am1.XLine2Point  = new Point3d(5, 0, 0);
            am1.DimLinePoint = new Point3d(0, -40, 0);
            am1.ColorIndex   = 2;
            MarkList.Add(am1);

            //对齐标注2
            AlignedDimension am2 = new AlignedDimension();

            am2.XLine1Point  = pt1;
            am2.XLine2Point  = new Point3d(0, -3, 0);
            am2.DimLinePoint = new Point3d(40, 0, 0);
            am2.ColorIndex   = 2;
            MarkList.Add(am2);

            //对齐标注3
            AlignedDimension am3 = new AlignedDimension();

            am3.XLine1Point  = pt1;
            am3.XLine2Point  = new Point3d(0, 70, 0);
            am3.DimLinePoint = new Point3d(70, 30, 0);
            am3.ColorIndex   = 2;
            MarkList.Add(am3);

            //对齐标注4
            AlignedDimension am4 = new AlignedDimension();

            am4.XLine1Point  = l1.EndPoint;
            am4.XLine2Point  = l2.EndPoint;
            am4.DimLinePoint = new Point3d(-60, 0, 0);
            am4.ColorIndex   = 2;
            MarkList.Add(am4);

            //对齐标注5
            AlignedDimension am5 = new AlignedDimension();

            am5.XLine1Point  = new Point3d(0, 34, 0);
            am5.XLine2Point  = new Point3d(-18, 34, 0);
            am5.DimLinePoint = new Point3d(0, 8, 0);
            am5.ColorIndex   = 2;
            MarkList.Add(am5);

            //对齐标注6
            AlignedDimension am6 = new AlignedDimension();

            am6.XLine1Point  = new Point3d(-18, 70, 0);
            am6.XLine2Point  = new Point3d(-18, 46, 0);
            am6.DimLinePoint = new Point3d(-50, 0, 0);
            am6.ColorIndex   = 2;
            MarkList.Add(am6);

            //角度标注1
            LineAngularDimension2 lad1 = new LineAngularDimension2();

            tmpl = new Line(new Point3d(0, 0, 0), new Point3d(0, 1, 0));
            pc.Clear();
            tmpl.IntersectWith(l3, Intersect.ExtendBoth, pc, new IntPtr(0), new IntPtr(0));
            lad1.XLine2Start = pc[0];
            lad1.XLine2End   = pt1;
            lad1.XLine1Start = l3.EndPoint;
            lad1.XLine1End   = l3.StartPoint;
            lad1.ArcPoint    = new Point3d(10, 2, 0);
            lad1.ColorIndex  = 2;
            MarkList.Add(lad1);

            AddEntities(MarkList.ToArray());

            Entity[] es = { c3, l3 };
            ////AddEntities(es);
            entityList.AddRange(es);
            //组成面域
            DBObjectCollection dbc1 = new DBObjectCollection();

            foreach (Entity e in entityList)
            {
                dbc1.Add(e);
            }
            dbc1.Add(c3);

            DBObjectCollection regions = new DBObjectCollection();

            regions = Region.CreateFromCurves(dbc1);
            //doc.Editor.WriteMessage("r1{0}", dbc1regions.Count);
            Region re1 = regions[0] as Region;
            Region re2 = regions[1] as Region;

            doc.Editor.WriteMessage("r1:{0},r2:{1}", re1.Area, re2.Area);

            double area = re1.Area > re2.Area ?re1.Area - re2.Area:re2.Area - re1.Area;

            Area = area;
            doc.Editor.WriteMessage("面积{0}", area);

            //entityList.Clear();
            //entityList.Add(r1);
            //entityList.Add(r2);


            foreach (Entity e in entityList)
            {
                e.ColorIndex = 1;
            }
            entityList.Add(l1);
            entityList.Add(l2);
            AddEntities(entityList.ToArray());
            AddEntities(centerMarkList.ToArray());
        }
예제 #15
0
        public void DimTest()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                // 创建要标注的图形
                Line   line1 = new Line(new Point3d(30, 20, 0), new Point3d(120, 20, 0));
                Line   line2 = new Line(new Point3d(120, 20, 0), new Point3d(120, 40, 0));
                Line   line3 = new Line(new Point3d(120, 40, 0), new Point3d(90, 80, 0));
                Line   line4 = new Line(new Point3d(90, 80, 0), new Point3d(30, 80, 0));
                Arc    arc   = new Arc(new Point3d(30, 50, 0), 30, Math.PI / 2, Math.PI * 3 / 2);
                Circle cir1  = new Circle(new Point3d(30, 50, 0), Vector3d.ZAxis, 15);
                Circle cir2  = new Circle(new Point3d(70, 50, 0), Vector3d.ZAxis, 10);
                //将图形添加到模型空间中
                db.AddToModelSpace(line1, line2, line3, line4, arc, cir1, cir2);
                //创建一个列表,用于存储标注对象
                List <Dimension> dims = new List <Dimension>();
                // 创建转角标注(水平)
                RotatedDimension dimRotated1 = new RotatedDimension
                {
                    //指定第一条尺寸界线的附着位置
                    XLine1Point = line1.StartPoint,
                    //指定第二条尺寸界线的附着位置
                    XLine2Point = line1.EndPoint,
                    //指定尺寸线的位置
                    DimLinePoint  = GeTools.MidPoint(line1.StartPoint, line1.EndPoint).PolarPoint(-Math.PI / 2, 10),
                    DimensionText = "<>mm" //设置标注的文字为标注值+后缀mm
                };
                dims.Add(dimRotated1);     //将水平转角标注添加到列表中
                //创建转角标注(垂直)
                RotatedDimension dimRotated2 = new RotatedDimension
                {
                    Rotation = Math.PI / 2, //转角标注角度为90度,表示垂直方向
                                            //指定两条尺寸界线的附着位置和尺寸线的位置
                    XLine1Point  = line2.StartPoint,
                    XLine2Point  = line2.EndPoint,
                    DimLinePoint = GeTools.MidPoint(line2.StartPoint, line2.EndPoint).PolarPoint(0, 10)
                };
                dims.Add(dimRotated2);//将垂直转角标注添加到列表中
                //创建转角标注(尺寸公差标注)
                RotatedDimension dimRotated3 = new RotatedDimension
                {
                    //指定两条尺寸界线的附着位置和尺寸线的位置
                    XLine1Point  = line4.StartPoint,
                    XLine2Point  = line4.EndPoint,
                    DimLinePoint = GeTools.MidPoint(line4.StartPoint, line4.EndPoint).PolarPoint(Math.PI / 2, 10),
                    //设置标注的文字为标注值+堆叠文字
                    DimensionText = TextTools.StackText("<>", "+0.026", "-0.025", StackType.Tolerance, 0.7)
                };
                dims.Add(dimRotated3);//将尺寸公差标注添加到列表中
                // 创建对齐标注
                AlignedDimension dimAligned = new AlignedDimension
                {
                    //指定两条尺寸界线的附着位置和尺寸线的位置
                    XLine1Point  = line3.StartPoint,
                    XLine2Point  = line3.EndPoint,
                    DimLinePoint = GeTools.MidPoint(line3.StartPoint, line3.EndPoint).PolarPoint(Math.PI / 2, 10),
                    //设置标注的文字为标注值+公差符号
                    DimensionText = "<>" + TextSpecialSymbol.Tolerance + "0.2"
                };
                dims.Add(dimAligned);//将对齐标注添加到列表中
                // 创建半径标注
                RadialDimension dimRadial = new RadialDimension
                {
                    Center = cir1.Center, //圆或圆弧的圆心
                                          //用于附着引线的圆或圆弧上的点
                    ChordPoint   = cir1.Center.PolarPoint(GeTools.DegreeToRadian(30), 15),
                    LeaderLength = 10     //引线长度
                };
                dims.Add(dimRadial);      //将半径标注添加到列表中
                // 创建直径标注
                DiametricDimension dimDiametric = new DiametricDimension
                {
                    //圆或圆弧上第一个直径点的坐标
                    ChordPoint = cir2.Center.PolarPoint(GeTools.DegreeToRadian(45), 10),
                    //圆或圆弧上第二个直径点的坐标
                    FarChordPoint = cir2.Center.PolarPoint(GeTools.DegreeToRadian(-135), 10),
                    LeaderLength  = 0   //从 ChordPoint 到注解文字或折线处的长度
                };
                dims.Add(dimDiametric); //将直径标注添加到列表中
                // 创建角度标注
                Point3AngularDimension dimLineAngular = new Point3AngularDimension
                {
                    //圆或圆弧的圆心、或两尺寸界线间的共有顶点的坐标
                    CenterPoint = line2.StartPoint,
                    //指定两条尺寸界线的附着位置
                    XLine1Point = line1.StartPoint,
                    XLine2Point = line2.EndPoint,
                    //设置角度标志圆弧线上的点
                    ArcPoint = line2.StartPoint.PolarPoint(GeTools.DegreeToRadian(135), 10)
                };
                dims.Add(dimLineAngular);//将角度标注添加到列表中
                // 创建弧长标注,标注文字取为默认值
                ArcDimension dimArc = new ArcDimension(arc.Center, arc.StartPoint, arc.EndPoint, arc.Center.PolarPoint(Math.PI, arc.Radius + 10), "<>", db.Dimstyle);
                dims.Add(dimArc);//将弧长标注添加到列表中
                // 创建显示X轴值的坐标标注
                OrdinateDimension dimX = new OrdinateDimension
                {
                    UsingXAxis    = true,        //显示 X 轴值
                    DefiningPoint = cir2.Center, //标注点
                                                 //指定引线终点,即标注文字显示的位置
                    LeaderEndPoint = cir2.Center.PolarPoint(-Math.PI / 2, 20)
                };
                dims.Add(dimX);//将坐标标注添加到列表中
                // 创建显示Y轴值的坐标标注
                OrdinateDimension dimY = new OrdinateDimension
                {
                    UsingXAxis    = false,       //显示Y轴
                    DefiningPoint = cir2.Center, //标注点
                                                 //指定引线终点,即标注文字显示的位置
                    LeaderEndPoint = cir2.Center.PolarPoint(0, 20)
                };
                dims.Add(dimY);                       //将坐标标注添加到列表中
                foreach (Dimension dim in dims)       //遍历标注列表
                {
                    dim.DimensionStyle = db.Dimstyle; //设置标注样式为当前样式
                    db.AddToModelSpace(dim);          //将标注添加到模型空间中
                }

                trans.Commit();//提交更改
            }
        }
예제 #16
0
        private string jsonGetObjectData(ObjectId id_platf)
        {
            string result = "";

            try
            {//Всякое может случиться
                //Открываем переданный в функцию объект на чтение, преобразуем его к Entity
                Entity ent = (Entity)id_platf.GetObject(OpenMode.ForRead);

                //Далее последовательно проверяем класс объекта на соответствие классам основных примитивов

                if (id_platf.ObjectClass.Name == "AcDbLine")
                {                                                       //Если объект - отрезок (line)
                    crawlAcDbLine kline = new crawlAcDbLine((Line)ent); //Преобразуем к типу линия
                    result = jsonHelper.To <crawlAcDbLine>(kline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbPolyline")
                {//Если объект - полилиния
                    Polyline          kpLine = (Polyline)ent;
                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDb2dPolyline")
                {//2D полилиния - такие тоже попадаются
                    Polyline2d        kpLine = (Polyline2d)ent;
                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDb3dPolyline")
                {//2D полилиния - такие тоже попадаются
                    Polyline3d kpLine = (Polyline3d)ent;

                    crawlAcDbPolyline jpline = new crawlAcDbPolyline(kpLine);
                    result = jsonHelper.To <crawlAcDbPolyline>(jpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbText")
                { //Текст
                    DBText        dbtxt = (DBText)ent;
                    crawlAcDbText jtext = new crawlAcDbText(dbtxt);
                    result = jsonHelper.To <crawlAcDbText>(jtext);
                }
                else if (id_platf.ObjectClass.Name == "AcDbMText")
                {//Мтекст
                    MText          mtxt  = (MText)ent;
                    crawlAcDbMText jtext = new crawlAcDbMText(mtxt);
                    result = jsonHelper.To <crawlAcDbMText>(jtext);
                }
                else if (id_platf.ObjectClass.Name == "AcDbArc")
                {//Дуга
                    Arc          arc  = (Arc)ent;
                    crawlAcDbArc cArc = new crawlAcDbArc(arc);
                    result = jsonHelper.To <crawlAcDbArc>(cArc);
                }
                else if (id_platf.ObjectClass.Name == "AcDbCircle")
                {//Окружность
                    Circle          circle  = (Circle)ent;
                    crawlAcDbCircle cCircle = new crawlAcDbCircle(circle);
                    result = jsonHelper.To <crawlAcDbCircle>(cCircle);
                }
                else if (id_platf.ObjectClass.Name == "AcDbEllipse")
                {  //Эллипс
                    Ellipse          el   = (Ellipse)ent;
                    crawlAcDbEllipse cEll = new crawlAcDbEllipse(el);
                    result = jsonHelper.To <crawlAcDbEllipse>(cEll);
                }
                else if (id_platf.ObjectClass.Name == "AcDbAlignedDimension")
                {//Размер повернутый
                    AlignedDimension dim = (AlignedDimension)ent;

                    crawlAcDbAlignedDimension rDim = new crawlAcDbAlignedDimension(dim);
                    result = jsonHelper.To <crawlAcDbAlignedDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbRotatedDimension")
                {//Размер повернутый
                    RotatedDimension dim = (RotatedDimension)ent;

                    crawlAcDbRotatedDimension rDim = new crawlAcDbRotatedDimension(dim);
                    result = jsonHelper.To <crawlAcDbRotatedDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbPoint3AngularDimension")
                {//Угловой размер по 3 точкам
                    Point3AngularDimension dim = (Point3AngularDimension)ent;

                    crawlAcDbPoint3AngularDimension rDim = new crawlAcDbPoint3AngularDimension(dim);
                    result = jsonHelper.To <crawlAcDbPoint3AngularDimension>(rDim);
                }

                else if (id_platf.ObjectClass.Name == "AcDbLineAngularDimension2")
                {//Еще угловой размер по точкам
                    LineAngularDimension2 dim = (LineAngularDimension2)ent;

                    crawlAcDbLineAngularDimension2 rDim = new crawlAcDbLineAngularDimension2(dim);
                    result = jsonHelper.To <crawlAcDbLineAngularDimension2>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbDiametricDimension")
                {  //Размер диаметра окружности
                    DiametricDimension          dim  = (DiametricDimension)ent;
                    crawlAcDbDiametricDimension rDim = new crawlAcDbDiametricDimension(dim);
                    result = jsonHelper.To <crawlAcDbDiametricDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbArcDimension")
                {  //Дуговой размер
                    ArcDimension          dim  = (ArcDimension)ent;
                    crawlAcDbArcDimension rDim = new crawlAcDbArcDimension(dim);
                    result = jsonHelper.To <crawlAcDbArcDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbRadialDimension")
                {  //Радиальный размер
                    RadialDimension          dim  = (RadialDimension)ent;
                    crawlAcDbRadialDimension rDim = new crawlAcDbRadialDimension(dim);
                    result = jsonHelper.To <crawlAcDbRadialDimension>(rDim);
                }
                else if (id_platf.ObjectClass.Name == "AcDbAttributeDefinition")
                {  //Атрибут блока
                    AttributeDefinition ad = (AttributeDefinition)ent;

                    crawlAcDbAttributeDefinition atd = new crawlAcDbAttributeDefinition(ad);
                    result = jsonHelper.To <crawlAcDbAttributeDefinition>(atd);
                }
                else if (id_platf.ObjectClass.Name == "AcDbHatch")
                {//Штриховка
                    Teigha.DatabaseServices.Hatch htch = ent as Teigha.DatabaseServices.Hatch;

                    crawlAcDbHatch cHtch = new crawlAcDbHatch(htch);
                    result = jsonHelper.To <crawlAcDbHatch>(cHtch);
                }
                else if (id_platf.ObjectClass.Name == "AcDbSpline")
                {//Сплайн
                    Spline spl = ent as Spline;

                    crawlAcDbSpline cScpline = new crawlAcDbSpline(spl);
                    result = jsonHelper.To <crawlAcDbSpline>(cScpline);
                }
                else if (id_platf.ObjectClass.Name == "AcDbPoint")
                {//Точка
                    DBPoint        Pnt = ent as DBPoint;
                    crawlAcDbPoint pt  = new crawlAcDbPoint(Pnt);
                    result = jsonHelper.To <crawlAcDbPoint>(pt);
                }

                else if (id_platf.ObjectClass.Name == "AcDbBlockReference")
                {//Блок
                    BlockReference          blk  = ent as BlockReference;
                    crawlAcDbBlockReference cBlk = new crawlAcDbBlockReference(blk);

                    result = jsonHelper.To <crawlAcDbBlockReference>(cBlk);

                    //newDocument(id_platf, result);
                }
                else if (id_platf.ObjectClass.Name == "AcDbProxyEntity")
                {//Прокси
                    ProxyEntity pxy = ent as ProxyEntity;


                    crawlAcDbProxyEntity cBlk = new crawlAcDbProxyEntity(pxy);

                    result = jsonHelper.To <crawlAcDbProxyEntity>(cBlk);

                    DocumentFromBlockOrProxy(id_platf, result);
                }
                else if (id_platf.ObjectClass.Name == "AcDbSolid")
                {//Солид 2Д
                    Solid solid = (Solid)ent;


                    crawlAcDbSolid cSld = new crawlAcDbSolid(solid);

                    result = jsonHelper.To <crawlAcDbSolid>(cSld);
                }

                /*
                 *
                 *
                 * else if (id_platf.ObjectClass.Name == "AcDbLeader")
                 * {  //Выноска Autocad
                 * Leader ld = (Leader)ent;
                 *
                 * if (ld.EndPoint.Z != 0 || ld.StartPoint.Z != 0)
                 * {
                 * //ed.WriteMessage("DEBUG: Преобразован объект: Выноска Autocad");
                 *
                 * ld.EndPoint = new Point3d(ld.EndPoint.X, ld.EndPoint.Y, 0);
                 * ld.StartPoint = new Point3d(ld.StartPoint.X, ld.StartPoint.Y, 0);
                 *
                 * result = true;
                 * };
                 *
                 * }
                 * /*
                 * else if (id_platf.ObjectClass.Name == "AcDbPolygonMesh")
                 * {
                 * BUG: В платформе нет API для доступа к вершинам сетей AcDbPolygonMesh и AcDbPolygonMesh и AcDbSurface
                 *
                 * }
                 * else if (id_platf.ObjectClass.Name == "AcDbSolid")
                 * {
                 * BUG: Чтобы плющить Solid-ы нужны API функции 3d
                 * }
                 * else if (id_platf.ObjectClass.Name == "AcDbRegion")
                 * {
                 * Region rgn = ent as Region;
                 * BUG: нет свойств у региона
                 * }
                 *
                 */
                else
                {
                    //Если объект не входит в число перечисленных типов,
                    //то выводим в командную строку класс этого необработанного объекта

                    cDebug.WriteLine("Не могу обработать тип объекта: " + id_platf.ObjectClass.Name);
                }
            }
            catch (System.Exception ex)
            {
                //Если что-то сломалось, то в командную строку выводится ошибка
                cDebug.WriteLine("Не могу преобразовать - ошибка: " + ex.Message);
            };

            //Возвращаем значение функции
            return(result);
        }
예제 #17
0
        public static bool Clear(this Dimension obj)
        {
            bool myFlag = false;

            if (Math.Abs(obj.Elevation) >= TOLERANCE)
            {
                obj.Elevation = 0.0;
                myFlag        = true;
            }
            if (obj is AlignedDimension)
            {
                AlignedDimension myDimension = obj as AlignedDimension;
                if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine1Point = myDimension.XLine1Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine2Point = myDimension.XLine2Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.DimLinePoint.Z) >= TOLERANCE)
                {
                    myDimension.DimLinePoint = myDimension.DimLinePoint.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is ArcDimension)
            {
                ArcDimension myDimension = obj as ArcDimension;
                if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine1Point = myDimension.XLine1Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine2Point = myDimension.XLine2Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.Leader1Point.Z) >= TOLERANCE)
                {
                    myDimension.Leader1Point = myDimension.Leader1Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.Leader2Point.Z) >= TOLERANCE)
                {
                    myDimension.Leader2Point = myDimension.Leader2Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE)
                {
                    myDimension.ArcPoint = myDimension.ArcPoint.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is DiametricDimension)
            {
                DiametricDimension myDimension = obj as DiametricDimension;
                if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE)
                {
                    myDimension.ChordPoint = myDimension.ChordPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.FarChordPoint.Z) >= TOLERANCE)
                {
                    myDimension.FarChordPoint = myDimension.FarChordPoint.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is LineAngularDimension2)
            {
                LineAngularDimension2 myDimension = obj as LineAngularDimension2;
                if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE)
                {
                    myDimension.ArcPoint = myDimension.ArcPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine1End.Z) >= TOLERANCE)
                {
                    myDimension.XLine1End = myDimension.XLine1End.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine1Start.Z) >= TOLERANCE)
                {
                    myDimension.XLine1Start = myDimension.XLine1Start.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2End.Z) >= TOLERANCE)
                {
                    myDimension.XLine2End = myDimension.XLine2End.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2Start.Z) >= TOLERANCE)
                {
                    myDimension.XLine2Start = myDimension.XLine2Start.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is Point3AngularDimension)
            {
                Point3AngularDimension myDimension = obj as Point3AngularDimension;
                if (Math.Abs(myDimension.ArcPoint.Z) >= TOLERANCE)
                {
                    myDimension.ArcPoint = myDimension.ArcPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.CenterPoint.Z) >= TOLERANCE)
                {
                    myDimension.CenterPoint = myDimension.CenterPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine1Point = myDimension.XLine1Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine2Point = myDimension.XLine2Point.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is RadialDimension)
            {
                RadialDimension myDimension = obj as RadialDimension;
                if (Math.Abs(myDimension.Center.Z) >= TOLERANCE)
                {
                    myDimension.Center = myDimension.Center.ClearZ();
                    myFlag             = true;
                }
                if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE)
                {
                    myDimension.ChordPoint = myDimension.ChordPoint.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is RadialDimensionLarge)
            {
                RadialDimensionLarge myDimension = obj as RadialDimensionLarge;
                if (Math.Abs(myDimension.Center.Z) >= TOLERANCE)
                {
                    myDimension.Center = myDimension.Center.ClearZ();
                    myFlag             = true;
                }
                if (Math.Abs(myDimension.ChordPoint.Z) >= TOLERANCE)
                {
                    myDimension.ChordPoint = myDimension.ChordPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.JogPoint.Z) >= TOLERANCE)
                {
                    myDimension.JogPoint = myDimension.JogPoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.OverrideCenter.Z) >= TOLERANCE)
                {
                    myDimension.OverrideCenter = myDimension.OverrideCenter.ClearZ();
                    myFlag = true;
                }
            }
            else if (obj is RotatedDimension)
            {
                RotatedDimension myDimension = obj as RotatedDimension;
                if (Math.Abs(myDimension.DimLinePoint.Z) >= TOLERANCE)
                {
                    myDimension.DimLinePoint = myDimension.DimLinePoint.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine1Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine1Point = myDimension.XLine1Point.ClearZ();
                    myFlag = true;
                }
                if (Math.Abs(myDimension.XLine2Point.Z) >= TOLERANCE)
                {
                    myDimension.XLine2Point = myDimension.XLine2Point.ClearZ();
                    myFlag = true;
                }
            }
            return(myFlag);
        }
예제 #18
0
        public static ObjectId AddDimRadial(Point3d cenPt, Point3d ptChord, double leaderLength, string text, ObjectId style)
        {
            RadialDimension ent = new RadialDimension(cenPt, ptChord, leaderLength, text, style);

            return(ModelSpace.AddEnt(ent));
        }