예제 #1
0
파일: ArxHelper.cs 프로젝트: Huynhnx/Upwork
        public static void CreateStairFrom4Point(Point3d pt1, Point3d pt2, Point3d pt3, Point3d pt4, double stairWidth, string Layer)
        {
            Point3dCollection verx = new Point3dCollection();

            verx.Add(pt1);
            verx.Add(pt2);
            verx.Add(pt3);
            verx.Add(pt4);
            // Draw arrow
            Point3dCollection arrowPoint = new Point3dCollection();
            Point3d           mid1       = new Point3d((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2, (pt1.Z + pt2.Z) / 2);
            Point3d           mid2       = new Point3d((pt3.X + pt4.X) / 2, (pt3.Y + pt4.Y) / 2, (pt3.Z + pt4.Z) / 2);

            if (mid1.Z < mid2.Z)
            {
                drawArrow(mid1, mid2, pt1 - pt2, pt1.DistanceTo(pt2), stairWidth);
            }
            else
            {
                drawArrow(mid2, mid1, pt1 - pt2, pt1.DistanceTo(pt2), stairWidth);
            }
            Polyline3d pl = new Polyline3d(Poly3dType.SimplePoly, verx, true);

            pl.Layer = Layer;
            ArxHelper.AppendEntity(pl);
            for (int i = 1; i < pt3.DistanceTo(pt2) / stairWidth; i++)
            {
                Point3d p1   = pt1 + (pt3 - pt2).GetNormal() * i * stairWidth;
                Point3d p2   = pt2 + (pt3 - pt2).GetNormal() * i * stairWidth;
                Line    line = new Line(p1, p2);
                line.Layer = Layer;
                ArxHelper.AppendEntity(line);
            }
        }
예제 #2
0
파일: ArxHelper.cs 프로젝트: Huynhnx/Upwork
        public static bool BuildPolylineFrom2Point(Point3d pt1, Point3d pt2)
        {
            //Get document, DataBase and Editor
            Document doc = Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor             ed = doc.Editor;
            PromptPointOptions op = new PromptPointOptions("Pick Direction:");

            op.UseBasePoint = true;
            op.BasePoint    = pt1;
            Line line           = new Line(pt1, pt2);
            PromptPointResult r = ed.GetPoint(op);

            if (r.Status == PromptStatus.OK)
            {
                Point3dCollection pts        = new Point3dCollection();
                Point3d           pt         = line.GetClosestPointTo(r.Value, true);
                Point3d           EndPoint   = pt1 + (r.Value - pt).GetNormal() * 3;
                Point3d           StartPoint = pt2 + (r.Value - pt).GetNormal() * 3;
                Point3dCollection vertex     = new Point3dCollection();
                vertex.Add(EndPoint);
                vertex.Add(pt1);
                vertex.Add(pt2);
                vertex.Add(StartPoint);
                Polyline3d pl3d = new Polyline3d(Poly3dType.SimplePoly, vertex, false);
                ArxHelper.AppendEntity(pl3d);
                vertex.Dispose();
                return(true);
            }
            return(false);
        }
예제 #3
0
파일: ArxHelper.cs 프로젝트: Huynhnx/Upwork
        public static void BuildLine(Line longline, Line shortline)
        {
            Point3d ptex1 = new Point3d();
            Point3d ptex2 = new Point3d();

            ptex1 = longline.GetClosestPointTo(shortline.StartPoint, true);
            ptex2 = longline.GetClosestPointTo(shortline.EndPoint, true);
            Point3dCollection points1 = new Point3dCollection();
            Point3dCollection points2 = new Point3dCollection();

            points1.Add(ptex1);
            points1.Add(shortline.StartPoint);
            points1.Add(shortline.EndPoint);
            points1.Add(ptex2);
            Polyline3d pl1 = new Polyline3d(Poly3dType.SimplePoly, points1, false);

            ArxHelper.AppendEntity(pl1);
            Vector3d dir  = (ptex1 - shortline.StartPoint);
            Point3d  pt11 = longline.StartPoint + dir.GetNormal() * 3;
            Point3d  pt21 = longline.EndPoint + dir.GetNormal() * 3;

            if (ptex1.DistanceTo(longline.StartPoint) + ptex1.DistanceTo(longline.EndPoint) > longline.Length)
            {
                if (ptex1.DistanceTo(longline.StartPoint) < ptex1.DistanceTo(longline.EndPoint))
                {
                    Point3d pt = new Point3d();
                    pt = ptex1 + (ptex1 - longline.EndPoint).GetNormal() * 3;
                    Line l = new Line(pt, ptex1);
                    AppendEntity(l);
                    points2.Add(pt);
                    points2.Add(longline.StartPoint);
                    points2.Add(longline.EndPoint);
                    points2.Add(pt21);
                }
                else
                {
                    Point3d pt = new Point3d();
                    pt = ptex2 + (ptex2 - longline.StartPoint).GetNormal() * 3;
                    points2.Add(pt);
                    points2.Add(longline.StartPoint);
                    points2.Add(longline.EndPoint);
                    points2.Add(pt21);
                }
            }
            else
            {
                points2.Add(pt11);
                points2.Add(longline.StartPoint);
                points2.Add(longline.EndPoint);
                points2.Add(pt21);
            }

            Polyline3d pl2 = new Polyline3d(Poly3dType.SimplePoly, points2, false);

            ArxHelper.AppendEntity(pl2);
        }
예제 #4
0
파일: ArxHelper.cs 프로젝트: Huynhnx/Upwork
        public static void CreateStairFrom3Point(Point3d pt1, Point3d pt2, Point3d pt3, double stairWidth, string Layer)
        {
            Line    l12     = new Line(pt1, pt2);
            Point3d ptonL12 = l12.GetClosestPointTo(pt3, false);
            Xline   xl1     = new Xline();

            xl1.BasePoint = pt1;
            xl1.UnitDir   = pt3 - ptonL12;
            Xline xl3 = new Xline();

            xl3.BasePoint = pt3;
            xl3.UnitDir   = pt1 - pt2;
            Point3dCollection pts3 = new Point3dCollection();
            Point3dCollection pts4 = new Point3dCollection();

            xl1.IntersectWith(xl3, Intersect.OnBothOperands, pts3, IntPtr.Zero, IntPtr.Zero);
            Point3d p3 = new Point3d();
            Point3d p4 = new Point3d();

            if (pts3.Count > 0)
            {
                p3 = pts3[0];
            }
            else
            {
                return;
            }
            Xline xl2 = new Xline();

            xl2.BasePoint = pt2;
            xl2.UnitDir   = pt3 - ptonL12;
            xl2.IntersectWith(xl3, Intersect.OnBothOperands, pts4, IntPtr.Zero, IntPtr.Zero);
            if (pts4.Count > 0)
            {
                p4 = pts4[0];
            }
            else
            {
                return;
            }
            Point3dCollection verx = new Point3dCollection();

            verx.Add(pt1);
            verx.Add(pt2);
            verx.Add(p4);
            verx.Add(p3);
            Polyline3d pl = new Polyline3d(Poly3dType.SimplePoly, verx, true);

            pl.Layer = Layer;
            ArxHelper.AppendEntity(pl);
            for (int i = 1; i < p4.DistanceTo(pt2) / stairWidth; i++)
            {
                Point3d p1   = pt1 + (p4 - pt2).GetNormal() * i * stairWidth;
                Point3d p2   = pt2 + (p4 - pt2).GetNormal() * i * stairWidth;
                Line    line = new Line(p1, p2);
                line.Layer = Layer;
                ArxHelper.AppendEntity(line);
            }
            Point3d mid1 = new Point3d((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2, (pt1.Z + pt2.Z) / 2);
            Point3d mid2 = new Point3d((p3.X + p4.X) / 2, (p3.Y + p4.Y) / 2, (p3.Z + p4.Z) / 2);

            if (mid1.Z < mid2.Z)
            {
                drawArrow(mid1, mid2, pt1 - pt2, pt1.DistanceTo(pt2), stairWidth);
            }
            else
            {
                drawArrow(mid2, mid1, pt1 - pt2, pt1.DistanceTo(pt2), stairWidth);
            }
        }
예제 #5
0
파일: ArxHelper.cs 프로젝트: Huynhnx/Upwork
        public static bool BuilPolyline(Point3d pt1, Point3d pt2, Point3d closerPoint, Point3d CloserPointOnLine, Point3d FurtherPoint, Point3d FurthurPointOnLine)
        {
            //Build Longer line

            Point3d           pt7  = pt1 + (CloserPointOnLine - closerPoint).GetNormal() * 3;
            Point3d           pt8  = pt2 + (CloserPointOnLine - closerPoint).GetNormal() * 3;
            Point3dCollection verx = new Point3dCollection();

            verx.Add(pt7);
            verx.Add(pt1);
            verx.Add(pt2);
            verx.Add(pt8);
            Polyline3d longer = new Polyline3d(Poly3dType.SimplePoly, verx, false);

            //Build Shorter Line
            Xline xline = new Xline();

            xline.BasePoint = closerPoint;
            xline.UnitDir   = pt1 - pt2;
            Line l48 = new Line(FurthurPointOnLine, FurtherPoint);
            Point3dCollection intersec = new Point3dCollection();

            xline.IntersectWith(l48, Intersect.OnBothOperands, intersec, IntPtr.Zero, IntPtr.Zero);
            if (intersec.Count < 1)
            {
                return(false);
            }
            Xline xl1 = new Xline();

            if (pt1.DistanceTo(FurtherPoint) < pt2.DistanceTo(FurtherPoint))
            {
                xl1.BasePoint = pt1;
            }
            else
            {
                xl1.BasePoint = pt2;
            }
            xl1.UnitDir = pt7 - pt1;
            Xline xl2 = new Xline();

            xl2.BasePoint = FurtherPoint;
            xl2.UnitDir   = pt2 - pt1;
            Point3dCollection intersec2 = new Point3dCollection();

            xl1.IntersectWith(xl2, Intersect.OnBothOperands, intersec2, IntPtr.Zero, IntPtr.Zero);

            Point3dCollection verx2 = new Point3dCollection();

            if (intersec2.Count < 1)
            {
                return(false);
            }
            ArxHelper.AppendEntity(longer);
            if (pt1.DistanceTo(FurtherPoint) < pt2.DistanceTo(FurtherPoint))
            {
                verx2.Add(pt1);
                verx2.Add(intersec2[0]);
                verx2.Add(FurtherPoint);
                verx2.Add(intersec[0]);
                verx2.Add(closerPoint);
                verx2.Add(CloserPointOnLine);
                Polyline3d pl = new Polyline3d(Poly3dType.SimplePoly, verx2, false);
                ArxHelper.AppendEntity(pl);
                return(true);
            }
            else
            {
                verx2.Add(pt2);
                verx2.Add(intersec2[0]);
                verx2.Add(FurtherPoint);
                verx2.Add(intersec[0]);
                verx2.Add(closerPoint);
                verx2.Add(CloserPointOnLine);
                Polyline3d pl = new Polyline3d(Poly3dType.SimplePoly, verx2, false);
                ArxHelper.AppendEntity(pl);
                return(true);
            }
        }