Exemplo n.º 1
0
        // 由两条尺寸界线原点、尺寸文本位置、尺寸文本和标注样式创建对齐标注的函数.
        public static ObjectId AddDimAligned(Point3d pt1, Point3d pt2, Point3d ptText, string text, ObjectId style)
        {
            AlignedDimension ent   = new AlignedDimension(pt1, pt2, ptText, text, style);
            ObjectId         entId = AppendEntity(ent);

            return(entId);
        }
Exemplo n.º 2
0
        public static void OverrideDimensionText()
        {
            // 获取当前数据库
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // 启动事务
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // 以读模式打开块表
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;
                // 以写模式打开块表记录 ModelSpace
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;
                // 创建一个对齐标注
                AlignedDimension acAliDim = new AlignedDimension();
                acAliDim.XLine1Point    = new Point3d(5, 3, 0);
                acAliDim.XLine2Point    = new Point3d(10, 3, 0);
                acAliDim.DimLinePoint   = new Point3d(7.5, 5, 0);
                acAliDim.DimensionStyle = acCurDb.Dimstyle;
                // 改写标注文字
                acAliDim.DimensionText = "The value is <>";
                // 将新对象添加到模型空间和事务
                acBlkTblRec.AppendEntity(acAliDim);
                acTrans.AddNewlyCreatedDBObject(acAliDim, true);
                // 提交修改,关闭事务
                acTrans.Commit();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draw aligned dimension
        /// </summary>
        /// <param name="start">Start of dim</param>
        /// <param name="end">End of dim</param>
        /// <param name="text">Text overide of dim</param>
        /// <param name="layerName"></param>
        /// <param name="mtextheight"></param>
        /// <param name="colour"></param>
        /// <param name="isClosed"></param>
        /// <returns></returns>
        public static Entity DrawDim(Point3d start, Point3d end, string text, string layerName, double mtextheight, double yLocationMultiplier, short colour = 255)
        {
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Database currentDB = doc.Database;

            CreateLayer(layerName, colour);
            Entity entCreated;

            using (Transaction tr = currentDB.TransactionManager.StartTransaction())
            {
                BlockTable       blckTable     = tr.GetObject(currentDB.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord blockTableRec = tr.GetObject(blckTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                AlignedDimension alignedDim    = new AlignedDimension();
                alignedDim.XLine1Point        = start;
                alignedDim.XLine2Point        = end;
                alignedDim.DimensionText      = text;
                alignedDim.Dimscale           = mtextheight;
                alignedDim.DimLinePoint       = new Point3d(((end.X - start.X) / 2), start.Y * yLocationMultiplier, 0);
                alignedDim.HorizontalRotation = 0;
                alignedDim.Layer = layerName;
                blockTableRec.AppendEntity(alignedDim);
                tr.AddNewlyCreatedDBObject(alignedDim, true);
                tr.Commit();
                entCreated = alignedDim;
            }
            return(entCreated);
        }
Exemplo n.º 4
0
        public static ObjectId Create(LineSegment3d L, double H, ObjectId DimStyleId, ObjectId LayerId)
        {
            ObjectId Return = ObjectId.Null;

            #region T
            using (Transaction T = AC.DB.TransactionManager.StartTransaction())
            {
                var BT  = T.GetObject(AC.DB.BlockTableId, OpenMode.ForRead) as BlockTable;
                var BTR = T.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                var V       = L.Direction;
                var cross_V = V.CrossProduct(Vector3d.ZAxis);

                var CP = CADUtil.GetCenterPoint3d(L);       // center point
                var DP = CADUtil.MoveP(CP, cross_V, H);     // dimension point

                var acDim = new AlignedDimension(L.StartPoint, L.EndPoint, DP, string.Empty, DimStyleId);

                acDim.DimensionStyle = DimStyleId;
                acDim.LayerId        = LayerId;

                BTR.AppendEntity(acDim);
                T.AddNewlyCreatedDBObject(acDim, true);
                Return = acDim.Id;

                T.Commit();
            }
            #endregion

            return(Return);
        }
Exemplo n.º 5
0
        private void OnBlocksSelected(List <AcBlockRef> blockRefs)
        {
            using (var trans = Ac.StartTransaction())
            {
                var ln = trans.GetObject <Polyline>(this.LineId);
                if ((ln.StartPoint.Z != 0.0) || (ln.EndPoint.Z != 0.0))
                {
                    Ac.WriteLn("WARNING: Line is not on plane (Elevation != 0.0; Z != 0)");
                }

                var ln2d = ln.ConvertTo(false);
                //ln2d.Elevation = 0;
                //foreach (Vertex2d pt in ln2d)
                //{
                //    Ac.WriteLn(pt.Position.ToString());
                //}

                foreach (var bl in blockRefs)
                {
                    var blPt2d = new Point3d(bl.Position.X, bl.Position.Y, 0.0);
                    var lnPt   = ln2d.GetClosestPointTo(blPt2d, false);
                    lnPt = new Point3d(lnPt.X, lnPt.Y, 0.0);

                    AlignedDimension dim = new AlignedDimension(blPt2d, lnPt, lnPt, null, this.DimStyleId);
                    dim.LayerId = trans.CurrentLayer.Id;

                    trans.AddEntity(dim);
                }
                ln2d.Dispose();
                trans.Commit();
            }
        }
Exemplo n.º 6
0
        public static List <ObjectId> Create(Polyline acPoly, double H, bool updown, ObjectId DimStyleId, ObjectId LayerId)
        {
            List <ObjectId> Return = new List <ObjectId>();

            using (Transaction T = AC.DB.TransactionManager.StartTransaction())
            {
                var BT  = T.GetObject(AC.DB.BlockTableId, OpenMode.ForRead) as BlockTable;
                var BTR = T.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                for (int i = 0; i < acPoly.NumberOfVertices; i++)
                {
                    try
                    {
                        var L       = acPoly.GetLineSegmentAt(i);
                        var V       = L.Direction;
                        var cross_V = V.CrossProduct(Vector3d.ZAxis);
                        var MP      = Utils.PointUtil.GetCenterP(L);     // Middle point

                        #region 폴리라인 내부에 입력되어야하는 경우
                        // updown이 true일 경우 폴리라인 외부, false인 경우 폴리라인 내부
                        if (!updown)
                        {
                            var CP = Utils.PointUtil.GetCenterP(acPoly);     // Center point

                            var p = Utils.PointUtil.Move(MP, cross_V);

                            var b = Utils.PointUtil.IsInsidePolyline(acPoly, p, false);

                            if (!b)
                            {
                                cross_V = -cross_V;
                            }
                        }
                        #endregion

                        var DP = CADUtil.MoveP(MP, cross_V, H);     // dimension point

                        var acDim = new AlignedDimension(L.StartPoint, L.EndPoint, DP, string.Empty, DimStyleId);

                        Return.Add(acDim.Id);

                        acDim.DimensionStyle = DimStyleId;
                        acDim.LayerId        = LayerId;

                        BTR.AppendEntity(acDim);
                        T.AddNewlyCreatedDBObject(acDim, true);
                    }
                    catch
                    {
                    }
                }

                T.Commit();
            }

            return(Return);
        }
Exemplo n.º 7
0
        private void UpdataDimension()
        {
            RoadwayWrapper   myRoadway = (RoadwayWrapper)Entity;
            AlignedDimension dim       = (AlignedDimension)m_dims[0].Dimension;

            dim.XLine1Point  = myRoadway.StartPoint;
            dim.XLine2Point  = mEndPt;
            dim.DimLinePoint = myRoadway.StartPoint;
        }
Exemplo n.º 8
0
        public static ObjectId AddDimAligned(Point3d pt1, Point3d pt2, Point3d ptText)
        {
            Database         workingDatabase = HostApplicationServices.WorkingDatabase;
            ObjectId         dimstyle        = workingDatabase.Dimstyle;
            string           text            = Math.Round(pt1.DistanceTo(pt2), workingDatabase.Dimdec).ToString();
            AlignedDimension ent             = new AlignedDimension(pt1, pt2, ptText, text, dimstyle);

            return(ModelSpace.AddEnt(ent));
        }
Exemplo n.º 9
0
        // 由两条尺寸界线原点和尺寸文本位置创建对齐标注的函数.
        public static ObjectId AddDimAligned(Point3d pt1, Point3d pt2, Point3d ptText)
        {
            Database         db    = HostApplicationServices.WorkingDatabase;
            ObjectId         style = db.Dimstyle;
            string           text  = Math.Round(pt1.DistanceTo(pt2), db.Dimdec).ToString();
            AlignedDimension ent   = new AlignedDimension(pt1, pt2, ptText, text, style);
            ObjectId         entId = AppendEntity(ent);

            return(entId);
        }
Exemplo n.º 10
0
        public CylinderTunnelJig(Point3d firstPt) : base(new CylinderTunnel())
        {
            mPoints = new List <Point3d>();
            mPoints.Add(firstPt);
            mPromptCounter = 0;

            m_dims = new DynamicDimensionDataCollection();
            Dimension dim1 = new AlignedDimension();

            dim1.SetDatabaseDefaults();
            m_dims.Add(new DynamicDimensionData(dim1, true, true));
            dim1.DynamicDimension = true;
        }
Exemplo n.º 11
0
        public RoadwayJig(Point3d spt, Point3d ept) : base(new RoadwayWrapper())
        {
            mStartPt       = spt;
            mEndPt         = ept;
            mPromptCounter = 0;

            m_dims = new DynamicDimensionDataCollection();
            Dimension dim1 = new AlignedDimension();

            dim1.SetDatabaseDefaults();
            m_dims.Add(new DynamicDimensionData(dim1, true, true));
            dim1.DynamicDimension = true;
        }
Exemplo n.º 12
0
        private static void AddRegDescrDimLine(Complex c1, Complex c2, double k, string dimstyle)
        {
            var db = Application.DocumentManager.MdiActiveDocument.Database;

            using (var acTrans = db.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                var acBlkTbl = (BlockTable)acTrans.GetObject(db.BlockTableId, OpenMode.ForRead);

                // Open the Block table record Model space for write
                var acBlkTblRec = (BlockTableRecord)acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                // Create the  dimension

                var qq = new Complex((c2 - c1) * Complex.polar(1.0, Math.PI / 2.0));
                qq /= qq.abs();
                qq *= k;
                qq += (c2 + c1) / 2.0;

                var acRotDim = new AlignedDimension();
                acRotDim.SetDatabaseDefaults();
                acRotDim.XLine1Point  = new Point3d(c1.real(), c1.imag(), 0);
                acRotDim.XLine2Point  = new Point3d(c2.real(), c2.imag(), 0);
                acRotDim.DimLinePoint = new Point3d(qq.real(), qq.imag(), 0);

                try
                {
                    // Open the DimStyle table for read
                    var acDimStyleTbl = (DimStyleTable)acTrans.GetObject(db.DimStyleTableId, OpenMode.ForRead);

                    var acDimStyleTblRec1 =
                        (DimStyleTableRecord)acTrans.GetObject(acDimStyleTbl[dimstyle], OpenMode.ForWrite);
                    acRotDim.SetDimstyleData(acDimStyleTblRec1);
                    acRotDim.DimensionStyle = acDimStyleTbl[dimstyle];
                }
                catch
                {
                    acRotDim.DimensionStyle = db.Dimstyle;
                }


                acRotDim.LayerId = DrawingHelper.LayerManipulator.CreateLayer("DIM", System.Drawing.Color.Red);

                // Add the new object to Model space and the transaction
                acBlkTblRec.AppendEntity(acRotDim);
                acTrans.AddNewlyCreatedDBObject(acRotDim, true);

                // Commit the changes and dispose of the transaction
                acTrans.Commit();
            }
        }
Exemplo n.º 13
0
        public void MyJigDimension()
        {
            var Doc = Application.DocumentManager.MdiActiveDocument;
            var Ed  = Doc.Editor;

            var pointRes = Ed.GetPoint(new PromptPointOptions("请输入一地个点:\n"));

            if (pointRes.Status != PromptStatus.OK)
            {
                return;
            }

            Line line = new Line()
            {
                StartPoint = pointRes.Value
            };
            AlignedDimension dim = new AlignedDimension()
            {
                XLine1Point = line.StartPoint, DimensionStyle = ObjectId.Null
            };

            JigPromptPointOptions jigOpts = new JigPromptPointOptions();

            jigOpts.BasePoint    = pointRes.Value;
            jigOpts.UseBasePoint = true;

            MyJig myJig = new MyJig();

            myJig.PromptInput(jigOpts, "输入第二个点");
            myJig.JigEnts.Add(line);
            myJig.JigEnts.Add(dim);
            myJig.SetJigUpdate((jig) =>
            {
                line.EndPoint     = jig.Point;
                dim.XLine2Point   = jig.Point;
                dim.DimensionText = line.Length.ToString();

                var centerPt = new Point3d((line.StartPoint.X + jig.Point.X) / 2, (line.StartPoint.Y + jig.Point.Y) / 2, (line.StartPoint.Z + jig.Point.Z) / 2);

                dim.DimLinePoint = centerPt + (jig.Point - line.StartPoint).GetNormal().RotateBy(Math.PI / 2, Vector3d.ZAxis) * 10;
            });

            if (myJig.Drag() != PromptStatus.OK)
            {
                return;
            }



            myJig.JigEnts.ToSpace();
        }
Exemplo n.º 14
0
        public static Vector3d GetVector(AlignedDimension dim)
        {
            var p1  = dim.XLine1Point;
            var p2  = dim.XLine2Point;
            var ls  = new LineSegment3d(p1, p2);
            var tp  = dim.TextPosition;
            var Vec = Utils.Vector.Get(p1, p2);

            var rotatedVec = Vec.RotateBy(Math.PI / 2, Vector3d.ZAxis);

            var ip = CADUtil.GetIntersectedPoint(tp, rotatedVec, ls);

            return(Utils.Vector.Get(ip, tp));
        }
Exemplo n.º 15
0
        public void Cmd1()
        {
            var line = new Line(Point3d.Origin - Vector3d.XAxis + Vector3d.YAxis * 2, Point3d.Origin + Vector3d.XAxis + Vector3d.YAxis * 2);


            line.ToSpace();

            var db = Application.DocumentManager.MdiActiveDocument.Database;

            ObjectId styleId = DBHelper.GetSymbol(db.DimStyleTableId, "LL");

            AlignedDimension dimAlign = new AlignedDimension(line.StartPoint, line.EndPoint, Point3d.Origin + Vector3d.YAxis * 1.5, null, styleId);

            dimAlign.ToSpace();
        }
Exemplo n.º 16
0
        private static void AlignDimsToLine(DocumentModifier docMdf, AlignedDimension dim, Curve c)
        {
            // 找到标注的两个顶点
            var pt2 = FindIntersect(c, dim.DimLinePoint, dim.XLine2Point);
            var pt1 = FindIntersect(c, dim.DimLinePoint + (dim.XLine1Point - dim.XLine2Point), dim.XLine1Point);

            if (pt1 != null)
            {
                dim.XLine1Point = pt1.Value;
            }
            if (pt2 != null)
            {
                dim.XLine2Point = pt2.Value;
            }
            //
        }
Exemplo n.º 17
0
        public static ObjectId AddDimAligned1(Point3d pt1, Point3d pt2, Point3d ptText, string text, ObjectId style)
        {
            AlignedDimension alignedDimension = new AlignedDimension();

            alignedDimension.SetDatabaseDefaults();
            alignedDimension.XLine1Point    = pt1;
            alignedDimension.XLine2Point    = pt2;
            alignedDimension.DimLinePoint   = ptText;
            alignedDimension.Dimlfac        = 1.0;
            alignedDimension.DimensionStyle = style;
            if (Operators.CompareString(text, "", false) != 0)
            {
                alignedDimension.DimensionText = text;
            }
            return(ModelSpace.AddEnt(alignedDimension));
        }
Exemplo n.º 18
0
        private void UpdataDimension()
        {
            CylinderTunnel Tunnel = (CylinderTunnel)Entity;

            if (m_dims.Count <= mPromptCounter)
            {
                Dimension _dim = new AlignedDimension();
                _dim.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(_dim, true, true));
                _dim.DynamicDimension = true;
            }

            AlignedDimension dim = (AlignedDimension)m_dims[mPromptCounter].Dimension;

            dim.XLine1Point  = Tunnel.BasePoints[mPromptCounter];
            dim.XLine2Point  = mPoints[mPromptCounter + 1];
            dim.DimLinePoint = Tunnel.BasePoints[mPromptCounter];
        }
Exemplo n.º 19
0
            public EllipseJig(Point3d center, Vector3d vec) : base(new Ellipse())
            {
                mCenterPt      = center;
                mNormal        = vec;
                mRadiusRatio   = 0.00001;
                mPromptCounter = 0;

                m_dims = new DynamicDimensionDataCollection();
                Dimension dim1 = new AlignedDimension();

                dim1.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim1, true, true));

                Dimension dim2 = new AlignedDimension();

                dim2.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim2, true, true));
            }
Exemplo n.º 20
0
        private void AddSlope(Point3d startPnt, Point3d endPnt)
        {
            var      dx    = endPnt.X - startPnt.X;
            var      dy    = endPnt.Y - startPnt.Y;
            var      dz    = endPnt.Z - startPnt.Z;
            Vector2d v     = new Vector2d(dx, dy);
            var      slope = dz / v.Length;

            using (var trans = Ac.StartTransaction())
            {
                var dimText          = (slope * 100).ToString("0.0") + @"%";
                AlignedDimension dim = new AlignedDimension(startPnt, endPnt, startPnt, dimText, this.DimStyleId);
                dim.LayerId = trans.CurrentLayer.Id;

                trans.AddEntity(dim);
                trans.Commit();
            }
        }
Exemplo n.º 21
0
 private void UpdataDimension()
 {
     if (mPromptCounter == 0)
     {
         Tag myTag            = (Tag)Entity;
         AlignedDimension dim = (AlignedDimension)m_dims[0].Dimension;
         dim.XLine1Point  = myTag.StartPoint;
         dim.XLine2Point  = mInflectionPt;
         dim.DimLinePoint = myTag.StartPoint;
     }
     else if (mPromptCounter == 1)
     {
         Tag myTag            = (Tag)Entity;
         AlignedDimension dim = (AlignedDimension)m_dims[1].Dimension;
         dim.XLine1Point  = myTag.InflectionPoint;
         dim.XLine2Point  = mEndPt;
         dim.DimLinePoint = myTag.InflectionPoint;
     }
 }
Exemplo n.º 22
0
 void UpdateDimensions()
 {
     if (mPromptCounter == 0)
     {
         Ellipse          myellipse = (Ellipse)Entity;
         AlignedDimension dim       = (AlignedDimension)m_dims[0].Dimension;
         dim.XLine1Point  = myellipse.Center;
         dim.XLine2Point  = mAxisPt;
         dim.DimLinePoint = myellipse.Center;
     }
     else
     {
         Ellipse          myellipse = (Ellipse)Entity;
         AlignedDimension dim2      = (AlignedDimension)m_dims[1].Dimension;
         dim2.XLine1Point  = myellipse.Center;
         dim2.XLine2Point  = acquiredPoint;
         dim2.DimLinePoint = myellipse.Center;
     }
 }
Exemplo n.º 23
0
        public static AlignedDimension DimAli(Database db, Point3d P1, Point3d P2, Point3d Pref, ObjectId dimID)
        {
            AlignedDimension AD1;


            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       blockTbl   = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord modelSpace = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                                                           OpenMode.ForWrite) as BlockTableRecord;
                AD1       = new AlignedDimension(P1, P2, Pref, "", dimID);
                AD1.Layer = "标注";
                modelSpace.AppendEntity(AD1);
                tr.AddNewlyCreatedDBObject(AD1, true);

                tr.Commit();
            }
            return(AD1);
        }
Exemplo n.º 24
0
    public crawlAcDbAlignedDimension(AlignedDimension dim)
    {
        Entity ent = (Entity)dim;

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

        this.XLine1Point  = new crawlPoint3d(dim.XLine1Point.X, dim.XLine1Point.Y, dim.XLine1Point.Z);
        this.XLine2Point  = new crawlPoint3d(dim.XLine2Point.X, dim.XLine2Point.Y, dim.XLine2Point.Z);
        this.DimLinePoint = new crawlPoint3d(dim.DimLinePoint.X, dim.DimLinePoint.Y, dim.DimLinePoint.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;
    }
Exemplo n.º 25
0
        public TagJig(Point3d spt, Point3d ipt, Point3d ept) : base(new Tag())
        {
            mStartPt       = spt;
            mInflectionPt  = ipt;
            mEndPt         = ept;
            mPromptCounter = 0;

            m_dims = new DynamicDimensionDataCollection();
            Dimension dim1 = new AlignedDimension();

            dim1.SetDatabaseDefaults();
            m_dims.Add(new DynamicDimensionData(dim1, true, true));
            dim1.DynamicDimension = true;
            Dimension dim2 = new AlignedDimension();

            dim2.SetDatabaseDefaults();
            m_dims.Add(new DynamicDimensionData(dim2, true, true));
            dim2.DynamicDimension = true;
        }
Exemplo n.º 26
0
 private void UpdataDimension()
 {
     if (mPromptCounter == 0)
     {
         StandardLineWrapper myStandardLine = (StandardLineWrapper)Entity;
         AlignedDimension    dim            = (AlignedDimension)m_dims[0].Dimension;
         //  dim.XLine1Point = myStandardLine.StartPoint;
         dim.XLine2Point = mInflectionPt;
         //  dim.DimLinePoint = myStandardLine.StartPoint;
     }
     else if (mPromptCounter == 1)
     {
         StandardLineWrapper myStandardLine = (StandardLineWrapper)Entity;
         AlignedDimension    dim            = (AlignedDimension)m_dims[1].Dimension;
         dim.XLine1Point  = myStandardLine.InflectionPoint;
         dim.XLine2Point  = mEndPt;
         dim.DimLinePoint = myStandardLine.InflectionPoint;
     }
 }
Exemplo n.º 27
0
        DimAligned()
        {
            m_db = Utils.Db.GetCurDwg();

            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            Point3d pt1, pt2;

            // get end points and angle for extension lines
            if (GetLineOrTwoPoints(out pt1, out pt2) != PromptStatus.OK)
            {
                return;
            }

            PromptPointOptions prTextPtOpts = new PromptPointOptions("\nText point");

            prTextPtOpts.UseBasePoint = true;
            prTextPtOpts.BasePoint    = Utils.Ge.Midpoint(pt1, pt2);
            PromptPointResult prTextPtRes = ed.GetPoint(prTextPtOpts);

            if (prTextPtRes.Status != PromptStatus.OK)
            {
                return;
            }

            using (AlignedDimension dim = new AlignedDimension()) {
                dim.XLine1Point = pt1;
                dim.XLine2Point = pt2;

                // TBD: dimLinePt is supposed automatically set from where
                // text was placed, unless you deliberately set the dimLinePt (and DIMFIT != 4)
                // However, it doesn't seem to work unless you set to the same as TextPosition
                // anyway.
                dim.HorizontalRotation       = GetDimHorizRotation();
                dim.UsingDefaultTextPosition = true;    // make text go where user picked
                dim.TextPosition             = prTextPtRes.Value;
                dim.DimLinePoint             = prTextPtRes.Value;

                Utils.Db.TransformToWcs(dim, m_db);
                Utils.SymTbl.AddToCurrentSpaceAndClose(dim, m_db);
            }
        }
Exemplo n.º 28
0
        public static ObjectId AlignDim(Point3d line_pt1, Point3d line_pt2, Point3d dim_pt, string text, ObjectId dimstyleid)
        {
            Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
            Database database          = mdiActiveDocument.Database;
            ObjectId result;

            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;
                    AlignedDimension alignedDimension = new AlignedDimension(line_pt1, line_pt2, dim_pt, text, dimstyleid);
                    result = blockTableRecord.AppendEntity(alignedDimension);
                    transaction.AddNewlyCreatedDBObject(alignedDimension, true);
                    transaction.Commit();
                }
            }
            return(result);
        }
Exemplo n.º 29
0
        public void cmdCreateDimension()
        {
            var doc = AcApp.DocumentManager.MdiActiveDocument;
            var ed  = doc.Editor;
            var db  = doc.Database;

            var result = ed.GetPoint("Please select a point");

            if (result.Status != PromptStatus.OK)
            {
                return;
            }
            var ptStart = result.Value;

            var result2 = ed.GetPoint("Please select a point");

            if (result2.Status != PromptStatus.OK)
            {
                return;
            }
            var ptEnd = result2.Value;

            var result3 = ed.GetPoint("Please select a point");

            if (result3.Status != PromptStatus.OK)
            {
                return;
            }
            var ptCenter = result3.Value;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var bt  = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                var ms  = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                var dim = new AlignedDimension(ptStart, ptEnd, ptCenter, "This is a sample", ObjectId.Null);
                ms.AppendEntity(dim);
                tr.AddNewlyCreatedDBObject(dim, true);

                tr.Commit();
            }
        }
Exemplo n.º 30
0
        protected override SamplerStatus Sampler(JigPrompts Prompts)
        {
            PromptPointResult promptPointResult = Prompts.AcquirePoint(new JigPromptPointOptions("\r\n请指定下一点:")
            {
                UserInputControls = 2,
                Cursor            = 2,
                BasePoint         = this.point3d_2,
                UseBasePoint      = true
            });
            Point3d       value = promptPointResult.Value;
            SamplerStatus result;

            if (value != this.point3d_3)
            {
                AlignedDimension alignedDimension = new AlignedDimension();
                alignedDimension.SetDatabaseDefaults();
                if (this.short_0 == 1)
                {
                    alignedDimension.XLine1Point = this.point3d_2;
                    alignedDimension.XLine2Point = value;
                    double  num        = this.point3d_2.GetVectorTo(value).AngleOnPlane(new Plane());
                    Point3d pointAngle = CAD.GetPointAngle(this.point3d_2, 600.0, num * 180.0 / 3.1415926535897931 + 90.0);
                    alignedDimension.DimLinePoint = pointAngle;
                }
                else if (this.short_0 == 2)
                {
                    alignedDimension.XLine1Point  = this.point3d_2;
                    alignedDimension.XLine2Point  = this.point3d_0[1];
                    alignedDimension.DimLinePoint = value;
                }
                this.entity_0[0] = alignedDimension;
                this.point3d_3   = value;
                result           = 0;
            }
            else
            {
                result = 1;
            }
            return(result);
        }
            public EllipseJig(Point3d center,Vector3d vec)
                : base(new Ellipse())
            {
                mCenterPt = center;
                mNormal = vec;
                mRadiusRatio = 0.00001;
                mPromptCounter = 0;

                m_dims = new DynamicDimensionDataCollection();
                Dimension dim1 = new AlignedDimension();
                dim1.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim1,true,true));
                dim1.DynamicDimension = true;
                Dimension dim2 = new AlignedDimension();
                dim2.SetDatabaseDefaults();
                m_dims.Add(new DynamicDimensionData(dim2,true,true));
                dim2.DynamicDimension = true;
            }