예제 #1
0
        public static void RRR()
        {
            TypeViewerForm tvf = new TypeViewerForm();
            //Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(tvf);
            open_project dia = new open_project();

            Application.ShowModelessDialog(null, dia, false);
        }
예제 #2
0
 public static void RRR()
 {
     TypeViewerForm tvf = new TypeViewerForm();
     //Application.ShowModalDialog(null, tvf, false);
     //Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(tvf);
     Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(tvf);
     Point3d pnt1 = new Point3d(0, 0, 0);
     Point3d pnt2 = new Point3d(100, 100, 0);
     Circle cir = new Circle(pnt1, Vector3d.ZAxis, 50);
     Line lin = new Line(pnt1, pnt2);
     BlockTableRecord btr;
     BlockTable bt;
     Database wbd = HostApplicationServices.WorkingDatabase;
     Transaction trans;
     trans = wbd.TransactionManager.StartTransaction();
     bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
     btr = (BlockTableRecord)trans.GetObject(wbd.CurrentSpaceId, OpenMode.ForWrite);
     btr.AppendEntity(cir);
     btr.AppendEntity(lin);
     trans.AddNewlyCreatedDBObject(cir, true);
     trans.AddNewlyCreatedDBObject(lin, true);
     trans.Commit();
     trans.Dispose();
 }
예제 #3
0
        public static void processPoints()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            int numberOfPoints;

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Запрос выбора объектов в области чертежа
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                //List<Point3d> pathPoints = new List<Point3d>();

                // Если статус запроса равен OK, объекты выбраны
                if (acSSPrompt.Status == PromptStatus.OK)
                {
                    SelectionSet acSSet = acSSPrompt.Value;

                    numberOfPoints = Data.pathPoints.Count; // + Data.floorPointsStart.Count
                    Data.arrayFloidD = new double[numberOfPoints, numberOfPoints];
                    Data.arrayFloidS = new int[numberOfPoints, numberOfPoints];
                    Data.descentPoints = new double[numberOfPoints];
                    Data.descent = 0;

                    for (int i = 0; i < numberOfPoints; i++)
                    {
                        for (int j = 0; j < numberOfPoints; j++)
                        {
                            Data.arrayFloidD[i, j] = Double.PositiveInfinity;
                            Data.arrayFloidS[i, j] = j;
                            if (i == j)
                                Data.arrayFloidD[i, j] = 0;
                        }
                        Data.descentPoints[i] = 0;

                    }

                    // Перебор объектов в наборе
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        // Проверка, нужно убедиться в правильности полученного объекта
                        if (acSSObj != null)
                        {

                            // Открытие объекта для чтения
                            Line acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Line;
                            if (acEnt != null)
                            {
                                int indX = Data.pathPoints.FindIndex(item => item == acEnt.StartPoint);
                                int indY = Data.pathPoints.FindIndex(item => item == acEnt.EndPoint);

                                Data.arrayFloidD[indX, indY] = acEnt.StartPoint.DistanceTo(acEnt.EndPoint) + Data.deltaPoints[indX]; ;
                                Data.arrayFloidD[indY, indX] = Data.arrayFloidD[indX, indY];
                            }
                        }
                    }

                    for (int i = 0; i < Data.floorPointsStart.Count; i++)
                    {
                        int indX = Data.pathPoints.FindIndex(item => item == Data.floorPointsStart[i]);
                        int indY = Data.pathPoints.FindIndex(item => item == Data.floorPointsEnd[i]);

                        Data.arrayFloidD[indX, indY] = Data.floorPointsDistance[i];
                        Data.arrayFloidD[indY, indX] = Data.arrayFloidD[indX, indY];
                    }

                        //Алгоритм Флойда — Уоршелла
                        for (int k = 0; k < numberOfPoints; k++)
                            for (int i = 0; i < numberOfPoints; i++)
                                for (int j = 0; j < numberOfPoints; j++)
                                    if (i != j)
                                        if (Data.arrayFloidD[i, j] > Data.arrayFloidD[i, k] + Data.arrayFloidD[k, j])
                                        {
                                            Data.arrayFloidD[i, j] = Data.arrayFloidD[i, k] + Data.arrayFloidD[k, j];
                                            Data.arrayFloidS[i, j] = k;
                                        }

                    /*string test="";
                    for (int i = 0; i < numberOfPoints; i++)
                    {
                        //test = "";
                        for (int j = 0; j < numberOfPoints; j++)
                        {
                            test = test + arrayFloidS[i, j].ToString() + " ";
                        }
                        test = test + "\n";

                    }
                    Application.ShowAlertDialog(test);

                    test = "";
                    for (int i = 0; i < numberOfPoints; i++)
                    {
                        //test = "";
                        for (int j = 0; j < numberOfPoints; j++)
                        {
                            test = test + arrayFloidD[i, j].ToString() + " ";
                        }
                        test = test + "\n";

                    }
                    Application.ShowAlertDialog(test);

                    test = "";
                        for (int j = 0; j < numberOfPoints; j++)
                            test = test + pathPoints[j].ToString() + " ";
                    Application.ShowAlertDialog(test);*/

                    // Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(tvf);
                    // tvf.writeText(arrayFloidD[indStart, indEnd]);
                }

                // Очистка транзакции

                // Сохранение нового объекта в базе данных
                acTrans.Commit();

            }
        }
예제 #4
0
        public static void getYourPath()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();
            double delta = 0;
            int indStart, indEnd = 0;
            List<int> colorPath = new List<int>();
            List<int> path = new List<int>();

            using (DocumentLock doclock = acDoc.LockDocument())
            {

                // Старт транзакции
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    PromptPointResult pPtRes;
                    PromptPointOptions pPtOpts = new PromptPointOptions("");

                    PromptDoubleResult psoRes;
                    PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                    // Prompt for the start point
                    pPtOpts.Message = "\nВведи начало пути: ";
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                    indStart = Data.pathPoints.FindIndex(item => item == pPtRes.Value);

                    psoOpt.Message = "\nВведите длину спуска: ";
                    if (Data.descentPoints[indStart] == 0)
                        psoOpt.DefaultValue = Data.descent;
                    else
                        psoOpt.DefaultValue = Data.descentPoints[indStart];

                    psoRes = acDoc.Editor.GetDouble(psoOpt);
                    if (Data.descentPoints[indStart] == 0)
                    {
                        Data.descentPoints[indStart] = psoRes.Value;
                        Data.descent = psoRes.Value;
                    }
                    delta = delta + psoRes.Value;
                    path.Add(indStart);

                    while (true)
                    {
                        pPtOpts.Message = "\nВведи следующую точку пути: ";
                        pPtRes = acDoc.Editor.GetPoint(pPtOpts);

                        indEnd = Data.pathPoints.FindIndex(item => item == pPtRes.Value);
                        if (indEnd == -1) break;
                        path.Add(indEnd);

                        //Application.ShowAlertDialog("Тут все хорошо 1");

                        colorPath = Class4.setPath(Data.arrayFloidS, path, indStart, indEnd, Data.arrayFloidS[indStart, indEnd]);
                        //Application.ShowAlertDialog("Тут все хорошо 2");

                        Data.dlina = Data.arrayFloidD[indStart, indEnd] + delta;

                        indStart = indEnd;

                    }

                    psoOpt.Message = "\nВведите длину спуска: ";
                    if (Data.descentPoints[indStart] == 0)
                        psoOpt.DefaultValue = Data.descent;
                    else
                        psoOpt.DefaultValue = Data.descentPoints[indStart];

                    psoRes = acDoc.Editor.GetDouble(psoOpt);
                    if (Data.descentPoints[indStart] == 0)
                    {
                        Data.descentPoints[indStart] = psoRes.Value;
                        Data.descent = psoRes.Value;
                    }
                    delta = delta + psoRes.Value;
                    Data.dlina = Data.dlina + delta;

                    PromptSelectionResult acSSPrompt1 = acDoc.Editor.GetSelection();
                    // Если статус запроса равен OK, объекты выбраны
                    if (acSSPrompt1.Status == PromptStatus.OK)
                    {
                        SelectionSet acSSet1 = acSSPrompt1.Value;

                        for (int i = 0; i < colorPath.Count - 1; i++)
                        {
                            //Application.ShowAlertDialog("Путь: " + colorPath[i].ToString());
                            foreach (SelectedObject acSSObj in acSSet1)
                            {
                                // Проверка, нужно убедиться в правильности полученного объекта
                                if (acSSObj != null)
                                {
                                    // Открытие объекта для чтения
                                    Line acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite) as Line;
                                    //Application.ShowAlertDialog("Тут все хорошо 3");
                                    if (acEnt != null)
                                    {
                                        int indS = Data.pathPoints.FindIndex(item => item == acEnt.StartPoint);
                                        int indE = Data.pathPoints.FindIndex(item => item == acEnt.EndPoint);
                                        if (((colorPath[i] == indS) && ((colorPath[i + 1] == indE))) || ((colorPath[i + 1] == indS) && ((colorPath[i] == indE))))
                                        {
                                            acEnt.ColorIndex = 3;
                                            if (!Data.pathName[indS].Contains(DataCabel.t_oboznach1))
                                            {
                                                Data.pathName[indS].Add(DataCabel.t_oboznach1);
                                               // Application.ShowAlertDialog("Тут все хорошо 1" + indS.ToString() + " " + DataCabel.t_oboznach1);
                                            }
                                            if (!Data.pathName[indE].Contains(DataCabel.t_oboznach1))
                                            {
                                                Data.pathName[indE].Add(DataCabel.t_oboznach1);
                                               // Application.ShowAlertDialog("Тут все хорошо 2" + indE.ToString() + " " + DataCabel.t_oboznach1);
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                    //Application.ShowAlertDialog((Data.arrayFloidD[indStart, indEnd] + delta).ToString()); показывает длину

                    // Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(tvf);
                    // tvf.writeText(arrayFloidD[indStart, indEnd]);

                    // Очистка транзакции

                    // Сохранение нового объекта в базе данных
                    acTrans.Commit();
                }
            }
        }
예제 #5
0
        public static void getPointsFloor()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("");

                // Prompt for the start point
                pPtOpts.Message = "\nВведи начало на одном этаже: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                Data.floorPointsStart.Add(pPtRes.Value);

                if (!Data.pathPoints.Contains(pPtRes.Value))
                    Data.pathPoints.Add(pPtRes.Value);

                pPtOpts.Message = "\nВведи конец на другом этаже: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                Data.floorPointsEnd.Add(pPtRes.Value);

                if (!Data.pathPoints.Contains(pPtRes.Value))
                    Data.pathPoints.Add(pPtRes.Value);

                //PromptStringOptions psoOpt = new PromptStringOptions("nВведите имя блока: ");
                PromptDoubleResult psoRes;
                PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                psoOpt.Message = "\nВведите длину перехода: ";

                psoRes = acDoc.Editor.GetDouble(psoOpt);
                Data.floorPointsDistance.Add(psoRes.Value);

                // Сохранение нового объекта в базе данных
                acTrans.Commit();
            }
        }
예제 #6
0
        public static void getPointsDelta()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                PromptPointResult pPtRes;
                PromptPointOptions pPtOpts = new PromptPointOptions("");

                // Prompt for the start point
                pPtOpts.Message = "\nВведи точку перехода: ";
                pPtRes = acDoc.Editor.GetPoint(pPtOpts);

                int indX = Data.pathPoints.FindIndex(item => item == pPtRes.Value);

                //PromptStringOptions psoOpt = new PromptStringOptions("nВведите имя блока: ");
                PromptDoubleResult psoRes;
                PromptDoubleOptions psoOpt = new PromptDoubleOptions("");

                psoOpt.Message = "\nВведите длину перехода: ";
                psoRes = acDoc.Editor.GetDouble(psoOpt);
                Data.deltaPoints[indX] = psoRes.Value;

                // Сохранение нового объекта в базе данных
                acTrans.Commit();
            }
        }
예제 #7
0
        public static void getPoints()
        {
            // Получение текущего документа и базы данных
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            TypeViewerForm tvf = new TypeViewerForm();

            // Старт транзакции
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Запрос выбора объектов в области чертежа
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                //List<Point3d> pathPoints = new List<Point3d>();

                // Если статус запроса равен OK, объекты выбраны
                if (acSSPrompt.Status == PromptStatus.OK)
                {
                    SelectionSet acSSet = acSSPrompt.Value;

                    // Перебор объектов в наборе
                    foreach (SelectedObject acSSObj in acSSet)
                    {
                        // Проверка, нужно убедиться в правильности полученного объекта
                        if (acSSObj != null)
                        {

                            // Открытие объекта для чтения
                            Line acEnt = acTrans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Line;
                            if (acEnt != null)
                            {

                                if (!Data.pathPoints.Contains(acEnt.StartPoint))
                                    Data.pathPoints.Add(acEnt.StartPoint);
                                if (!Data.pathPoints.Contains(acEnt.EndPoint))
                                    Data.pathPoints.Add(acEnt.EndPoint);

                                //получаем координаты и кидаем их в функцию окошечка
                                //tvf.writeText(acEnt.StartPoint.X, acEnt.StartPoint.Y, acEnt.EndPoint.X, acEnt.EndPoint.Y);

                                // Изменение цвета объекта на Зеленый
                                //acEnt.ColorIndex = 3;
                            }
                        }
                    }
                }
            }

            int numberOfPoints;

            numberOfPoints = Data.pathPoints.Count;
            Data.deltaPoints = new double[numberOfPoints];
            Data.pathName = new List<string>[numberOfPoints];

            for (int i = 0; i < numberOfPoints; i++)
            {
                Data.pathName[i] = new List<string>();
            }

            for (int i = 0; i < numberOfPoints; i++)
                Data.deltaPoints[i] = 0;
        }