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()); } }
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()); } }
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()); } }