Exemplo n.º 1
0
            private void createObjects(AC_Line line)
            {
                AC_Circle t1 = new AC_Circle();
                AC_Circle t2 = new AC_Circle();
                AC_Polyline p = new AC_Polyline();
                t1.Center = line.StartPoint;
                t2.Center = line.EndPoint;
                t1.Radius = BaseRadius[0];
                t2.Radius = BaseRadius[1];
                t1.addToDrawing();
                t2.addToDrawing();
                p.addToDrawing();

                //APPLY COLORS
                applyLineStyle((AC_Entity)p, Color.FromRgb(255, 51, 51), "ACAD_ISO02W100",3);
                applyLineStyle((AC_Entity)t1, Color.FromRgb(255, 135, 51), "ACAD_ISO03W100",1);
                applyLineStyle((AC_Entity)t2, Color.FromRgb(255, 135, 51), "ACAD_ISO03W100",1);

                //COPY XDATA GUID
                int index = 0;
                string guid = "";
                foreach (TypedValue tv in line.XData as ResultBuffer)
                {
                    if(index == 3){
                        guid = tv.Value.ToString();
                    }
                    index++;
                }

                ResultBuffer rb = new ResultBuffer(new TypedValue((int)DxfCode.ExtendedDataRegAppName, "TRIANGULATE"), new TypedValue((int)DxfCode.ExtendedDataAsciiString, guid));
                t1.XData = rb;
                t2.XData = rb;
                p.XData = rb;

                Point3dCollection pts = new Point3dCollection();
                t1.IntersectWith((Circle)t2, Intersect.OnBothOperands, pts, IntPtr.Zero, IntPtr.Zero);

                if (pts.Count == 0)
                {
                    tr.AC_Doc.Editor.WriteMessage("Cannot Calculate Triangulation \n");
                    t1.Erase(true);
                    t2.Erase(true);
                    p.Erase(true);
                }
                else if (pts.Count == 1)
                {
                    p.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
                    p.AddVertexAt(1, new Point2d(pts[0].X, pts[0].Y), 0, 0, 0);
                    p.AddVertexAt(2, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
                }
                else if (pts.Count == 2)
                {
                    p.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
                    p.AddVertexAt(1, new Point2d(pts[0].X, pts[0].Y), 0, 0, 0);
                    p.AddVertexAt(2, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
                    p.AddVertexAt(3, new Point2d(pts[1].X, pts[1].Y), 0, 0, 0);
                    p.Closed = true;
                }
            }
Exemplo n.º 2
0
            public bool askForDistances(AC_Line acline)
            {
                circleCenter = acline.StartPoint;
                previewCircle = new AC_Circle();
                previewCircle.addToDrawing();
                removeSnap noSnap = new removeSnap(previewCircle.ObjectId);
                ObjectOverrule.AddOverrule(RXObject.GetClass(typeof(Entity)), noSnap, true);

                drawPreviewCircle = true;
                PromptDistanceOptions DistOption = new PromptDistanceOptions("Triangulation Distance");
                DistOption.BasePoint = circleCenter;
                DistOption.UseBasePoint = true;

                PromptDoubleResult triang1 = tr.AC_Doc.Editor.GetDistance(DistOption);
                if (triang1.Status == PromptStatus.OK)
                {
                    if (triang1.Value != 0)
                    {
                        tr.AC_Doc.Editor.WriteMessage(triang1.Value.ToString() + "\n");
                        circleCenter = acline.EndPoint;
                        DistOption.BasePoint = circleCenter;
                        radius.Add(triang1.Value);
                        PromptDoubleResult triang2 = tr.AC_Doc.Editor.GetDistance(DistOption);
                        if (triang2.Status == PromptStatus.OK)
                        {
                            tr.AC_Doc.Editor.WriteMessage(triang2.Value.ToString() + "\n");
                            radius.Add(triang2.Value);
                            previewCircle.Visible = false;
                            drawPreviewCircle = false;
                            return true;
                        }
                        else
                        {
                            tr.AC_Doc.Editor.PointMonitor -= Editor_PointMonitor;
                            ObjectOverrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), noSnap);
                            previewCircle.Erase(true);
                            return false;
                        }
                    }
                    else
                    {
                        tr.AC_Doc.Editor.PointMonitor -= Editor_PointMonitor;
                        tr.AC_Doc.Editor.WriteMessage("Cannot Calculate Triangulation \n");
                        ObjectOverrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), noSnap);
                        previewCircle.Erase(true);
                        return false;
                    }
                }
                else
                {
                    tr.AC_Doc.Editor.PointMonitor -= Editor_PointMonitor;
                    ObjectOverrule.RemoveOverrule(RXObject.GetClass(typeof(Entity)), noSnap);
                    previewCircle.Visible = false;
                    drawPreviewCircle = false;
                    return false;
                }
            }