Example #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()); }
        }
Example #2
0
        private void btn_CreateKeyNote_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (cBox_objectType.SelectedIndex >= 0)
                {
                    LCH.getCurrentDwgVars();
                    using (GV.Doc.LockDocument())
                    {
                        //get title
                        string objTypeSelected = cBox_objectType.SelectedItem.ToString();
                        GV.textHeight = Convert.ToDouble(tBox_textHeight.Text);
                        //get items
                        mTextLabel = "";

                        //key note heading
                        if (tBox_Heading.Text != "")
                        {
                            LCH.getCurrentFont();
                            if (btn_HeadingBold.IsChecked == true || btn_HeadingUnderline.IsChecked == true)
                            {
                                mTextLabel += "{";
                            }
                            if (btn_HeadingBold.IsChecked == true)
                            {
                                mTextLabel += "\\f" + GV.currentFont + "|b1;";
                            }

                            if (btn_HeadingUnderline.IsChecked == true)
                            {
                                mTextLabel += "\\L";
                            }

                            mTextLabel += tBox_Heading.Text + @"}\P";
                            mTextLabel  = mTextLabel.Replace(@"\\", @"\");
                        }
                        else
                        {
                            mTextLabel += tBox_Heading.Text + @" \P";
                        }

                        foreach (var item in GV.NotesCollection_Anno2[cBox_objectType.SelectedItem.ToString()])
                        {
                            mTextLabel += item.Key + GV.keynoteSeperator + item.Value + @" \P";
                        }

                        #region Create Keynote Text
                        if (!mTextLabel.Equals(string.Empty))
                        {
                            switch (GV.keynotetexttype)
                            {
                            case "mtext":
                            {
                                LCH.createMtextwithJIG(mTextLabel);
                            }
                            break;

                            default:
                            {
                                LCH.createMtextwithJIG(mTextLabel);
                            }
                            break;
                            }
                            #endregion
                        }
                    }
                }
                else
                {
                    UIH.toastIT("Notes not found.", "No Notes Found", NotificationType.Error);
                }
            }
            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());
            }
        }
Example #3
0
        private void btn_selectViewport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                clearUIValues();
                if (checkifDefnitionsSelected())
                {
                    cBox_objectType.ItemsSource = null;
                    lBox_labels.ItemsSource     = null;
                    GV.clearSelection();
                    GV.all_label_coll.Clear();
                    tBox_Heading.Text = "";

                    //rest progressbar
                    proBar.Value = 0;

                    //MyCommands.vpshp();

                    //GV.Doc.SendStringToExecute("vpshp", true, false, false);

                    LCH.getCurrentDwgVars();
                    #region main
                    using (GV.Doc.LockDocument())
                    {
                        short val = (short)AcAp.GetSystemVariable("CVPORT");
                        if (val != 1)
                        {
                            GV.processStatus = false;
                            UIH.toastIT("This option works only in Paperspace (Layouts), please swtich to paperspace and try again!", "Viewport Not Preset", NotificationType.Error);
                        }
                        else
                        {
                            Helper.ViewportExtensions.getvPortCoordinatesADV();

                            if (GV.processStatus == true && GV.selObjects_forProcessing != null)
                            {
                                bw.WorkerSupportsCancellation = true;
                                bw.WorkerReportsProgress      = true;
                                //bw.ProgressChanged += bw_ProgressChanged;
                                bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                                //start work
                                if (bw.IsBusy != true)
                                {
                                    bw.RunWorkerAsync();
                                }
                                int index    = 1;
                                int objCount = GV.selObjects_forProcessing.Count();
                                GV.pBarMaxVal = objCount;

                                foreach (ObjectId objID in GV.selObjects_forProcessing)
                                {
                                    LCH.getlabelvalueSpecific(objID);

                                    #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
                                    index++;
                                    #endregion
                                }
                                updateUIdata();

                                UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    UIH.toastIT("Check if defintion and note files are selected!", "Missing defintion/note file", NotificationType.Error);
                }
            }
            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());
            }
        }
Example #4
0
        private void btn_selectLabel_SST_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LCH.getCurrentDwgVars();
                //rest progressbar
                proBar.Value = 0;
                GV.all_label_coll.Clear();
                clearUIValues();
                GV.clearSelection();
                tBox_Heading.Text = "";

                //read the label get the label name and KN values based on the KN location from SST file
                using (GV.Doc.LockDocument())
                {
                    GH.writeLog("\n Running command : btn_selectLabels_Click");

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

                    if (psRes.Status == PromptStatus.OK)
                    {
                        SelectionSet acSSet = psRes.Value;
                        GV.selObjects_forProcessing = acSSet.GetObjectIds();
                        GH.qprint("Number of objects selected: " + psRes.Value.Count);
                        GH.writeLog("\nNumber of objects selected: " + psRes.Value.Count);
                    }

                    bw.WorkerSupportsCancellation = true;
                    bw.WorkerReportsProgress      = true;
                    //bw.ProgressChanged += bw_ProgressChanged;
                    bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                    //start work
                    if (bw.IsBusy != true)
                    {
                        bw.RunWorkerAsync();
                    }
                    //check the label name against the SST file and type of label
                    int index = 1;

                    int objCount = GV.selObjects_forProcessing.Count();
                    GV.pBarMaxVal = objCount;

                    //GV.pmeter.Start("Processing Labels");
                    //GV.pmeter.SetLimit(objCount);


                    foreach (ObjectId objID in GV.selObjects_forProcessing)
                    {
                        LCH.getlabelvalueSpecific(objID);
                        //go to note list and get the note for the respective KN number that
                    }
                }
            }
            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());
            }
        }
Example #5
0
        private void btn_selectLabels_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //check if defnition and  note list are selected
                if (checkifDefnitionsSelected())
                {
                    //rest progressbar
                    proBar.Value = 0;
                    GV.all_label_coll.Clear();
                    clearUIValues();
                    GV.clearSelection();
                    tBox_Heading.Text = "";

                    LCH.getCurrentDwgVars();
                    using (GV.Doc.LockDocument())
                    {
                        GH.writeLog("\n Running command : btn_selectLabels_Click");

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

                        if (psRes.Status == PromptStatus.OK)
                        {
                            SelectionSet acSSet = psRes.Value;
                            GV.selObjects_forProcessing = acSSet.GetObjectIds();
                            GH.qprint("Number of objects selected: " + psRes.Value.Count);
                            GH.writeLog("\nNumber of objects selected: " + psRes.Value.Count);

                            //get key notes based on the selection
                            #region process labels Styles
                            bw.WorkerSupportsCancellation = true;
                            bw.WorkerReportsProgress      = true;
                            //bw.ProgressChanged += bw_ProgressChanged;
                            bw.DoWork += new DoWorkEventHandler(bw_UpdateProgressBar);
                            //start work
                            if (bw.IsBusy != true)
                            {
                                bw.RunWorkerAsync();
                            }


                            int index = 1;

                            int objCount = GV.selObjects_forProcessing.Count();
                            GV.pBarMaxVal = objCount;

                            //GV.pmeter.Start("Processing Labels");
                            //GV.pmeter.SetLimit(objCount);


                            foreach (ObjectId objID in GV.selObjects_forProcessing)
                            {
                                LCH.getlabelvalueSpecific(objID);

                                #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
                            }
                            //GV.pmeter.Stop();
                            //LCH.getlabelvalues();
                            //LCH.getlabelvalues(acSSet.GetObjectIds(), trans);
                            updateUIdata();

                            UIH.toastIT("All selected labels processed successfully!", "Status", NotificationType.Success);
                            #endregion
                        }
                    }
                }
                else
                {
                    UIH.toastIT("Check if defintion and note files are selected!", "Missing defintion/note file", NotificationType.Error);
                }
            }
            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());
            }
        }