Exemplo n.º 1
0
        public void GetExportLayers(T model)
        {
            if (lengedList.Count > 0)
            {
                model.LayerList = new List <string>();
                List <MText> txtList = GetAllLengedText();

                foreach (MText dBText in txtList)
                {
                    if (MethodCommand.FindDBTextIsInPolyine(dBText, model.LegendList))
                    {
                        model.LayerList.Add(dBText.Text);
                    }
                }
            }
        }
Exemplo n.º 2
0
        } // form 结束

        public Hashtable TuliList()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor   ed  = doc.Editor;
            Database db  = doc.Database;

            // 识别图例 开始
            Hashtable tuliListData = new Hashtable();

            List <Polyline>       allLengenPolyine  = new List <Polyline>();
            List <BlockReference> blockTableRecords = new List <BlockReference>();
            List <DBText>         dbtextList        = new List <DBText>();
            List <MText>          mtextList         = new List <MText>();

            TypedValue[] tvs3 =
                new TypedValue[1] {
                new TypedValue(
                    (int)DxfCode.LayerName,
                    "图例"
                    )
            };

            SelectionFilter       sf3  = new SelectionFilter(tvs3);
            PromptSelectionResult psr3 = ed.SelectAll(sf3);
            SelectionSet          SS3  = psr3.Value;

            if (psr3.Status == PromptStatus.OK)
            {
                ObjectId[] idArray = SS3.GetObjectIds();
                using (Transaction acTrans = db.TransactionManager.StartTransaction())
                {
                    for (int j = 0; j < idArray.Length; j++)
                    {
                        DBObject ob = acTrans.GetObject(idArray[j], OpenMode.ForRead);

                        if (ob is Polyline && (ob as Polyline).Closed)
                        {
                            allLengenPolyine.Add((ob as Polyline));
                        }
                        else if (ob is BlockReference)
                        {
                            blockTableRecords.Add(ob as BlockReference);
                        }
                        else if (ob is DBText)
                        {
                            dbtextList.Add(ob as DBText);
                        }
                        else if (ob is MText)
                        {
                            mtextList.Add(ob as MText);
                        }
                    }

                    List <string> title  = new List <string>();
                    Hashtable     tuxing = new Hashtable();

                    ArrayList backGroud = new ArrayList();
                    Dictionary <string, Hashtable> canvas = new Dictionary <string, Hashtable>();

                    // 找到面积最大的多段线
                    Dictionary <int, List <Polyline> > plList = MethodCommand.FindMaxAreaPoline(allLengenPolyine);
                    if (plList[0].Count > 0)
                    {
                        foreach (MText dBText in mtextList)
                        {
                            if (MethodCommand.FindDBTextIsInPolyine(dBText, plList[0]))
                            {
                                title.Add(dBText.Text);
                            }
                        }
                    }

                    ArrayList geom  = new ArrayList();
                    ArrayList type  = new ArrayList();
                    ArrayList color = new ArrayList();

                    //tuxing.Add("geom", GetAllLengedGemo());
                    tuxing.Add("type", type);
                    tuxing.Add("color", color);

                    tuliListData.Add("title", title);
                    tuliListData.Add("tuxing", tuxing);
                }
            }

            MessageBox.Show(tuliListData.ToString());
            return(tuliListData);
        }  // 识别图例 结束