コード例 #1
0
        private void btn_learn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                collIndex = 0;
                selObjs.Clear();
                LCH.getCurrentDwgVars();
                using (GV.Doc.LockDocument())
                {
                    //ask the user to pick a style to read about the style
                    //Seleciton options, with single selection
                    PromptSelectionOptions Options = new PromptSelectionOptions();
                    Options.SingleOnly = true;
                    //Options.SinglePickInSpace = true;
                    Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();

                    PromptSelectionResult psRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetSelection(Options, new SelectionFilter(LCH.selectionFilter(GV.labelFilterType)));

                    if (psRes.Status == PromptStatus.OK)
                    {
                        SelectionSet acSSet = psRes.Value;
                        GV.selObjects_forProcessing = acSSet.GetObjectIds();


                        foreach (ObjectId objID in GV.selObjects_forProcessing)
                        {
                            //get the name of the label
                            LI = new Global.labelComponentItem();
                            LI.styleName = LCH.getLabelName(objID);
                            LI.objType = LCH.getObjType(objID);
                            LI.objID = objID;
                            GV.ed.WriteMessage("LI.name: " + LI.styleName);
                            GV.ed.WriteMessage("LI.objType: " + LI.objType);

                            //get the component id which has the value 99
                            Dictionary<string, string> CompNameVals = new Dictionary<string, string>();
                            CompNameVals = Helper.LabelTextExtractor.getLabelValsAll(objID);

                            //get the location of the value and store it against the style name and id.
                            int i = 0;
                            LI.KNComponentID = new List<int>();
                            string KNLoc = "";

                            foreach (var item in CompNameVals)
                            {
                                if (item.Value == "99")
                                {
                                    LI.KNComponentID.Add(Convert.ToInt32(item.Key));
                                    KNLoc = item.Key + ",";
                                    i++;
                                }
                            }

                            //check if there is a comman at the end of the KN and remove that
                            KNLoc = KNLoc.Remove(KNLoc.Length - 1);

                            if (selObjs.Where(item => item.styleName == LI.styleName).Any() == false)
                            {
                                selObjs.Add(LI);
                            }
                            
                            //show this on the confirmation box - once the user confirms its then add to the list. or discard that item

                            tBox_styleName.Text = LI.styleName;
                            //tBox_styleKNloc.Text = KNLoc;

                            // ask the user to pick the mapper configuration 

                            //store the configuration to settings file

                        }

                        grid_addStyle.Visibility = System.Windows.Visibility.Visible;
                    }
                }
            }
            catch (System.Exception ex)
            { GH.writeLog(ex.ToString()); }
        }
コード例 #2
0
        private void ProcessLabels()
        {
            try
            {
                int index    = 1;
                int objCount = GV.selObjects_forProcessing.Count();
                GV.pBarMaxVal = objCount;
                Dictionary <string, string> labelVals = new Dictionary <string, string>();
                Dictionary <string, string> noteItems;
                List <string> SSTList = new List <string>();
                foreach (ObjectId objID in GV.selObjects_forProcessing)
                {
                    // get the style name from the label
                    string styleName = LCH.getLabelName(objID);
                    SSTList = GH.getSST(styleName);
                    if (SSTList != null)
                    {
                        string notetype = SSTList[1];
                        labelVals = Helper.LabelTextExtractor.getLabelValsAll(objID);
                        //get the KN values based on the locations
                        foreach (var KNloc in SSTList[2].ToString())
                        {
                            #region Add the notes to the collection
                            // add note type if its not there add it to the collection
                            if (!GV.NotesCollection_Anno2.ContainsKey(notetype))
                            {
                                noteItems = new Dictionary <string, string>();
                                GV.NotesCollection_Anno2.Add(notetype, noteItems);
                            }

                            //check if that note number is already in the collection.
                            noteItems = GV.NotesCollection_Anno2[notetype]; //get the note item for the specific note type

                            if (labelVals.ContainsKey(KNloc.ToString()))
                            {
                                string noteNum = labelVals[KNloc.ToString()]; //get the note number based on the KN location
                                                                              //check if that note type is available in the template file
                                if (GV.notesDict.ContainsKey(notetype))
                                {
                                    Dictionary <int, string> innetDict = new Dictionary <int, string>();
                                    innetDict = GV.notesDict[notetype];
                                    //check if the value exists inthe inner dict
                                    if (innetDict.ContainsKey(Convert.ToInt32(noteNum)) && !noteItems.ContainsKey(noteNum))
                                    {
                                        noteItems.Add(noteNum, innetDict[Convert.ToInt32(noteNum)]);
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    //get the notes from the notelist files and add it based on the KN values

                    #region ProgressBAR

                    GH.printDebug("", "", false, true);
                    GV.pBarStatus = "Labels Processed: " + index + @"/" + objCount;
                    UpdateProgressBar(index, objCount, GV.pBarStatus);
                    //GV.pmeter.MeterProgress();
                    Helper.UIHelper.DoEvents();

                    GV.pBarCurrentVal = index;

                    //assign it work
                    //bw.ReportProgress(index);
                    index++;
                    #endregion
                }
            }
            catch (Autodesk.Civil.CivilException ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                GH.errorBox(ex.ToString());
            }
            catch (System.Exception ee)
            {
                GH.errorBox(ee.ToString());
            }
        }