示例#1
0
        public void TransformEnties()
        {
            Vector3d UserXaxis = db.Ucsxdir;
            Vector3d WXaxis    = new Vector3d(1, 0, 0);
            Vector3d Zaxis     = new Vector3d(0, 0, 1);
            double   Rangle    = UserXaxis.GetAngleTo(WXaxis);

            if (UserXaxis.Y < 0)
            {
                Zaxis = Zaxis.Negate();                                           //1.03版修改,修正角度旋转正负问题
            }
            Matrix3d Rmat = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);            //旋转矩阵

            if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X)
            {
                mIsRight = true;
                Matrix3d mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT)).PreMultiplyBy(Rmat);  //旋转矩阵左乘位移矩阵
                foreach (Entity ent in mEntities)
                {
                    ent.TransformBy(mat);
                }
            }
            else
            {
                mIsRight = false;
                Line     L   = (Line)mEntitiesL[0];
                Vector3d Vt  = new Vector3d(L.Length, 0, 0);
                Matrix3d mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) - Vt).PreMultiplyBy(Rmat);//旋转矩阵左乘位移矩阵,然后镜像矩阵左乘前结果
                foreach (Entity ent in mEntitiesL)
                {
                    ent.TransformBy(mat);
                }
            }
        }
        private static double smethod_0(Point3d point3d_0, Point3d point3d_1, Point3d point3d_2)
        {
            Vector3d vectorTo  = point3d_0.GetVectorTo(point3d_1);
            Vector3d vectorTo2 = point3d_0.GetVectorTo(point3d_2);

            return(vectorTo2.X * vectorTo.Y - vectorTo.X * vectorTo2.Y);
        }
示例#3
0
    public void TransformEnties()
    {
        Vector3d UserXaxis = db.Ucsxdir;
        Vector3d WXaxis    = new Vector3d(1, 0, 0);
        Vector3d Zaxis     = new Vector3d(0, 0, 1);
        double   Rangle    = UserXaxis.GetAngleTo(WXaxis);
        Matrix3d Rmat      = Matrix3d.Rotation(Rangle, Zaxis, mdragPT);           //旋转矩阵
        Vector3d VT        = new Vector3d(1, 1, 1);                               //插入点转换向量

        if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y >= mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(0, 0, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X < mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y >= mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(-mtableob.Width, 0, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X < mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y < mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(-mtableob.Width, -mtableob.Height, 0);
        }
        if (mdragPT.TransformBy(UCS.Inverse()).X >= mbasePT.TransformBy(UCS.Inverse()).X&& mdragPT.TransformBy(UCS.Inverse()).Y < mbasePT.TransformBy(UCS.Inverse()).Y)
        {
            VT = new Vector3d(0, -mtableob.Height, 0);
        }
        Matrix3d mat = Matrix3d.Displacement(mbasePT.GetVectorTo(mdragPT) + VT); //位移矩阵

        mtableob.TransformBy(mat.PreMultiplyBy(Rmat));                           //位移矩阵左乘旋转矩阵获得变形矩阵
    }
示例#4
0
        public static double GetAngle(Point3d basePoint, Point3d directionPoint, Point3d destinationPoint)
        {
            Vector3d baseVector        = basePoint.GetVectorTo(directionPoint);
            Vector3d destinationVector = basePoint.GetVectorTo(destinationPoint);

            double angle = baseVector.GetAngleTo(destinationVector);

            return(angle);
        }
示例#5
0
        //create vector with point selected and midpoint of line
        //crete vector with midpoint and endpoint of line
        public bool sideSelected(Point3d midPoint, Point3d endPoint, Point3d startPoint)
        {
            Vector3d vector1 = midPoint.GetVectorTo(endPoint);
            Vector3d vector2 = midPoint.GetVectorTo(startPoint);

            double ang = vector1.GetAngleTo(vector2);


            return(true);
        }
示例#6
0
        /// <summary>
        /// Перемещение объектов
        /// Открытая транзакция не требуется
        /// При отмене пользователем - объекты удаляются
        /// </summary>
        /// <param name="ed"></param>
        /// <param name="ids"></param>
        /// <param name="pt"></param>
        /// /// <param name="escErase">Удалять при нажатии Esc</param>
        /// <returns></returns>
        public static bool Drag(this Editor ed, [CanBeNull] ObjectId[] ids, Point3d pt, bool escErase)
        {
            if (ids == null || !ids.Any())
            {
                return(false);
            }
            var tolerance   = new Tolerance(0.1, 0.1);
            var selSet      = SelectionSet.FromObjectIds(ids);
            var ptInputLast = pt;
            var ppr         = ed.Drag(selSet, "\nТочка вставки:", (Point3d ptInput, ref Matrix3d mat) =>
            {
                ptInput = ptInput.FromUcsToWcs();
                if (ptInput.IsEqualTo(ptInputLast, tolerance))
                {
                    return(SamplerStatus.NoChange);
                }
                mat         = Matrix3d.Displacement(pt.GetVectorTo(ptInput));
                ptInputLast = ptInput;
                return(SamplerStatus.OK);
            });

            if (ppr.Status == PromptStatus.OK)
            {
                var ptInput = ppr.Value.FromUcsToWcs();
                using (var t = ed.Document.TransactionManager.StartTransaction())
                {
                    var mat = Matrix3d.Displacement(pt.GetVectorTo(ptInput));
                    foreach (var item in ids)
                    {
                        var ent = (Entity)item.GetObject(OpenMode.ForWrite, false, true);
                        ent.TransformBy(mat);
                    }

                    t.Commit();
                }

                ed.Regen();
                return(true);
            }

            if (escErase)
            {
                using var t = ed.Document.TransactionManager.StartTransaction();
                foreach (var id in ids)
                {
                    var ent = id.GetObject(OpenMode.ForWrite);
                    ent.Erase();
                }

                t.Commit();
            }

            ed.Regen();
            return(false);
        }
示例#7
0
        /// <summary>
        /// 判断3点是否在同一条直线上
        /// </summary>
        /// <param name="startPoint3d">起点</param>
        /// <param name="secondPoint3d">第二点</param>
        /// <param name="endPoint3d">终点</param>
        /// <returns>bool</returns>
        public static bool IsOnOneLine(this Point3d startPoint3d, Point3d secondPoint3d, Point3d endPoint3d)
        {
            Vector3d V1_2 = secondPoint3d.GetVectorTo(startPoint3d);
            Vector3d V2_3 = secondPoint3d.GetVectorTo(endPoint3d);

            if (V1_2.GetAngleTo(V2_3) == 0 || V1_2.GetAngleTo(V2_3) == Math.PI)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
        /// <summary>
        /// 判断三个点是否在同一直线上
        /// </summary>
        /// <param name="firstPoint">第一个点</param>
        /// <param name="secondPoint">第二个点</param>
        /// <param name="thirdPoint">第三个点</param>
        /// <returns></returns>
        public static bool IsOnOneLine(this Point3d firstPoint, Point3d secondPoint, Point3d thirdPoint)
        {
            Vector3d v21 = secondPoint.GetVectorTo(firstPoint);
            Vector3d v23 = secondPoint.GetVectorTo(thirdPoint);

            if (v21.GetAngleTo(v23) == 0 || v21.GetAngleTo(v23) == Math.PI)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#9
0
        public static ObjectId AddDimArc(Point3d cenPt, Point3d pt1, Point3d pt2, Point3d arcPt)
        {
            Database     workingDatabase = HostApplicationServices.WorkingDatabase;
            ObjectId     dimstyle        = workingDatabase.Dimstyle;
            Vector3d     vectorTo        = cenPt.GetVectorTo(pt1);
            Vector3d     vectorTo2       = cenPt.GetVectorTo(pt2);
            double       angleTo         = vectorTo.GetAngleTo(vectorTo2);
            double       num             = cenPt.DistanceTo(pt1);
            double       value           = angleTo * num;
            string       text            = Conversions.ToString(Math.Round(value, workingDatabase.Dimdec));
            ArcDimension ent             = new ArcDimension(cenPt, pt1, pt2, arcPt, text, dimstyle);

            return(ModelSpace.AddEnt(ent));
        }
示例#10
0
        /// <summary>
        /// 将多条直线合并去重
        /// </summary>
        public static ObjectId[] OverkillLine(this Database db, SelectionSet ss)
        {
            List <Line> rawlines = new List <Line> {
            };
            List <Line> lines    = new List <Line> {
            };

            if (ss != null)
            {
                foreach (SelectedObject obj in ss)
                {
                    if (obj != null)
                    {
                        Entity ent = obj.ObjectId.GetObject(OpenMode.ForRead) as Entity;
                        if (ent.GetType() == typeof(Line))
                        {
                            Line rawline = ent as Line;
                            rawlines.Add(rawline);
                        }
                    }
                }
            }

            foreach (Line rawline in rawlines)
            {
                Point3d  p0 = rawline.StartPoint;
                Point3d  p1 = rawline.EndPoint;
                Vector3d v  = p0.GetVectorTo(p1);

                foreach (Line subrawline in rawlines)
                {
                    if (subrawline != rawline)
                    {
                        Point3d  subp0 = subrawline.StartPoint;
                        Point3d  subp1 = subrawline.EndPoint;
                        Vector3d subv  = subp0.GetVectorTo(subp1);
                        Vector3d subv1 = p0.GetVectorTo(subp0);

                        if ((v.GetAngleTo(subv) == 0 || v.GetAngleTo(subv) == Math.PI) &&
                            (v.GetAngleTo(subv1) == 0 || v.GetAngleTo(subv1) == Math.PI))
                        {
                            subrawline.ObjectId.ChangeEntityColor(3);
                        }
                    }
                }
            }

            return(db.AddEntityToModeSpace(lines.ToArray()));
        }
示例#11
0
        /// <summary>
        /// 由三点(Point3d)创建圆
        /// </summary>
        /// <param name="pt1">点1</param>
        /// <param name="pt2">点2</param>
        /// <param name="pt3">点3</param>
        /// <returns>过三点的圆</returns>
        public static Circle Circle(Point3d pt1, Point3d pt2, Point3d pt3)
        {
            Vector3d va = pt1.GetVectorTo(pt2);
            Vector3d vb = pt1.GetVectorTo(pt3);

            if (va.GetAngleTo(vb) == 0 | va.GetAngleTo(vb) == Math.PI)
            {
                return(new Circle());
            }
            CircularArc3d geoArc = new CircularArc3d(pt1, pt2, pt3);
            Point3d       cenPt  = new Point3d(geoArc.Center.X, geoArc.Center.Y, 0);
            double        radius = geoArc.Radius;

            return(new Circle(cenPt, Vector3d.ZAxis, radius));
        }
示例#12
0
        // 由圆心、两条尺寸界线原点和尺寸文本位置创建弧长标注的函数.
        public static ObjectId AddDimArc(Point3d cenPt, Point3d pt1, Point3d pt2, Point3d arcPt)
        {
            Database     db        = HostApplicationServices.WorkingDatabase;
            ObjectId     style     = db.Dimstyle;
            Vector3d     vec1      = cenPt.GetVectorTo(pt1);
            Vector3d     vec2      = cenPt.GetVectorTo(pt2);
            double       ang       = vec1.GetAngleTo(vec2);
            double       radius    = cenPt.DistanceTo(pt1);
            double       arcLength = ang * radius;
            string       text      = (Math.Round(arcLength, db.Dimdec)).ToString();
            ArcDimension ent       = new ArcDimension(cenPt, pt1, pt2, arcPt, text, style);
            ObjectId     entId     = AppendEntity(ent);

            return(entId);
        }
示例#13
0
 public MarkJig(IEnumerable <Entity> _entityList, Point3d _basePoint)
 {
     entityList   = _entityList;
     basePoint    = _basePoint;
     currentPoint = _basePoint;
     transforms   = Matrix3d.Displacement(basePoint.GetVectorTo(currentPoint));
 }
示例#14
0
        public static void Rotate()
        {
            // move first point to second point

            var start1 = new Point3d(1, 0, 0);
            var end1   = new Point3d(2, 0, 0);

            var start2 = new Point3d(1, 0, 0);
            var end2   = new Point3d(2, 2, 0);

            var vec1 = start1.GetVectorTo(end1);
            var vec2 = start2.GetVectorTo(end2);

            var ang = vec1.GetAngleTo(vec2) * 180.0 / Math.PI;

            var mat = Matrix3d.Rotation(vec1.GetAngleTo(vec2), new Vector3d(0, 0, 1), start1);

            Program.CreatePoint(start1);
            Program.CreatePoint(start2);

            Program.CreatePoint(end1);
            Program.CreatePoint(end2);

            Program.CreatePoint(start1.TransformBy(mat));
            // Program.CreatePoint(start2.TransformBy(mat));
            Program.CreatePoint(end1.TransformBy(mat));
            //Program.CreatePoint(  end2.TransformBy(mat));

            Program.CreateLine(start1, end1);
            Program.CreateLine(start2, end2);
        }
示例#15
0
        /// <summary>
        ///     Method to get the midpoint between the current point and an input point
        /// </summary>
        /// <param name="pt1"></param>
        /// <param name="pt2"></param>
        /// <returns></returns>
        public static Point3d GetMidPoint(this Point3d pt1, Point3d pt2)
        {
            var vector       = pt1.GetVectorTo(pt2);
            var halfwayPoint = pt1 + vector * 0.5;

            return(halfwayPoint);
        }
示例#16
0
 protected override bool Update()
 {
     if (!_pointAcquired) //insert point
     {
         if (_previousInsertPoint.DistanceTo(_insertPoint) < 0.01)
         {
             return(true);
         }
         Matrix3d disp = Matrix3d.Displacement(_previousInsertPoint.GetVectorTo(_insertPoint));
         Entity.TransformBy(disp);
         _previousInsertPoint = _insertPoint;
     }
     else //scale
     {
         if (_scale < 4.0)
         {
             return(true);
         }
         if (_previousScale == _scale)
         {
             return(true);
         }
         Matrix3d scale = Matrix3d.Scaling(1 / (_previousScale / _scale), _insertPoint);
         Entity.TransformBy(scale);
         _previousScale = _scale;
     }
     return(true);
 }
示例#17
0
        public static CoordinateSystem3d GetZAxisUcsToWorld(Editor ed, Point3d basePoint, Point3d positiveZaxisPoint)
        {
            var pPt3dWCS = positiveZaxisPoint;
            var pPt3dUCS = positiveZaxisPoint;

            Plane    plane = new Plane(basePoint, basePoint.GetVectorTo(positiveZaxisPoint));
            Matrix3d ucs   = Matrix3d.PlaneToWorld(plane);
            var      cs    = ucs.CoordinateSystem3d;

            ed.WriteMessage(String.Format(" GetZAxisUcsToWorld: X={0},Y={1},Z={2}", cs.Xaxis, cs.Yaxis, cs.Zaxis));

            // Translate the point from the current UCS to the WCS
            Matrix3d newMatrix = new Matrix3d();

            newMatrix = Matrix3d.AlignCoordinateSystem(Point3d.Origin,
                                                       Vector3d.XAxis,
                                                       Vector3d.YAxis,
                                                       Vector3d.ZAxis,
                                                       ucs.CoordinateSystem3d.Origin,
                                                       ucs.CoordinateSystem3d.Xaxis,
                                                       ucs.CoordinateSystem3d.Yaxis,
                                                       ucs.CoordinateSystem3d.Zaxis);

            pPt3dWCS = pPt3dUCS.TransformBy(newMatrix);

            ed.WriteMessage("\nThe WCS coordinates are: \n" +
                            pPt3dWCS.ToString() + "\n" +
                            "\nThe UCS coordinates are: \n" +
                            pPt3dUCS.ToString());


            return(ucs.CoordinateSystem3d);
        }
示例#18
0
        moveSite(this ObjectIdCollection ids, Point3d pnt3dFrom, Point3d pnt3dTo)
        {
            Vector3d v3d = pnt3dFrom.GetVectorTo(pnt3dTo);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    foreach (ObjectId id in ids)
                    {
                        Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
                        if (ent is CogoPoint)
                        {
                            CogoPoint cgPnt    = (CogoPoint)ent;
                            Point3d   cgPntLoc = id.getCogoPntCoordinates();
                            Point3d   cgPntNew = cgPntLoc.TransformBy(Matrix3d.Displacement(v3d));
                            cgPnt.Easting  = cgPntNew.X;
                            cgPnt.Northing = cgPntNew.Y;
                        }
                        else
                        {
                            ent.TransformBy(Matrix3d.Displacement(v3d));
                        }
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Mod.cs: line: 587");
            }
        }
示例#19
0
        //更新
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
        {
            Entity ent = ents[0];

            ent.UpgradeOpen();
            if (ent is BlockReference)
            {
                BlockReference br = ent as BlockReference;
                br.Position = newPt;
                draw.Geometry.Draw(br);
            }

            v = newPt.GetVectorTo(oldPt);

            for (int i = 1; i < ents.Count; i++)
            {
                Entity entity = ents[i];
                entity.UpgradeOpen();
                if (entity is BlockReference)
                {
                    BlockReference br = entity as BlockReference;
                    br.Position = oldPts[i - 1] + v;
                    draw.Geometry.Draw(entity);
                }
            }

            return(true);
        }
        /// <summary>
        ///  复制图形 图形已经加入到图形数据库中
        /// </summary>
        /// <param name="entId">图形对象的ObjectId</param>
        /// <param name="sourcePoint">参考原点</param>
        /// <param name="targetPoint">参考目标点</param>
        public static Entity CopyEntity(this ObjectId entId, Point3d sourcePoint, Point3d targetPoint)
        {
            // 声明一个图形对象
            Entity entR;
            // 当前图形数据库
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                // 打开块表
                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
                // 打开块表记录
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForRead);
                // Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForWrite);
                // 打开图形
                Entity ent = (Entity)entId.GetObject(OpenMode.ForWrite);

                // 计算变换矩阵
                Vector3d vectoc = sourcePoint.GetVectorTo(targetPoint);
                Matrix3d mt     = Matrix3d.Displacement(vectoc);
                entR = ent.GetTransformedCopy(mt);
                btr.AppendEntity(entR);
                trans.AddNewlyCreatedDBObject(entR, true);
                // 提交事务处理
                trans.Commit();
            }
            return(entR);
        }
示例#21
0
        protected override bool WorldDraw(WorldDraw draw)
        {
            WorldGeometry geo = draw.Geometry;

            if (geo != null)
            {
                Vector3d vec  = basePoint.GetVectorTo(secondPoint);
                Matrix3d disp = Matrix3d.Displacement(this.basePoint.GetVectorTo(this.secondPoint));
                //geo.PushModelTransform(disp);
                for (int i = 0; i < blockPosition.Count; i++)
                {
                    Point3d tempPoint = blockPosition[i] + vec;
                    brefs[i].Position = tempPoint;
                    geo.Draw(brefs[i]);
                }

                for (int i = 0; i < linesPosition.Count; i++)
                {
                    Point3d tempStartPoint = linesPosition[i].Item1 + vec;
                    Point3d tempEndPoint   = linesPosition[i].Item2 + vec;

                    lines[i].StartPoint = tempStartPoint;
                    lines[i].EndPoint   = tempEndPoint;
                    geo.Draw(lines[i]);
                }
                //geo.PopModelTransform();
                return(true);
            }
            return(false);
        }
        public static Vector3d ToCadVector3d(PointN basePt, PointN destPt)
        {
            Point3d point3d  = GIS2CAD.ToCadPoint3d(basePt);
            Point3d point3d2 = GIS2CAD.ToCadPoint3d(destPt);

            return(point3d.GetVectorTo(point3d2));
        }
示例#23
0
        public static void SetZAxisUcs(Editor ed, Point3d basePoint, Point3d positiveZaxisPoint)
        {
            Plane    plane = new Plane(basePoint, basePoint.GetVectorTo(positiveZaxisPoint));
            Matrix3d ucs   = Matrix3d.PlaneToWorld(plane);

            ed.CurrentUserCoordinateSystem = ucs;
        }
示例#24
0
        /// Method to return a displacement vector - transformed by the current UCS
        /// </summary>
        /// <param name="point1">Point3d to transform from</param>
        /// <param name="point2">Point3d to transform to</param>
        /// <param name="acCurEd">The Current Working Editor</param>
        /// <returns></returns>
        public static Vector3d GetTransformedVector(this Point3d point1, Point3d point2, Editor acCurEd)
        {
            //Get the vector from point1 to point2
            var acVec3D = point1.GetVectorTo(point2);

            //Transform the vector by the current UCS and return it
            return(acVec3D.TransformBy(acCurEd.CurrentUserCoordinateSystem));
        }
示例#25
0
        private void MoveEntitiy(Transaction tr, Point3d basePt, Point3d moveTo, ObjectId id)
        {
            Vector3d vec = basePt.GetVectorTo(moveTo);
            Entity   ent = tr.GetObject(id, OpenMode.ForWrite) as Entity;

            ent.UpgradeOpen();
            ent.TransformBy(Matrix3d.Displacement(vec));
        }
示例#26
0
        /// <summary> 根据给定的参数创建出视口 </summary>
        /// <param name="docMdf"></param>
        /// <param name="layout"></param>
        /// <param name="clipCurveInModel"></param>
        /// <param name="bottomLeftPt">图框的左下角点</param>
        /// <param name="bottomRightPt">图框的右下角点</param>
        /// <param name="bottomLength"></param>
        private void CreateViewport(DocumentModifier docMdf, CoordinateSystem3d modelUcs, Layout layout, Curve clipCurveInModel,
                                    Point3d bottomLeftPt, Point3d bottomRightPt, double bottomLength)
        {
            var brt = layout.BlockTableRecordId.GetObject(OpenMode.ForRead) as BlockTableRecord;

            brt.UpgradeOpen();
            // 视口的裁剪区域,此区域可以由多段线、圆弧或样条曲线等来定义,而且曲线可以不闭合。
            var layoutClipCurve = Curve.CreateFromGeCurve(geCurve: clipCurveInModel.GetGeCurve());

            brt.AppendEntity(layoutClipCurve);
            docMdf.acTransaction.AddNewlyCreatedDBObject(layoutClipCurve, true);
            var viewExt = new AdvancedExtents3d(layoutClipCurve.GeometricExtents);
            var center  = viewExt.GetAnchor(AdvancedExtents3d.Anchor.GeometryCenter);

            // 创建视口
            Viewport acVport = new Viewport();

            brt.AppendEntity(acVport);
            docMdf.acTransaction.AddNewlyCreatedDBObject(acVport, true);
            brt.DowngradeOpen();

            // 设置视口所对应的裁剪图形
            acVport.NonRectClipEntityId = layoutClipCurve.ObjectId;
            acVport.NonRectClipOn       = true;
            acVport.On = true;  // 如果是新创建的布局,则此视口必须要先设置其 on 为true。

            // 将视口放置到不打印层
            acVport.Layer         = ACadConstants.LayerName_Defpoints;
            layoutClipCurve.Layer = ACadConstants.LayerName_Defpoints;

            // -----------------------------------------------   设置视口的显示区域
            acVport.PerspectiveOn = false;
            // ViewHeight属性– 表示视口内模型空间视图的高度。它决定的视口显示的缩放比例
            // 如果要按1:1显示,则需要将其设置为视口多段线所对应的Extents3d的高度。
            acVport.ViewHeight = viewExt.GetHeight();
            // ViewCenter属性- 表示视口内视图的观察中心。它决定的视口显示的平面定位
            // 如果要视图内容范围完全匹配多段线的区域,则需要将其设置为视口多段线的几何中心点。
            acVport.ViewCenter = center.ToXYPlane();
            //ViewHeight属性– 表示视口内模型空间视图的高度。
            acVport.ViewDirection = new Vector3d(0, 0, 1);
            // ViewTarget属性– 表示视口内视图的目标点的位置。
            acVport.ViewTarget = new Point3d(0, 0, 0);
            acVport.Locked     = true;

            // -----------------------------------------------   视口对象在布局中的定位
            // 对视口所绑定的几何曲线的平移和缩放操作可以对视口进行变换,变换过程中视口中的显示内容在布局中的位置也发生同等变换,即是将视口与其中的内容作为一个整体进行变换
            // 但是直接对acVport进行变换,并不会生效。
            var scale        = bottomLength / bottomLeftPt.DistanceTo(bottomRightPt);
            var layoutOrigin = new Point3d(0, 0, 0);
            var disp         = bottomLeftPt.GetVectorTo(layoutOrigin).Subtract(modelUcs.Origin.GetAsVector());

            docMdf.WriteNow(scale, disp, bottomLeftPt, modelUcs.Origin);
            layoutClipCurve.TransformBy(Matrix3d.Displacement(disp));
            layoutClipCurve.TransformBy(Matrix3d.Scaling(scaleAll: scale, center: (new Point3d(0, 0, 0))));
            //
            //var angle = origin.GetVectorTo(bottomRightPt).GetAngleTo(new Vector3d(1, 0, 0));
            //ViewportUtil.RotateViewport(acVport, _docMdf, layout, new Point2d(0, 0), angle);
        }
示例#27
0
        public static void MoveToAttachment(this Transaction acTrans, Entity acEnt,
                                            Enums.AttachmentPoint attachmentPoint, Point3d initPoint, double xOffset = 0, double yOffset = 0)
        {
            var ext    = acEnt.GeometricExtents;
            var extMin = ext.MinPoint;
            var extMax = ext.MaxPoint;

            var fromPoint = new Point3d();

            switch (attachmentPoint)
            {
            case Enums.AttachmentPoint.TopLeft:
                fromPoint = new Point3d(extMin.X - xOffset, extMax.Y + yOffset, 0);
                break;

            case Enums.AttachmentPoint.TopRight:
                fromPoint = new Point3d(extMax.X + xOffset, extMax.Y + yOffset, 0);
                break;

            case Enums.AttachmentPoint.BottomLeft:
                fromPoint = new Point3d(extMin.X - xOffset, extMin.Y - yOffset, 0);
                break;

            case Enums.AttachmentPoint.BottomRight:
                fromPoint = new Point3d(extMax.X + xOffset, extMin.Y - yOffset, 0);
                break;

            case Enums.AttachmentPoint.TopCenter:
                var leftTc  = new Point3d(extMin.X, extMax.Y + yOffset, 0);
                var rightTc = new Point3d(extMax.X, extMax.Y + yOffset, 0);
                fromPoint = leftTc.GetMidPoint(rightTc);
                break;

            case Enums.AttachmentPoint.BottomCenter:
                var leftBc  = new Point3d(extMin.X, extMin.Y - yOffset, 0);
                var rightBc = new Point3d(extMax.X, extMin.Y - yOffset, 0);
                fromPoint = leftBc.GetMidPoint(rightBc);
                break;

            case Enums.AttachmentPoint.LeftCenter:
                var botLc = new Point3d(extMin.X - xOffset, extMin.Y, 0);
                var topLc = new Point3d(extMin.X - xOffset, extMax.Y, 0);
                fromPoint = botLc.GetMidPoint(topLc);
                break;

            case Enums.AttachmentPoint.RightCenter:
                var botRc = new Point3d(extMax.X - xOffset, extMin.Y, 0);
                var topRc = new Point3d(extMax.X - xOffset, extMax.Y, 0);
                fromPoint = botRc.GetMidPoint(topRc);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(attachmentPoint), attachmentPoint, null);
            }

            acEnt.Upgrade();
            acEnt.TransformBy(Matrix3d.Displacement(fromPoint.GetVectorTo(initPoint)));
        }
示例#28
0
        public static void MyMove(this ObjectId entityId, Point3d originPnt, Point3d targetPnt)
        {
            Vector3d vector = targetPnt.GetVectorTo(originPnt);
            Matrix3d mt     = Matrix3d.Displacement(vector);
            var      ent    = entityId.GetObject(OpenMode.ForWrite) as Entity;

            ent.TransformBy(mt);
            ent.DowngradeOpen();
        }
示例#29
0
        /// <summary>
        /// 判断向量与x轴的夹角,x轴上方为正,下方为负
        /// </summary>
        /// <param name="startPoint">起点</param>
        /// <param name="endPoint">终点</param>
        /// <returns></returns>
        public static double GetAngleToXAxis(this Point3d startPoint, Point3d endPoint)
        {
            // 声明一个与X轴平行的向量
            Vector3d temp = new Vector3d(1, 0, 0);
            // 获取起点到终点的向量
            Vector3d VsToe = startPoint.GetVectorTo(endPoint);

            return(VsToe.Y > 0 ? temp.GetAngleTo(VsToe) : -temp.GetAngleTo(VsToe));
        }
示例#30
0
        public static double GetNormal(Editor ed, Point3d basePoint, Point3d positiveZaxisPoint)
        {
            Plane    plane = new Plane(basePoint, basePoint.GetVectorTo(positiveZaxisPoint));
            Matrix3d ucs   = Matrix3d.PlaneToWorld(plane);

            ed.WriteMessage(String.Format("Normal" + ucs.Normal));

            return(ucs.Normal);
        }
示例#31
0
        /// <summary>
        /// Перемещение объектов
        /// Открытая транзакция не требуется
        /// При отмене пользователем - объекты удаляются
        /// </summary>
        /// <param name="ed"></param>
        /// <param name="ids"></param>
        /// <param name="pt"></param>
        /// <returns></returns>
        public static bool Drag(this Editor ed, ObjectId[] ids, Point3d pt)
        {
            if (ids == null || !ids.Any()) return false;
            SelectionSet selSet = SelectionSet.FromObjectIds(ids);
            PromptPointResult ppr = ed.Drag(selSet, "\nТочка вставки:", (Point3d ptInput, ref Matrix3d mat) =>
            {
                if (ptInput.IsEqualTo(pt)) return SamplerStatus.NoChange;
                mat = Matrix3d.Displacement(pt.GetVectorTo(ptInput));
                //pt = ptInput;
                return SamplerStatus.OK;
            });

            if (ppr.Status == PromptStatus.OK)
            {
                using (var t = ed.Document.TransactionManager.StartTransaction())
                {
                    foreach (var item in ids)
                    {
                        var mat = Matrix3d.Displacement(pt.GetVectorTo(ppr.Value));
                        var ent = item.GetObject(OpenMode.ForWrite, false, true) as Entity;
                        ent.TransformBy(mat);
                    }
                    t.Commit();
                }

                return true;
            }
            else
            {
                using (var t = ed.Document.TransactionManager.StartTransaction())
                {
                    foreach (var id in ids)
                    {
                        var ent = id.GetObject(OpenMode.ForWrite);
                        ent.Erase();
                    }
                    t.Commit();
                }
                return false;
            }
        }
        /// <summary>
        /// 绘制梁图
        /// </summary>
        private void DrawBeamSlab()
        {
            supportPointsL = new List<Point3d>();
            supportPointsR = new List<Point3d>();
            //---如果是调试位置,可以打开图块的外边框 IsDrawBlockBorder = true;

            if (user_curveZX == null || user_cvBoardUp == null || user_cvBoardDn == null || user_pierline1 == null || user_pierline2 == null)
            {
                System.Windows.Forms.MessageBox.Show("未选择线。");
                return;
            }

            xPoint1 = AcadAssist.GetIntersectionPoint(user_curveZX, user_pierline1);
            xPoint2 = AcadAssist.GetIntersectionPoint(user_curveZX, user_pierline2);
            Vector3d vectRotate1 = xPoint1.GetVectorTo(xPoint2);
            //double rotate1Angle = vectRotate1.AngleOnPlane(user_curveZX.GetPlane());
            rotate1Angle = AcadAssist.AngleOnPlan(vectRotate1, user_curveZX);

            curveZX2 = AcadAssist.ConvertToTxPolyline(user_curveZX);
            cvBoardUp2 = AcadAssist.ConvertToTxPolyline(user_cvBoardUp);
            cvBoardDn2 = AcadAssist.ConvertToTxPolyline(user_cvBoardDn);
            pierline12 = (TxLine)user_pierline1.Clone();
            pierline22 = (TxLine)user_pierline2.Clone();
            curveZX2.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1);
            cvBoardUp2.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1);
            cvBoardDn2.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1);
            pierline12.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1);
            pierline22.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1);

            m_storeCLines2 = new List<TxLine>();
            for (int i = 0; i < user_storedCLines.Count; i++)
            {
                m_storeCLines2.Add((TxLine)user_storedCLines[i].Clone());
                m_storeCLines2[i].TransformBy(Matrix3d.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1));
            }

            m_hgbLines2 = new List<TxLine>();
            for (int i = 0; i < user_hgbLines.Count; i++)
            {
                m_hgbLines2.Add((TxLine)user_hgbLines[i].Clone());
                m_hgbLines2[i].TransformBy(Matrix3d.Rotation(-rotate1Angle, Vector3d.ZAxis, xPoint1));
            }

            if (curveZX2.StartPoint.X > curveZX2.EndPoint.X)
                curveZX2 = AcadAssist.ReverseTxPolyline(curveZX2);

            if (cvBoardUp2.StartPoint.X > cvBoardUp2.EndPoint.X)
                cvBoardUp2 = AcadAssist.ReverseTxPolyline(cvBoardUp2);

            if (cvBoardDn2.StartPoint.X > cvBoardDn2.EndPoint.X)
                cvBoardDn2 = AcadAssist.ReverseTxPolyline(cvBoardDn2);

            if (pierline12.StartPoint.Y > pierline12.EndPoint.Y)
                pierline12 = AcadAssist.ReverseTxLine(pierline12);

            if (pierline22.StartPoint.Y > pierline22.EndPoint.Y)
                pierline22 = AcadAssist.ReverseTxLine(pierline22);

            try
            {
                #region 绘制总体构造信息  [道路设计线,伸缩缝中心线,桩号,墩号,墩位,板梁端部线]
                //-------------前面还有个中心线的相交-------不相交有没有处理过,是不是已经延长过了,不记得了;这个是新加上的----------
                List<Point3d> milePoints1 = AcadAssist.GetIntersectionPoints(curveZX2, pierline12);
                List<Point3d> milePoints2 = AcadAssist.GetIntersectionPoints(curveZX2, pierline22);
                if (milePoints1.Count == 0 || milePoints2.Count == 0) System.Windows.Forms.MessageBox.Show("分控线和桥梁边线没有交点");

                milePoint1 = AcadAssist.GetIntersectionPoint(curveZX2, pierline12);
                milePoint2 = AcadAssist.GetIntersectionPoint(curveZX2, pierline22);

                //伸缩缝中心线线转化为线段
                pierline1x = AcadAssist.LineToBorder(pierline12, cvBoardUp2, cvBoardDn2);
                pierline2x = AcadAssist.LineToBorder(pierline22, cvBoardUp2, cvBoardDn2);

                //道路设计线
                block.AddLine(pierline1x, CommonLayer.cenlayer);
                block.AddLine(pierline2x, CommonLayer.cenlayer);
                TxCurve centerLine = AcadAssist.CurveToBorder(curveZX2, pierline12, pierline22);
                Point3d centerLineMidPoint = centerLine.GetPointAtDist(centerLine.GetDistAtPoint(centerLine.EndPoint) * 0.7);
                Vector3d centerLineMidVect = AcadAssist.GetFirstDerivative(centerLine, centerLineMidPoint);
                centerLine = AcadAssist.ExtendCurve(centerLine, 8 * block.style.BlockScale);
                block.AddCurve(centerLine, CommonLayer.cenlayer);

                //板梁端部线   [伸缩缝附近横桥向端线]
                endLine1 = AcadAssist.OffsetLineToBoarder(pierline12, -m_glWidth1 * m_drawScale, cvBoardUp2, cvBoardDn2);
                endLine2 = AcadAssist.OffsetLineToBoarder(pierline22, +m_glWidth2 * m_drawScale, cvBoardUp2, cvBoardDn2);
                if (endLine1.StartPoint.Y > endLine1.EndPoint.Y) endLine1 = AcadAssist.ReverseTxLine(endLine1);
                if (endLine2.StartPoint.Y > endLine2.EndPoint.Y) endLine2 = AcadAssist.ReverseTxLine(endLine2);

                //空心板横桥向端线
                block.AddLine(endLine1, CommonLayer.gz1layer);
                block.AddLine(endLine2, CommonLayer.gz1layer);

                //转角---以后对齐,标注等都要用
                TxLine alignLine = new TxLine(AcadAssist.Mid(endLine1.StartPoint, endLine1.EndPoint), AcadAssist.Mid(endLine2.StartPoint, endLine2.EndPoint));
                Vector3d vectRotate = alignLine.StartPoint.GetVectorTo(alignLine.EndPoint);
                startLineAngle = AcadAssist.AngleOnPlan(vectRotate, alignLine);
                #endregion

                //最外侧板梁边线--------边板悬臂外边线
                cvBoardUpx = AcadAssist.CurveToBorder(cvBoardUp2, endLine1, endLine2);
                cvBoardDnx = AcadAssist.CurveToBorder(cvBoardDn2, endLine1, endLine2);
                block.AddCurve(cvBoardUpx, CommonLayer.gz1layer);
                block.AddCurve(cvBoardDnx, CommonLayer.gz1layer);

                //计算辅助点(去掉悬臂后的空心板边板外侧线的点)
                //  kxb_bb1_point1             kxb_bb1_point2
                //     -------------------------
                //     |                       |
                //     |                       |
                //     |                       |
                //     -------------------------
                //  kxb_bb2_point1             kxb_bb2_point2

                #region 初始板梁块数
                TxLine borderLineS = new TxLine(cvBoardUpx.StartPoint, cvBoardUpx.EndPoint);
                TxLine offsetBordS1 = AcadAssist.OffsetLineToBoarder(borderLineS, -m_initWsideLS * m_drawScale, endLine1, endLine2);
                TxLine offsetBordS2 = AcadAssist.OffsetLineToBoarder(borderLineS, -m_initWsideRS * m_drawScale, endLine1, endLine2);
                TxLine centerLineS1 = new TxLine(offsetBordS1.StartPoint, offsetBordS2.EndPoint);

                TxLine borderLineX = new TxLine(cvBoardDnx.StartPoint, cvBoardDnx.EndPoint);
                TxLine offsetBordX1 = AcadAssist.OffsetLineToBoarder(borderLineX, m_initWsideLX * m_drawScale, endLine1, endLine2);
                TxLine offsetBordX2 = AcadAssist.OffsetLineToBoarder(borderLineX, m_initWsideRX * m_drawScale, endLine1, endLine2);
                TxLine centerLineX1 = new TxLine(offsetBordX1.StartPoint, offsetBordX2.EndPoint);

                double distBorderL = centerLineS1.StartPoint.DistanceTo(centerLineX1.StartPoint);
                double distBorderR = centerLineS1.EndPoint.DistanceTo(centerLineX1.EndPoint);
                double Wone = m_initWone * m_drawScale;
                double Wsum = Math.Min(distBorderL, distBorderR) + Wone;
                double initWsjf2 = m_initWsjf * m_drawScale;
                boxCount = AcadAssist.CalBeamCountCombineSjf(Wsum, Wone, initWsjf2, Wone * 0.5);
                #endregion

                sideLines = new List<TxLine>();
                cenLines = new List<TxLine>();

                #region 定义梁中心线
                if (drawingMode == DrawingMode.AUTO)
                {
                    //箱梁划板[按照boxCount*(Wone+sjfW1/2)+Wone的原则]
                    sideLines.Clear();
                    cenLines.Clear();

                    List<Point3d> divPointL = AcadAssist.SplitLineByCount(centerLineX1.StartPoint, centerLineS1.StartPoint, boxCount - 1);
                    List<Point3d> divPointR = AcadAssist.SplitLineByCount(centerLineX1.EndPoint, centerLineS1.EndPoint, boxCount - 1);
                    for (int i = 0; i < divPointL.Count; i++)
                    {
                        cenLines.Add(new TxLine(divPointL[i], divPointR[i]));
                    }

                    for (int i = 0; i < cenLines.Count; i++)
                    {
                        sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], -Wone * 0.5, endLine1, endLine2));
                        sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], +Wone * 0.5, endLine1, endLine2));
                    }

                    //加上两个边梁d的中心线和内边线
                    cenLines.Add(centerLineX1);
                    cenLines.Add(centerLineS1);
                    sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineX1, +Wone * 0.5, endLine1, endLine2));
                    sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineS1, -Wone * 0.5, endLine1, endLine2));

                    if (isAdjustSJFW)
                    {
                        ///--------求出各湿接缝长度------------------
                        CompairTxLineStartY compairY1 = new CompairTxLineStartY();
                        sideLines.Sort(compairY1);
                        cenLines.Sort(compairY1);
                        List<double> sjfWidthBefore1 = new List<double>();//调整前湿接缝左宽度表
                        List<double> sjfWidthBefore2 = new List<double>();//调整前湿接缝右宽度表
                        int sjfCount = sideLines.Count / 2;//sidLine是梁边线(除边梁外边线)--数量是(中板数+1)*2==湿接缝数*2
                        for (int i = 0; i < sjfCount; i++)
                        {
                            double sjfWWW1 = sideLines[i * 2].StartPoint.DistanceTo(sideLines[i * 2 + 1].StartPoint);
                            double sjfWWW2 = sideLines[i * 2].EndPoint.DistanceTo(sideLines[i * 2 + 1].EndPoint);
                            sjfWidthBefore1.Add(sjfWWW1);
                            sjfWidthBefore2.Add(sjfWWW2);
                        }

                        double sjfWidth1Ave = MTL_Math.Math2.sum(sjfWidthBefore1) / sjfWidthBefore1.Count;
                        double sjfWidth2Ave = MTL_Math.Math2.sum(sjfWidthBefore2) / sjfWidthBefore2.Count;
                        List<double> adjustSjfW1 = new List<double>();//湿接缝左宽度调整量表
                        List<double> adjustSjfW2 = new List<double>();//湿接缝右宽度调整量表
                        for (int i = 0; i < sjfWidthBefore1.Count - 1; i++)
                        {
                            adjustSjfW1.Add(-(sjfWidthBefore1[i] - sjfWidth1Ave));
                            adjustSjfW2.Add(-(sjfWidthBefore1[i] - sjfWidth1Ave));
                        }
                        sideLines.Clear();
                        cenLines.Clear();

                        //-----自动均匀调整湿接缝的宽度-----------------
                        List<Point3d> divPointLx = this.AdjustSjfW(centerLineX1.StartPoint, centerLineS1.StartPoint, boxCount - 1, adjustSjfW1);
                        List<Point3d> divPointRx = this.AdjustSjfW(centerLineX1.EndPoint, centerLineS1.EndPoint, boxCount - 1, adjustSjfW2);
                        for (int i = 0; i < divPointL.Count; i++)
                        {
                            cenLines.Add(new TxLine(divPointLx[i], divPointRx[i]));
                        }

                        for (int i = 0; i < cenLines.Count; i++)
                        {
                            sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], -Wone * 0.5, endLine1, endLine2));
                            sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], +Wone * 0.5, endLine1, endLine2));
                        }
                        //加上两个边梁d的中心线和内边线
                        cenLines.Add(centerLineX1);
                        cenLines.Add(centerLineS1);
                        sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineX1, +Wone * 0.5, endLine1, endLine2));
                        sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineS1, -Wone * 0.5, endLine1, endLine2));
                    }
                }
                else if (drawingMode == DrawingMode.USER_CENTER)
                {
                    sideLines.Clear();
                    cenLines.Clear();
                    for (int i = 0; i < m_storeCLines2.Count; i++)
                    {
                        TxLine tempLine = AcadAssist.LineToBorder(m_storeCLines2[i], endLine1, endLine2);
                        cenLines.Add(tempLine);
                    }
                    CompairTxLineStartY compairY1 = new CompairTxLineStartY();
                    cenLines.Sort(compairY1);

                    //-----与前面自动确定中心线后形成的梁边线的代码相同--------------
                    for (int i = 0; i < cenLines.Count; i++)
                    {
                        if (i != 0)
                        {
                            sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], -Wone * 0.5, endLine1, endLine2));
                        }
                        if (i != cenLines.Count - 1)
                        {
                            sideLines.Add(AcadAssist.OffsetLineToBoarder(cenLines[i], +Wone * 0.5, endLine1, endLine2));
                        }
                    }
                    //加上两个边梁d的中心线和内边线
                    //cenLines.Add(centerLineX1);
                    //cenLines.Add(centerLineS1);
                    //sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineX1, +Wone * 0.5, endLine1, endLine2));
                    //sideLines.Add(AcadAssist.OffsetLineToBoarder(centerLineS1, -Wone * 0.5, endLine1, endLine2));
                    //-----与前面自动确定中心线后形成的梁边线的代码相同--------------
                }
                else
                {
                    //箱梁划板[按照文字定义的梁宽和湿接缝宽]
                    sideLines.Clear();
                    //double offsetX1 = -distX1;
                    //double offsetX2 = -distX2;
                    //List<double> XwidthOffsetL = MTL_Math.ParseString.ParaseToDouble(widthOffsetL);
                    //List<double> XwidthOffsetR = MTL_Math.ParseString.ParaseToDouble(widthOffsetR);
                    //List<double> XwidthOffsetJfL = MTL_Math.ParseString.ParaseToDouble(widthOffsetSjfL);
                    //List<double> XwidthOffsetJfR = MTL_Math.ParseString.ParaseToDouble(widthOffsetSjfR);
                    //if ((XwidthOffsetL.Count != XwidthOffsetR.Count) || (XwidthOffsetL.Count != XwidthOffsetJfL.Count + 1)
                    //    || (XwidthOffsetR.Count != XwidthOffsetJfR.Count + 1))
                    //{
                    //    System.Windows.Forms.MessageBox.Show("板梁个数与湿接缝个数不一致,请修改数据");
                    //    return;
                    //}
                    //for (int i = 0; i < XwidthOffsetL.Count; i++)
                    //{
                    //    double beamWSumLeft = XwidthOffsetL[i];
                    //    double beamWSumRigt = XwidthOffsetR[i];

                    //    //偏移半块板的宽度---求出梁中心线
                    //    double beamWDnLeft = (i == 0) ? (beamWSumLeft - initWsideI2) : ((i == boxCount - 1) ? initWsideI2 : (beamWSumLeft * 0.5));
                    //    double beamWDnRigt = (i == 0) ? (beamWSumRigt - initWsideI2) : ((i == boxCount - 1) ? initWsideI2 : (beamWSumRigt * 0.5));
                    //    TxLine offsetLine1 = AcadAssist.OffsetLineToBoarder(startLine2, (offsetX1 + beamWDnLeft) , endLine1, endLine2);
                    //    TxLine offsetLine2 = AcadAssist.OffsetLineToBoarder(startLine2, (offsetX2 + beamWDnRigt) , endLine1, endLine2);
                    //    TxLine center1 = new TxLine(offsetLine1.StartPoint, offsetLine2.EndPoint);
                    //    if (i != boxCount - 1)
                    //        cenLines.Add(center1);

                    //    //再偏移半块板的宽度---求出梁上缘边线
                    //    double beamWUpLeft = beamWSumLeft - beamWDnLeft;
                    //    double beamWUpRigt = beamWSumRigt - beamWDnRigt;
                    //    TxLine offsetLine3 = AcadAssist.OffsetLineToBoarder(startLine2,( offsetX1 + beamWSumLeft ), endLine1, endLine2);
                    //    TxLine offsetLine4 = AcadAssist.OffsetLineToBoarder(startLine2, (offsetX2 + beamWSumRigt), endLine1, endLine2);
                    //    TxLine border1 = new TxLine(offsetLine3.StartPoint, offsetLine4.EndPoint);
                    //    if (i != boxCount - 1)
                    //        kxbLines.Add(border1);

                    //    offsetX1 += XwidthOffsetL[i];
                    //    offsetX2 += XwidthOffsetR[i];
                    //}
                }
                #endregion

                //中心线与边线排序
                CompairTxLineStartY compareY2 = new CompairTxLineStartY();
                sideLines.Sort(compareY2);
                cenLines.Sort(compareY2);

                //输出板边线
                for (int i = 0; i < sideLines.Count; i++)
                {
                    block.AddLine(sideLines[i], CommonLayer.gz1layer);
                }
                //定义横梁线
                List<TxLine> hlLines = new List<TxLine>();//横梁线
                if (this.isUserhgbCount == false)
                {
                    hlLines.AddRange(m_hgbLines2);
                }
                else
                {
                    //-----目前只在跨中加一道横隔板----
                    TxLine beamSideUpLine1 = new TxLine(cvBoardDnx.StartPoint, cvBoardDnx.EndPoint);
                    TxLine beamSideUpLine2 = new TxLine(cvBoardUpx.StartPoint, cvBoardUpx.EndPoint);
                    Point3d hlPoint1 = AcadAssist.Mid(beamSideUpLine1.StartPoint, beamSideUpLine1.EndPoint);
                    Point3d hlPoint2 = AcadAssist.Mid(beamSideUpLine2.StartPoint, beamSideUpLine2.EndPoint);
                    hlLines.Add(new TxLine(hlPoint1, hlPoint2));
                }

                #region 绘制板梁平面构造图
                //绘制小箱梁T梁构造平面[kxbLines不包含上下构造边线--因此要用加上边线的kxbLinesWithBorder]
                List<BeamBox> BeamBoxs = new List<BeamBox>();   //横向布置箱梁
                List<BeamT> beamTs = new List<BeamT>();         //横向布置箱梁
                List<TxCurve> kxbLinesWithBorder = new List<TxCurve>();
                kxbLinesWithBorder.Insert(0, cvBoardDnx);
                for (int i = 0; i < sideLines.Count; i++) kxbLinesWithBorder.Add(sideLines[i]);
                kxbLinesWithBorder.Add(cvBoardUpx);
                boxCountX = Convert.ToInt32(sideLines.Count / 2);
                for (int i = 0; i <= boxCountX; i++)
                {
                    TxLine curBeamCenterLine = cenLines[i];
                    TxCurve curBeamSideLineDn = kxbLinesWithBorder[i * 2];
                    TxCurve curBeamSideLineUp = kxbLinesWithBorder[i * 2 + 1];
                    Point3d beamStartPoint = curBeamCenterLine.StartPoint;

                    if (structType == BeamType.BEAMBOX)
                    {
                        BeamBox BeamBox = new BeamBox();
                        if (i == 0) BeamBox.type = BeamBase.BeamLocate.Right;
                        if (i == boxCountX) BeamBox.type = BeamBase.BeamLocate.Left;
                        BeamBox.SetLinePM(curBeamCenterLine, curBeamSideLineDn, curBeamSideLineUp, hlLines, m_drawScale);
                        if (isDrawBeam)
                        {
                            DatabaseToAcad blockBeamBox = new DatabaseToAcad(block.style.BlockScale / m_drawScale);
                            BeamBox.DrawPM(blockBeamBox);
                            blockBeamBox.TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamStartPoint));
                            //-----------原来是这句DimensionScale,现在换成了ResetDimensionScale
                            blockBeamBox.ResetDimensionScale(block.style.BlockScale);
                            //blockBeamBox.DimensionScale(m_drawScale);
                            block.Append(blockBeamBox);
                        }
                        else
                        {

                            DatabaseToAcad blockBeamBox = new DatabaseToAcad(block.style.BlockScale / m_drawScale);
                            //BeamBox.DrawCenterLine(blockBeamBox);
                            blockBeamBox.TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamStartPoint));
                            //-----------原来是这句DimensionScale,现在换成了ResetDimensionScale
                            blockBeamBox.ResetDimensionScale(block.style.BlockScale);
                            //blockBeamBox.DimensionScale(m_drawScale);
                            block.Append(blockBeamBox);
                        }
                        BeamBoxs.Add(BeamBox);
                    }
                    else if (structType == BeamType.BEAMT)
                    {
                        BeamT beamT = new BeamT();
                        if (i == 0) beamT.type = BeamBase.BeamLocate.Right;
                        if (i == boxCountX) beamT.type = BeamBase.BeamLocate.Left;
                        beamT.SetLinePM(curBeamCenterLine, curBeamSideLineDn, curBeamSideLineUp, hlLines, m_drawScale);
                        if (isDrawBeam)
                        {
                            DatabaseToAcad blockBeamT = new DatabaseToAcad(block.style.BlockScale / m_drawScale);
                            beamT.DrawPM(blockBeamT);
                            blockBeamT.TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamStartPoint));
                            //-----------原来是这句DimensionScale,现在换成了ResetDimensionScale
                            blockBeamT.ResetDimensionScale(block.style.BlockScale);
                            //blockBeamT.DimensionScale(m_drawScale);
                            block.Append(blockBeamT);
                        }
                        else
                        {
                            DatabaseToAcad blockBeamT = new DatabaseToAcad(block.style.BlockScale / m_drawScale);
                            //beamT.DrawCenterLine(blockBeamT);
                            beamT.TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamStartPoint));
                            //-----------原来是这句DimensionScale,现在换成了ResetDimensionScale
                            blockBeamT.ResetDimensionScale(block.style.BlockScale);
                            //blockBeamBox.DimensionScale(m_drawScale);
                            block.Append(blockBeamT);
                        }
                        beamTs.Add(beamT);
                    }
                    else
                    {
                        throw new System.Exception("未知上部结构类型。");
                    }
                }
                #endregion

                #region 湿接缝填充
                //桥面板湿接缝填充[kxbLines不包含上下构造边线]
                int kxbLineCount2 = sideLines.Count / 2;
                for (int i = 0; i < kxbLineCount2; i++)
                {
                    TxLine border1 = sideLines[i * 2 + 0];
                    TxLine border2 = sideLines[i * 2 + 1];

                    TxPolyline loopPolyline = new TxPolyline();
                    loopPolyline.AddVertexAt(0, new Point2d(border1.StartPoint.X, border1.StartPoint.Y), 0, 0, 0);
                    loopPolyline.AddVertexAt(0, new Point2d(border1.EndPoint.X, border1.EndPoint.Y), 0, 0, 0);
                    loopPolyline.AddVertexAt(0, new Point2d(border2.EndPoint.X, border2.EndPoint.Y), 0, 0, 0);
                    loopPolyline.AddVertexAt(0, new Point2d(border2.StartPoint.X, border2.StartPoint.Y), 0, 0, 0);
                    loopPolyline.AddVertexAt(0, new Point2d(border1.StartPoint.X, border1.StartPoint.Y), 0, 0, 0);

                    block.AddHatch(loopPolyline, 3 * block.style.BlockScale, CommonLayer.gz3layer);
                }
                //桥面板湿接缝填充
                #endregion

                #region 绘制湿接缝范围的横隔板
                //湿接缝横梁[START]
                if (isDrawBeam)
                {
                    DatabaseToAcad blockSjf = new DatabaseToAcad(block.style.BlockScale);
                    for (int j = 1; j < BeamBoxs.Count; j++)
                    {
                        List<TxLine> hlCenters1 = new List<TxLine>();
                        List<TxLine> hlLines1L = new List<TxLine>();
                        List<TxLine> hlLines1R = new List<TxLine>();
                        BeamBoxs[j - 1].GetHLLine(out hlCenters1, out hlLines1L, out hlLines1R);
                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            hlCenters1[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j - 1].StartPointX));
                            hlLines1L[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j - 1].StartPointX));
                            hlLines1R[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j - 1].StartPointX));
                        }

                        List<TxLine> hlCenters2 = new List<TxLine>();
                        List<TxLine> hlLines2L = new List<TxLine>();
                        List<TxLine> hlLines2R = new List<TxLine>();
                        BeamBoxs[j].GetHLLine(out hlCenters2, out hlLines2L, out hlLines2R);
                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            hlCenters2[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j].StartPointX));
                            hlLines2L[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j].StartPointX));
                            hlLines2R[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, BeamBoxs[j].StartPointX));
                        }

                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            blockSjf.AddLine(new TxLine(hlCenters1[k].EndPoint, hlCenters2[k].StartPoint), CommonLayer.cenlayer);
                        }
                        for (int k = 0; k < hlLines1L.Count; k++)
                        {
                            blockSjf.AddLine(new TxLine(hlLines1L[k].EndPoint, hlLines2L[k].StartPoint), CommonLayer.gz2layer);
                            blockSjf.AddLine(new TxLine(hlLines1R[k].EndPoint, hlLines2R[k].StartPoint), CommonLayer.gz2layer);
                        }
                    }
                    //T梁湿接缝
                    for (int j = 1; j < beamTs.Count; j++)
                    {
                        List<TxLine> hlCenters1 = new List<TxLine>();
                        List<TxLine> hlLines1L = new List<TxLine>();
                        List<TxLine> hlLines1R = new List<TxLine>();
                        beamTs[j - 1].GetHLLine(out hlCenters1, out hlLines1L, out hlLines1R);
                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            hlCenters1[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j - 1].StartPointX));
                            hlLines1L[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j - 1].StartPointX));
                            hlLines1R[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j - 1].StartPointX));
                        }

                        List<TxLine> hlCenters2 = new List<TxLine>();
                        List<TxLine> hlLines2L = new List<TxLine>();
                        List<TxLine> hlLines2R = new List<TxLine>();
                        beamTs[j].GetHLLine(out hlCenters2, out hlLines2L, out hlLines2R);
                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            hlCenters2[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j].StartPointX));
                            hlLines2L[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j].StartPointX));
                            hlLines2R[k].TransformBy(Matrix3d.Scaling(0.001 * m_drawScale, beamTs[j].StartPointX));
                        }

                        for (int k = 0; k < hlCenters1.Count; k++)
                        {
                            blockSjf.AddLine(new TxLine(hlCenters1[k].EndPoint, hlCenters2[k].StartPoint), CommonLayer.cenlayer);
                        }
                        for (int k = 0; k < hlLines1L.Count; k++)
                        {
                            blockSjf.AddLine(new TxLine(hlLines1L[k].EndPoint, hlLines2L[k].StartPoint), CommonLayer.gz2layer);
                            blockSjf.AddLine(new TxLine(hlLines1R[k].EndPoint, hlLines2R[k].StartPoint), CommonLayer.gz2layer);
                        }
                    }
                    block.Append(blockSjf);
                }
                //湿接缝横梁[END]
                #endregion

                this.isDrawn = true;
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("绘图出错,请修改结构定义。" + "可能是结构边线是否合理。");
            }
        }
 /// <summary>
 /// 微调湿接缝宽度--初次布板湿接缝递增或递减,现将其调匀
 /// </summary>
 private List<Point3d> AdjustSjfW(Point3d start, Point3d end, int segCount, List<double> adjustSjfW)
 {
     double seglength = start.DistanceTo(end) / segCount;
     Vector3d vect = start.GetVectorTo(end).GetNormal();
     List<Point3d> res = new List<Point3d>();
     double dist = 0;
     for (int i = 1; i < segCount; i++)
     {
         dist += (seglength + adjustSjfW[i - 1]);
         res.Add(start + vect.MultiplyBy(dist));
     }
     return res;
 }
示例#34
0
 /// <summary>
 /// Gets a value indicating whether the specified point is on the segment defined by two points.
 /// </summary>
 /// <param name="pt">The instance to which the method applies.</param>
 /// <param name="p1">The segment start point.</param>
 /// <param name="p2">The segment end point.</param>
 /// <param name="tol">The tolerance used in comparisons.</param>
 /// <returns>true if the point is on the segment; otherwise, false.</returns>
 public static bool IsBetween(this Point3d pt, Point3d p1, Point3d p2, Tolerance tol)
 {
     return p1.GetVectorTo(pt).GetNormal(tol).Equals(pt.GetVectorTo(p2).GetNormal(tol));
 }