getRemoveAndReplace() { SelectionSet objSSet = buildSSetTable(); ObjectId[] ids = objSSet.GetObjectIds(); Table objTable = (Table)ids[0].getEnt(); int row = 16; int col = 1; return(double.Parse(objTable.Cells[row, col].Value.ToString())); }
resetPOI(ObjectId idTable) { List <POI> varpoi = new List <POI>(); POI vpoi = new POI(); using (Transaction tr = BaseObjs.startTransactionDb()) { Table objTable = (Table)tr.GetObject(idTable, OpenMode.ForRead); for (int i = 2; i < objTable.Rows.Count; i++) { vpoi.ClassObj = objTable.Cells[i + 2, 1].TextString; vpoi.Desc0 = objTable.Cells[i + 2, 2].TextString; vpoi.DescX = objTable.Cells[i + 2, 3].TextString; vpoi.Station = double.Parse(objTable.Cells[i + 2, 4].TextString.Replace("+", "")); vpoi.OFFSET = double.Parse(objTable.Cells[i + 2, 5].TextString); vpoi.Elevation = double.Parse(objTable.Cells[i + 2, 6].TextString); vpoi.ElevTOW = double.Parse(objTable.Cells[i + 2, 7].TextString); vpoi.ElevTOF = double.Parse(objTable.Cells[i + 2, 8].TextString); vpoi.Invert = double.Parse(objTable.Cells[i + 2, 9].TextString); vpoi.Size = double.Parse(objTable.Cells[i + 2, 10].TextString); vpoi.AngDelta = double.Parse(objTable.Cells[i + 2, 11].TextString); vpoi.AngDir = double.Parse(objTable.Cells[i + 2, 12].TextString); vpoi.AngChord = double.Parse(objTable.Cells[i + 2, 13].TextString); vpoi.isRightHand = (objTable.Cells[i + 2, 14].TextString.ToUpper() == "TRUE") ? true : false; vpoi.isClosed = (objTable.Cells[i + 2, 15].TextString.ToUpper() == "TRUE") ? true : false; vpoi.isStep = (objTable.Cells[i + 2, 16].TextString.ToUpper() == "TRUE") ? true : false; vpoi.CrossDesc = objTable.Cells[i + 2, 17].TextString; vpoi.CrossAlign = objTable.Cells[i + 2, 18].TextString; vpoi.CrossAlignInv = double.Parse(objTable.Cells[i + 2, 19].TextString); vpoi.CrossAlignSta = double.Parse(objTable.Cells[i + 2, 20].TextString); vpoi.CrossAlignSize = double.Parse(objTable.Cells[i + 2, 21].TextString); vpoi.PntNum = objTable.Cells[i + 2, 22].TextString; vpoi.PntSource = objTable.Cells[i + 2, 23].TextString; vpoi.Type = objTable.Cells[i + 2, 24].TextString; vpoi.Bulge = double.Parse(objTable.Cells[i + 2, 25].TextString); vpoi.Radius = double.Parse(objTable.Cells[i + 2, 26].TextString); vpoi.Side = Int16.Parse(objTable.Cells[i + 2, 27].TextString); vpoi.SlopeAhead = double.Parse(objTable.Cells[i + 2, 28].TextString); vpoi.SlopeBack = double.Parse(objTable.Cells[i + 2, 29].TextString); vpoi.SlopeH2H = double.Parse(objTable.Cells[i + 2, 30].TextString); vpoi.CenterPnt = new Point3d(double.Parse(objTable.Cells[i + 2, 31].TextString), double.Parse(objTable.Cells[i + 2, 32].TextString), 0); varpoi.Add(vpoi); } tr.Commit(); } return(varpoi); }
getTableData() { SelectionSet ss = buildSSetTable(); if (ss == null || ss.Count == 0) { return; } ObjectId idTable = ss.GetObjectIds()[0]; List <DEPTH> depths = new List <DEPTH>(); Table table = (Table)idTable.getEnt(); try { for (int i = 3; i <= 13; i++) { DEPTH depth = new DEPTH(); depth.KEYWORD = table.Cells[i, 3].Value.ToString(); depth.SG = double.Parse(table.Cells[i, 0].Value.ToString()); depth.OX = double.Parse(table.Cells[i, 1].Value.ToString()); depths.Add(depth); //Debug.Print "Keyword: " & varDepths(i - 3).KEYWORD & " SG: " & varDepths(i - 3).SG & " OX: " & varDepths(i - 3).OX } EW_Pub.depths = depths; EW_Pub.K_BRACE_V = double.Parse(table.Cells[15, 1].Value.ToString()); EW_Pub.COLUMN_FOOTINGS_V = double.Parse(table.Cells[16, 1].Value.ToString()); EW_Pub.OUTER_FOOTINGS_V = double.Parse(table.Cells[17, 1].Value.ToString()); EW_Pub.REMOVE_REPLACE_V = double.Parse(table.Cells[18, 1].Value.ToString()); EW_Pub.REMOVE_REPLACE_BLDG_V = double.Parse(table.Cells[19, 1].Value.ToString()); EW_Pub.OX_LIMIT_H = double.Parse(table.Cells[20, 1].Value.ToString()); EW_Pub.FOOTING_LIMIT_IN_H = double.Parse(table.Cells[21, 1].Value.ToString()); EW_Pub.K_BRACE_H = double.Parse(table.Cells[22, 1].Value.ToString()); } catch (System.Exception) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Update Table - create new drawing using EW.dwt and replace table after transferring values. Rename FLOOR SLAB to FLOOR SLAB A"); } //Debug.Print "K-Brace Vertica: " & K_BRACE_V //Debug.Print "Column Footings Depth: " & COLUMN_FOOTINGS_V //Debug.Print "Outer Footings Depth: " & OUTER_FOOTINGS_V //Debug.Print "Remove Replace Depth: " & REMOVE_REPLACE_V //Debug.Print "Remove Replace Building Depth: " & REMOVE_REPLACE_BLDG_V //Debug.Print "OX Limit: " & OX_LIMIT_H //Debug.Print "Footing Limit Inside: " & FOOTING_LIMIT_IN_H //Debug.Print "K-Brace Horizontal: " & K_BRACE_H }
addTableData(ObjectId idTable, List <POI> varpoi) { using (Transaction tr = BaseObjs.startTransactionDb()) { Table objTable = (Table)tr.GetObject(idTable, OpenMode.ForWrite); objTable.SuppressRegenerateTable(true); for (int i = 0; i < varpoi.Count; i++) { objTable.Cells[i + 2, 0].TextString = i.ToString(); objTable.Cells[i + 2, 1].TextString = varpoi[i].ClassObj; objTable.Cells[i + 2, 2].TextString = varpoi[i].Desc0; objTable.Cells[i + 2, 3].TextString = varpoi[i].DescX; objTable.Cells[i + 2, 4].TextString = string.Format("{0:###+##.00}", varpoi[i].Station); objTable.Cells[i + 2, 5].TextString = string.Format("{0:###.00}", System.Math.Round(varpoi[i].OFFSET, 3)); objTable.Cells[i + 2, 6].TextString = string.Format("{0:#####.000}", System.Math.Round(varpoi[i].Elevation, 3)); objTable.Cells[i + 2, 7].TextString = varpoi[i].ElevTOW.ToString(); objTable.Cells[i + 2, 8].TextString = varpoi[i].ElevTOF.ToString(); objTable.Cells[i + 2, 9].TextString = varpoi[i].Invert.ToString(); objTable.Cells[i + 2, 10].TextString = varpoi[i].Size.ToString(); objTable.Cells[i + 2, 11].TextString = varpoi[i].AngDelta.ToString(); objTable.Cells[i + 2, 12].TextString = varpoi[i].AngDir.ToString(); objTable.Cells[i + 2, 13].TextString = varpoi[i].AngChord.ToString(); objTable.Cells[i + 2, 14].TextString = varpoi[i].isRightHand.ToString(); objTable.Cells[i + 2, 15].TextString = varpoi[i].isClosed.ToString(); objTable.Cells[i + 2, 16].TextString = varpoi[i].isStep.ToString(); objTable.Cells[i + 2, 17].TextString = varpoi[i].CrossDesc; objTable.Cells[i + 2, 18].TextString = varpoi[i].CrossAlign; objTable.Cells[i + 2, 19].TextString = varpoi[i].CrossAlignInv.ToString(); objTable.Cells[i + 2, 20].TextString = varpoi[i].CrossAlignSta.ToString(); objTable.Cells[i + 2, 21].TextString = varpoi[i].CrossAlignSize.ToString(); objTable.Cells[i + 2, 22].TextString = varpoi[i].PntNum; objTable.Cells[i + 2, 23].TextString = varpoi[i].PntSource; objTable.Cells[i + 2, 24].TextString = varpoi[i].Type; objTable.Cells[i + 2, 25].TextString = varpoi[i].Bulge.ToString(); objTable.Cells[i + 2, 26].TextString = varpoi[i].Radius.ToString(); objTable.Cells[i + 2, 27].TextString = varpoi[i].Side.ToString(); objTable.Cells[i + 2, 28].TextString = varpoi[i].SlopeAhead.ToString(); objTable.Cells[i + 2, 29].TextString = varpoi[i].SlopeBack.ToString(); objTable.Cells[i + 2, 30].TextString = varpoi[i].SlopeH2H.ToString(); objTable.Cells[i + 2, 31].TextString = varpoi[i].CenterPnt.X.ToString(); objTable.Cells[i + 2, 32].TextString = varpoi[i].CenterPnt.Y.ToString(); } objTable.SuppressRegenerateTable(false); tr.Commit(); } }
updateTableData(ObjectId idTable, List <POI> varpoi) { using (Transaction tr = BaseObjs.startTransactionDb()) { Table objTable = (Table)tr.GetObject(idTable, OpenMode.ForWrite); int lngRows = objTable.Rows.Count - 3; //1 for Zero base and 2 for top two rows = 3 Debug.Print(lngRows.ToString()); int lngRowsDiff = varpoi.Count - lngRows; Debug.Print(lngRowsDiff.ToString()); if (lngRowsDiff < 0) { objTable.DeleteRows(lngRows + lngRowsDiff, System.Math.Abs(lngRowsDiff)); } else if (lngRowsDiff > 0) { objTable.InsertRows(lngRows, 5, lngRowsDiff); } objTable.SuppressRegenerateTable(true); for (int i = 2; i < objTable.Rows.Count; i++) { for (int j = 0; j < objTable.Columns.Count; j++) { objTable.Cells[i, j].DeleteContent(); } } tr.Commit(); } addTableData(idTable, varpoi); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonExportTbl_Click(object sender, RoutedEventArgs e) { if (dataGridTdInfo.Items.Count == 0) { MessageBox.Show("表中没有数据!"); return; } this.Hide();//对话框消失 Document doc = AcadApp.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; //1.提示用户输入插入点 PromptPointResult ptRes = ed.GetPoint("\n选择表格插入点"); if (ptRes.Status != PromptStatus.OK) //如果选择不正确 { this.Show(); //回到对话框 return; } //2.先对钢束信息进行更新,类似于点击了更新并退出按钮,但显示更新成功对话框 using (Transaction trans = db.TransactionManager.StartTransaction()) //开始事务处理 using (DocumentLock loc = doc.LockDocument()) { //1.更新图形数据库总体信息 SyncData.SyncTdGenParasToDlg(this); db.SyncDwgToTdGenParas(); //2.更新钢束Xrecord信息 SyncData.SyncTdsToDlg(ref tdsInTbl, this); db.SyncDwgToTds(tdsInTbl); trans.Commit();//执行事务处理 } //3.输出表格 using (Transaction trans1 = db.TransactionManager.StartTransaction()) //开始事务处理 using (DocumentLock loc = doc.LockDocument()) { //3.1 将表格内容读入列表中便于操作 List <string> tdNames = new List <string>(); List <string> tdStyles = new List <string>(); List <int> tdNums = new List <int>(); List <double> pipeDias = new List <double>(); List <int> drawTypes = new List <int>(); List <double> leftDrawAmounts = new List <double>(); List <double> rightDrawAmounts = new List <double>(); List <double> clearLens = new List <double>(); List <double> totalLens = new List <double>(); for (int i = 0; i < dataGridTdInfo.Items.Count; i++) { tdNames.Add((dataGridTdInfo.Columns[0].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text); tdStyles.Add((dataGridTdInfo.GetControl(i, 1, "comboBoxTdStyles") as ComboBox).Text); tdNums.Add(int.Parse((dataGridTdInfo.Columns[2].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); pipeDias.Add(double.Parse((dataGridTdInfo.Columns[3].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); drawTypes.Add( ((bool)((dataGridTdInfo.GetControl(i, 4, "checkBoxLeftDraw") as CheckBox).IsChecked) ? -1 : 0) + ((bool)((dataGridTdInfo.GetControl(i, 5, "checkBoxRightDraw") as CheckBox).IsChecked) ? 1 : 0) ); leftDrawAmounts.Add(double.Parse((dataGridTdInfo.Columns[6].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); rightDrawAmounts.Add(double.Parse((dataGridTdInfo.Columns[7].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); clearLens.Add(double.Parse((dataGridTdInfo.Columns[8].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); totalLens.Add(double.Parse((dataGridTdInfo.Columns[9].GetCellContent(dataGridTdInfo.Items[i]) as TextBlock).Text)); } //3.2 设置表格规格 Autodesk.AutoCAD.DatabaseServices.Table tb = new Autodesk.AutoCAD.DatabaseServices.Table(); //初始化钢束表格 tb.SetSize(dataGridTdInfo.Items.Count + 3, 14); //设置表格行数(表格行数、表头2行、合计1行)、列数 //设置列宽 tb.SetColumnWidth(12); //全部设为12 tb.Columns[1].Width = 22; //将钢束规格列设为22 //设置行高 tb.SetRowHeight(4); tb.Position = ptRes.Value;//插入点 //根据所使用的波纹管直径种类增加新列 var pipeDiasDist = pipeDias.Select(c => c).Distinct().OrderBy(c => c).ToList(); //多一种管道直径增加一列 if (pipeDiasDist.Count > 1) { tb.InsertColumns(9, 12, pipeDiasDist.Count - 1); } //根据所使用的钢束规格增加新列 var tdStylesDist = tdStyles.Select(c => c).Distinct().OrderBy(c => int.Parse(c.Remove(0, 4))).ToList(); //多一种钢束规格增加两列,分别为固定和张拉锚具,表格成形后如果本列锚具合计为零,再进行删除 if (tdStylesDist.Count > 1) { tb.InsertColumns(10 + pipeDiasDist.Count, 12, (tdStylesDist.Count - 1) * 2); } //设置表格样式 tb.TableStyle = db.Tablestyle; //表格样式为当前表格样式 tb.Cells.TextStyleId = db.Textstyle; //表格字体样式为当前样式 tb.Cells.TextHeight = 3; //表格字高为3 tb.Cells.Alignment = CellAlignment.MiddleCenter; //表格对其方式为对中 tb.SetMargin(-1, -1, CellMargins.Left, 0); //左侧边距 tb.SetMargin(-1, -1, CellMargins.Right, 0); //右侧边距 tb.SetMargin(-1, -1, CellMargins.Top, 0); //上侧边距 tb.SetMargin(-1, -1, CellMargins.Bottom, 0); //下侧边距 //3.3 表头合并并填写表头 //将标题行拆分 tb.UnmergeCells(tb.Cells[0, 0].GetMergeRange()); //名称 tb.Cells[0, 0].TextString = "名称"; tb.MergeCells(CellRange.Create(tb, 0, 0, 1, 0)); //规格 tb.Cells[0, 1].TextString = "规格"; tb.MergeCells(CellRange.Create(tb, 0, 1, 1, 1)); //钢束长度 tb.Cells[0, 2].TextString = "钢束长度\n(mm)"; tb.MergeCells(CellRange.Create(tb, 0, 2, 1, 2)); //根数 tb.Cells[0, 3].TextString = "根数"; tb.MergeCells(CellRange.Create(tb, 0, 3, 1, 3)); //钢束总长 tb.Cells[0, 4].TextString = "钢束总长\n(m)"; tb.MergeCells(CellRange.Create(tb, 0, 4, 1, 4)); //总重 tb.Cells[0, 5].TextString = "总重(kg)"; tb.MergeCells(CellRange.Create(tb, 0, 5, 1, 5)); //引伸量 tb.Cells[0, 6].TextString = "张拉端引伸量(mm)"; tb.MergeCells(CellRange.Create(tb, 0, 6, 0, 7)); tb.Cells[1, 6].TextString = "左端"; tb.Cells[1, 7].TextString = "右端"; //波纹管长 tb.Cells[0, 8].TextString = "波纹管长\n(mm)"; tb.MergeCells(CellRange.Create(tb, 0, 8, 1, 8)); //管道总长 tb.Cells[0, 9].TextString = "管道总长(m)"; if (pipeDiasDist.Count > 1) { tb.MergeCells(CellRange.Create(tb, 0, 9, 0, 8 + pipeDiasDist.Count)); } for (int i = 0; i < pipeDiasDist.Count; i++) { tb.Cells[1, 9 + i].TextString = "Φ" + pipeDiasDist[i].ToString("F0"); } //锚具 tb.Cells[0, 9 + pipeDiasDist.Count].TextString = "锚具套数"; tb.MergeCells(CellRange.Create(tb, 0, 9 + pipeDiasDist.Count, 0, 10 + pipeDiasDist.Count + (tdStylesDist.Count - 1) * 2)); for (int i = 0; i < tdStylesDist.Count; i++) { tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i].TextString = tdStylesDist[i].Remove(0, 1) + "张拉"; tb.Cells[1, 9 + pipeDiasDist.Count + 2 * i + 1].TextString = tdStylesDist[i].Remove(0, 1) + "固定"; } //控制应力 tb.Cells[0, tb.Columns.Count - 2].TextString = "控制应力\n(MPa)"; tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 2, 1, tb.Columns.Count - 2)); //备注 tb.Cells[0, tb.Columns.Count - 1].TextString = "备注"; tb.MergeCells(CellRange.Create(tb, 0, tb.Columns.Count - 1, 1, tb.Columns.Count - 1)); //3.4 填写表格内容 for (int i = 0; i < dataGridTdInfo.Items.Count; i++) //行迭代 { tb.Cells[2 + i, 0].TextString = tdNames[i]; //名称 tb.Cells[2 + i, 1].TextString = tdStyles[i]; //规格 tb.Cells[2 + i, 2].TextString = totalLens[i].ToString("F0"); //钢束长度 tb.Cells[2 + i, 3].TextString = tdNums[i].ToString("F0"); //钢束根数 tb.Cells[2 + i, 4].TextString = (totalLens[i] * tdNums[i] / 1000).ToString("F1"); //钢束总长 tb.Cells[2 + i, 5].TextString = (int.Parse(tdStyles[i].Remove(0, 4)) * 1.101 //总重 * (totalLens[i] * tdNums[i] / 1000)).ToString("F1"); tb.Cells[2 + i, 6].TextString = leftDrawAmounts[i].ToString("F0"); //左侧引伸量 tb.Cells[2 + i, 7].TextString = rightDrawAmounts[i].ToString("F0"); //右侧引伸量 tb.Cells[2 + i, 8].TextString = clearLens[i].ToString("F0"); //波纹管长 for (int j = 0; j < pipeDiasDist.Count; j++) //管道总长 { if (pipeDias[i] == pipeDiasDist[j]) //找到对应直径列 { tb.Cells[2 + i, 9 + j].TextString = (clearLens[i] * tdNums[i] / 1000).ToString("F1"); break; } } for (int j = 0; j < tdStylesDist.Count; j++) //锚具套数 { if (tdStyles[i] == tdStylesDist[j]) //找到对应规格列 { tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j].TextString //张拉套数 = (tdNums[i] * (2 - Math.Abs(drawTypes[i]))).ToString("F0"); tb.Cells[2 + i, 9 + pipeDiasDist.Count + 2 * j + 1].TextString //锚固套数 = (tdNums[i] * Math.Abs(drawTypes[i])).ToString("F0"); } } tb.Cells[2 + i, tb.Columns.Count - 2].TextString = TendonGeneralParameters.CtrlStress.ToString("F0");//控制应力 tb.Cells[2 + i, tb.Columns.Count - 1].TextString = (drawTypes[i] == 0) ? "两端张拉" : "单端张拉"; } //3.5 填写最后一行合计内容并删除合计为0的锚具列 tb.Cells[tb.Rows.Count - 1, 0].TextString = "合计"; //总重合计 tb.Cells[tb.Rows.Count - 1, 5].TextString = tb.Columns[5] .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1) .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1"); //管道总长合计 for (int j = 0; j < pipeDiasDist.Count; j++)//管道总长 { tb.Cells[tb.Rows.Count - 1, 9 + j].TextString = tb.Columns[9 + j] .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty) .Sum(c => double.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F1"); } //锚具套数合计 for (int j = 0; j < 2 * tdStylesDist.Count; j++) { tb.Cells[tb.Rows.Count - 1, 9 + pipeDiasDist.Count + j].TextString = tb.Columns[9 + pipeDiasDist.Count + j] .Where(c => c.Row > 1 && c.Row < tb.Rows.Count - 1 && (bool)!tb.Cells[c.Row, c.Column].IsEmpty) .Sum(c => int.Parse(tb.Cells[c.Row, c.Column].TextString)).ToString("F0"); } //删除锚具套数合计为0的列,减小表格规模 var voidCols = tb.Rows[tb.Rows.Count - 1] .Where(c => c.Column >= 9 + pipeDiasDist.Count && c.Column <= tb.Columns.Count - 3) .Where(c => int.Parse(tb.Cells[c.Row, c.Column].TextString) == 0) .Select(c => c.Column) .OrderByDescending(c => c); foreach (int iCol in voidCols) { tb.DeleteColumns(iCol, 1);//依次删除套数为0的列 } //3.6 将表格按照输入比例缩放 double scale = double.Parse(textBoxScale.Text); Matrix3d mt = Matrix3d.Scaling(scale, ptRes.Value); tb.TransformBy(mt); tb.GenerateLayout(); //更新表格 db.AddToModelSpace(tb); //将表格加入数据库 trans1.Commit(); //执行事务处理 } //4.输出表格并查看后重新返回对话框还是离开程序 PromptKeywordOptions kwOpt = new PromptKeywordOptions("\n返回对话框还是退出程序[返回对话框(R)/退出程序(任意键)]"); kwOpt.AllowArbitraryInput = true; kwOpt.AllowNone = false; PromptResult keRes = ed.GetKeywords(kwOpt); if (keRes.Status == PromptStatus.OK && keRes.StringResult == "R") { this.Show(); } else { this.Close(); } }
selectAlignment(ObjectId idAlign) { Alignment objAlign = (Alignment)idAlign.getEnt(); AlgnData alignData = new AlgnData(); AlgnData alignDataX = new AlgnData(); Point3d pnt3dPicked = Pub.pnt3dO; string nameAlign = ""; if ((idAlign == null)) { idAlign = Align.selectAlign("\nSelect Alignment: ", "Alignment Selection Failed", out pnt3dPicked, out nameAlign); } ResultBuffer rb = idAlign.getXData("PROFILE"); if (rb == null) { return(false); } TypedValue[] tvs = rb.AsArray(); fStake.HandleProfileView = tvs[1].Value.ToString().stringToHandle(); rb = idAlign.getXData("CLASS"); if (rb == null) { return(false); } tvs = rb.AsArray(); string strClass = tvs[1].Value.ToString(); fStake.ClassObj = strClass; Alignment align = (Alignment)idAlign.getEnt(); fStake.ACTIVEALIGN = align; fStake.HandleAlign = idAlign.getHandle(); fStake.objectID = idAlign; int result = 0; for (int i = nameAlign.Length - 1; i >= 1; i += -1) { if (!nameAlign.Substring(i, 1).isInteger(out result)) { fStake.NameStakeObject = nameAlign.Substring(0, i); break; } } ObjectId idTable = ObjectId.Null; Table table = null; try { idTable = Stake_Table.getTableId(idAlign); } catch (System.Exception) { try { SelectionSet ss = Select.buildSSet(typeof(Table)); ObjectId[] ids = ss.GetObjectIds(); using (Transaction tr = BaseObjs.startTransactionDb()) { for (int i = 0; i < ids.Length; i++) { table = (Table)tr.GetObject(ids[i], OpenMode.ForRead); if (table.Cells[1, 1].Value.ToString() == nameAlign) { TypedValue[] t = new TypedValue[2]; t.SetValue(new TypedValue(1001, "TABLE"), 0); t.SetValue(new TypedValue(1005, ids[i].getHandle()), 1); idAlign.setXData(t, "TABLE"); break; } } } } catch (System.Exception) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Select Table Failed"); } } switch (fStake.algnData.Count) { case 0: alignData.AlignHandle = align.Handle; alignData.TableHandle = table.Handle; alignData.AlignID = idAlign; alignData.AlignName = nameAlign; alignData.AlignLayer = align.Layer; fStake.algnData.Add(alignData); break; case 1: alignData = fStake.algnData[0]; if (alignData.AlignHandle == align.Handle) { alignData.TableHandle = table.Handle; } else { alignDataX.AlignHandle = align.Handle; alignDataX.TableHandle = table.Handle; alignDataX.AlignID = idAlign; alignDataX.AlignName = align.Name; alignDataX.AlignLayer = align.Layer; fStake.algnData.Add(alignDataX); } break; default: bool boolFound = false; for (int i = fStake.algnData.Count; i > 1; i--) { alignDataX = fStake.algnData[i - 1]; alignData = fStake.algnData[i]; if (alignDataX.AlignHandle == alignData.AlignHandle) { fStake.algnData.RemoveAt(i); } } for (int i = 1; i < fStake.algnData.Count; i++) { alignData = fStake.algnData[i]; if (alignData.AlignHandle == objAlign.Handle) { alignData.TableHandle = idTable.getHandle(); boolFound = true; } } if (!boolFound) { alignDataX.AlignHandle = objAlign.Handle; alignDataX.TableHandle = idTable.getHandle(); alignDataX.AlignID = idAlign; alignDataX.AlignName = objAlign.Name; alignDataX.AlignLayer = objAlign.Layer; fStake.algnData.Add(alignDataX); } break; } fStake.POI_CALC = Stake_Table.resetPOI(idTable); Stake_Misc.set_fStakeProps(strClass); if (strClass == "BLDG") { Stake_Grid.updateGridCollections(objAlign.Name); Application.ShowModelessDialog(Application.MainWindow.Handle, fGrid, false); fStake.Hide(); } fStake.ACTIVEALIGN = objAlign; return(true); }
modifyStaking(List <POI> varpoi) { Alignment objAlign = fStake.ACTIVEALIGN; ObjectId idAlign = objAlign.ObjectId; List <POI> varPOIadd = new List <POI>(); if (Stake_GetCardinals.userAddCrossingsFeatures(idAlign, ref varPOIadd)) { switch (fStake.ClassObj) { case "WTR": Stake_GetSurfaceElev.getSurfaceElevations(idAlign, ref varPOIadd); break; case "ALIGN": case "SEWER": Stake_GetSurfaceElev.getProfileElevations(idAlign, "STAKE", ref varPOIadd); break; } for (int i = 0; i <= varPOIadd.Count; i++) { varpoi.Add(varPOIadd[i]); } var sortSta = from s in varpoi orderby s.Station ascending select s; List <POI> poitmp = new List <POI>(); foreach (var s in sortSta) { poitmp.Add(s); } varpoi = poitmp; Stake_AddProfile.makeProfile(idAlign, varpoi, "STAKE", "ByLayout", true); switch (fStake.ClassObj) { case "ALIGN": case "SEWER": Stake_UpdateProfile.updateProfile(idAlign, varpoi, "STAKE", false, "STAKE"); break; } List <AlgnData> algnData = fStake.algnData; AlgnData aData = new AlgnData(); Table objTable = null; for (int i = 1; i < algnData.Count; i++) { aData = algnData[i]; if (aData.AlignHandle == objAlign.Handle) { objTable = (Table)aData.TableHandle.getEnt(); objTable.ObjectId.delete(); break; } } ObjectId idTable = Stake_Table.makeTable(idAlign, varpoi, aData); Stake_Table.addTableData(idTable, varpoi); } return(varpoi); }
setupSpreadSheetMS(double dblVolCut = 0, double dblVolFill = 0) { bool boolIsOpen = false; if (dblVolFill == 0) { bool exists; ObjectId idSurfaceCUT = Surf.getSurface("VOL_EXIST_BOT", out exists); ObjectId idSurfaceFILL = Surf.getSurface("VOL_BOT_SG", out exists); TinVolumeSurface objSurfaceFILL = (TinVolumeSurface)idSurfaceFILL.getEnt(); TinVolumeSurface objSurfaceCUT = (TinVolumeSurface)idSurfaceCUT.getEnt(); dblVolCut = objSurfaceFILL.GetVolumeProperties().UnadjustedCutVolume / 27; dblVolFill = objSurfaceFILL.GetVolumeProperties().UnadjustedFillVolume / 27; dblVolCut = dblVolCut + objSurfaceCUT.GetVolumeProperties().UnadjustedCutVolume / 27; dblVolFill = dblVolFill + objSurfaceCUT.GetVolumeProperties().UnadjustedFillVolume / 27; } string strPath = BaseObjs.docFullName; string strJN = BaseObjs.jobNumber(); string strFN = string.Format("{0}EW.xlsx", strJN); string strFullPath = strPath + "\\" + strFN; SelectionSet objSSet = EW_Utility1.buildSSet8(); objSSet.eraseSelectedItems(); objSSet = EW_Utility1.buildSSetTable(); Table objTable = (Table)objSSet.GetObjectIds()[0].getEnt(); Point3d varPntIns = objTable.Position; double dblWidth = objTable.Width; double dblHeight = objTable.Height; double dblPntX = varPntIns.X + dblWidth + 10; double dblPntY = varPntIns.Y - 8; string strPntX = System.Math.Round(dblPntX, 2).ToString(); string strPntY = System.Math.Round(dblPntY, 2).ToString(); string strPntIns = string.Format("{0},{1}", strPntX, strPntY); Excel._Application objExcelApp = (Excel._Application)Microsoft.VisualBasic.Interaction.GetObject(null, "Excel.Application"); Excel.Workbook objWB = null; Excel_ext excl = null; if (objExcelApp == null) { excl = new Excel_ext(); objExcelApp = excl.excelAPP; } else { for (int i = 1; i < objExcelApp.Workbooks.Count; i++) { objWB = objExcelApp.Workbooks[i]; if (objWB.Name == strFN) { boolIsOpen = true; break; } } } objExcelApp.Visible = true; if (!boolIsOpen) { if (FileSystem.FileExists(strFullPath)) { objWB = objExcelApp.Workbooks.Open(strFullPath); } else { FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath); objWB = objExcelApp.Workbooks.Open(strFullPath); string mess = string.Format("{0} not found. A copy of the template has been created in {1}\nExiting...", strFN, strPath); MessageBox.Show(mess); } } Excel.Worksheet objWS = objWB.Worksheets["SUMMARY"]; objWS.Activate(); objWS.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible; objWS.Range["SUMMARY!volCUT"].Value = dblVolCut; objWS.Range["SUMMARY!volFILL"].Value = dblVolFill; objWS.Range["SUMMARY!JOB_NUMBER"].Value = BaseObjs.docName.Substring(1, 4); objWS.Range["EW_SUMMARY"].Copy(); objExcelApp.Visible = true; BaseObjs._editor.Regen(); BaseObjs._acadDoc.SendStringToExecute(string.Format("_pasteclip {0}\r", strPntIns), true, false, false); objSSet = EW_Utility1.buildSSet8(); Autodesk.AutoCAD.DatabaseServices.Ole2Frame objAcadOle = null; if (objSSet == null || objSSet.Count == 0) { SelectionSet ss = BaseObjs._editor.SelectAll().Value; int k = ss.Count; ObjectId id = ss.GetObjectIds()[k - 1]; using (var tr = BaseObjs.startTransactionDb()) { objAcadOle = (Ole2Frame)tr.GetObject(id, OpenMode.ForWrite); objAcadOle.LockAspect = false; objAcadOle.WcsHeight = dblHeight; objAcadOle.WcsWidth = dblHeight / 2; objAcadOle.Layer = "ZZ_ZZ-SPREADSHEET"; tr.Commit(); } } else { using (var tr = BaseObjs.startTransactionDb()){ objAcadOle = (Ole2Frame)tr.GetObject(objSSet.GetObjectIds()[0], OpenMode.ForWrite); objAcadOle.LockAspect = false; objAcadOle.WcsHeight = dblHeight; objAcadOle.WcsWidth = dblHeight / 2; objAcadOle.Layer = "ZZ_ZZ-SPREADSHEET"; } } BaseObjs.acadActivate(); }
addExcelWorkbook() { string strPath = BaseObjs.docFullName; string strJN = BaseObjs.jobNumber(); string strFN = string.Format("{0}EW.xlsx", strJN); string strFullPath = string.Format("{0}\\{1}", Path.GetDirectoryName(strPath), strFN); string mess = string.Format("{0} exists. Overwrite existing file? Y/N", strFN); if (FileSystem.FileExists(strFullPath)) { DialogResult varResponse = MessageBox.Show(mess, "File exists!", MessageBoxButtons.YesNo); switch (varResponse) { case DialogResult.Yes: try { FileSystem.DeleteFile(strFullPath); } catch (Exception) { MessageBox.Show("Error deleting existing file - good luck"); return; } FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath); mess = string.Format("{0} created in {1} folder.", strFN, strPath); MessageBox.Show(mess); break; case DialogResult.No: break; //do nothing } } else { FileSystem.CopyFile("R:\\TSet\\Template\\EARTHWORK\\0000EW.xlsx", strFullPath); mess = string.Format("{0} created in {1} folder.", strFN, strPath); MessageBox.Show(mess); } Excel_ext excl = new Excel_ext(true); excl.OpenFile(strFullPath, ""); excl.FindExcelWorksheet("SUMMARY"); Excel._Worksheet objWS = excl.excelWrkSht; ProjectData varProjectData = Misc.getProjectData(strJN); if (varProjectData.Name.ToString() != string.Empty) { objWS.Range["SUMMARY!SITE_NAME"].Value = varProjectData.Name; objWS.Range["SUMMARY!LOCATION"].Value = varProjectData.Location; objWS.Range["SUMMARY!CLIENT"].Value = varProjectData.Client; objWS.Range["SUMMARY!JOB_NUMBER"].Value = varProjectData.Number; objWS.Range["SUMMARY!COORDINATOR"].Value = varProjectData.Coordinator; objWS.Range["SUMMARY!SOURCE"].Value = BaseObjs.docName; } double dblAreaPad = 0; int intCount = 0; SelectionSet objSSet = EW_Utility1.buildSSetTable(); Table objTable = (Table)objSSet.GetObjectIds()[0].getEnt(); if (EW_Pub.OX_LIMIT_H == 0) { EW_Pub.OX_LIMIT_H = double.Parse(objTable.Cells[20, 1].Value.ToString()); } objSSet = EW_Utility1.buildSSetBLDG_LIM(); foreach (ObjectId idBldgLim in objSSet.GetObjectIds()) { ObjectId idBldgLimOffset = idBldgLim.offset(EW_Pub.OX_LIMIT_H); if ((idBldgLimOffset.IsNull)) { intCount++; } else { dblAreaPad = dblAreaPad + idBldgLimOffset.getArea(); idBldgLimOffset.delete(); } } if (intCount > 0) { MessageBox.Show(string.Format("{0} Building Limit Area(s) failed. Requires manual calculation.", intCount)); } objWS.Range["SUMMARY!AREA_PAD"].Value = (int)dblAreaPad; double dblAreaSite = 0; Polyline objGradingLim = default(Polyline); objSSet = EW_Utility1.buildSSetGradingLim(); objGradingLim = (Polyline)objSSet.GetObjectIds()[0].getEnt(); dblAreaSite = objGradingLim.Area; objWS.Range["SUMMARY!AREA_SITE"].Value = (int)dblAreaSite; excl.CloseFile(true, strFullPath, false); }
updateAlignData() { ObjectIdCollection idsAlign = Align.getAlignmentIDs(); List <AlgnData> alignData = new List <AlgnData>(); foreach (ObjectId id in idsAlign) { Alignment objAlign = (Alignment)id.getEnt(); ResultBuffer rb = id.getXData("CLASS"); if (rb != null) { rb = id.getXData("TABLE"); if (rb != null) { TypedValue[] tvs = rb.AsArray(); AlgnData aData = new AlgnData(); aData.TableHandle = tvs[1].Value.ToString().stringToHandle(); aData.AlignLayer = objAlign.Layer; aData.AlignName = objAlign.Name; aData.AlignHandle = objAlign.Handle; aData.AlignID = objAlign.ObjectId; alignData.Add(aData); } else { SelectionSet objSSet = Select.buildSSet(typeof(Table)); if (objSSet.Count > 0) { ObjectId[] ids = objSSet.GetObjectIds(); foreach (ObjectId idTable in ids) { Table table = (Table)idTable.getEnt(); if (table.Cells[1, 1].Contents[0].ToString() == objAlign.Name) { TypedValue[] tvs = new TypedValue[2]; tvs.SetValue(new TypedValue(1001, "TABLE"), 0); tvs.SetValue(new TypedValue(1005, table.Handle), 0); id.setXData(tvs, "TABLE"); AlgnData aData = new AlgnData(); aData.TableHandle = table.Handle; aData.AlignLayer = objAlign.Layer; aData.AlignName = objAlign.Name; aData.AlignHandle = objAlign.Handle; aData.AlignID = objAlign.ObjectId; alignData.Add(aData); } } } else { string message = string.Format("Table for Align: {0} is missing -> redo alignment!!", objAlign.Name); Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(message); } } } } }
syncTableWithProfile() { List <POI> varPOIcur = fStake.POI_CALC; Alignment objAlign = fStake.ACTIVEALIGN; ObjectId idAlign = objAlign.ObjectId; ResultBuffer rb = idAlign.getXData("CLASS"); if (rb == null) { return; } TypedValue[] tvs = rb.AsArray(); fStake.ClassObj = tvs[1].Value.ToString(); Profile objProfile = null; try { objProfile = Prof.getProfile(idAlign, "STAKE"); } catch (System.Exception) { } ProfilePVICollection objProfilePVIs = objProfile.PVIs; Table objTable = null; ObjectId idTable = ObjectId.Null; try { idTable = Stake_Table.getTableId(idAlign); } catch (System.Exception) { try { SelectionSet ss = Select.buildSSet(typeof(Table)); ObjectId[] ids = ss.GetObjectIds(); if (ids.Length > 0) { for (int i = 0; i < ids.Length; i++) { idTable = ids[i]; objTable = (Table)idTable.getEnt(); if (objTable.Cells[1, 1].TextString == objAlign.Name) { break; } } } } catch (System.Exception) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Select Table Failed"); return; } } fStake.POI_CALC = resetPOI(idTable); List <POI> varPOITmp = fStake.POI_CALC; List <POI> varpoi = new List <POI>(); List <POI> varpoiAdd = new List <POI>(); Debug.Print(varPOITmp.Count.ToString()); ProfilePVI objProfilePVI = null; for (int i = 0; i < varPOITmp.Count; i++) { for (int j = 0; j < objProfilePVIs.Count; j++) { objProfilePVI = objProfilePVIs[j]; if (Math.roundDown2((objProfilePVI.Station)) == Math.roundDown2(varPOITmp[i].Station)) { varpoi.Add(varPOITmp[i]); break; } } } bool boolExists = false; for (int i = 0; i < objProfilePVIs.Count; i++) { boolExists = false; objProfilePVI = objProfilePVIs[i]; for (int j = 0; j < varpoi.Count; j++) { if (Math.roundDown2(varpoi[j].Station) == Math.roundDown2((objProfilePVI.Station))) { boolExists = true; break; } } if (!boolExists) { POI vpoi = new POI(); vpoi.Station = Math.roundDown3((objProfilePVI.Station)); vpoi.Elevation = objProfilePVI.Elevation; vpoi.ClassObj = fStake.ClassObj; vpoi.Desc0 = "GB"; varpoiAdd.Add(vpoi); } } if (varpoiAdd[0].Desc0 != "NOTHING") { for (int i = 0; i < varpoiAdd.Count; i++) { varpoi.Add(varpoiAdd[i]); } } var sortSta = from p in varpoi orderby p.Station ascending select p; List <POI> poiTmp = new List <POI>(); foreach (var p in sortSta) { poiTmp.Add(p); } varpoi = poiTmp; updateTableData(idTable, varpoi); fStake.POI_CALC = varpoi; }
makeTable(ObjectId idAlign, List <POI> varpoi, AlgnData varAlignData = null, object varPntUpper = null) { Alignment objAlign = (Alignment)idAlign.getEnt(); string strLayerName = "TABLES"; Layer.manageLayers(strLayerName); Extents3d ext3d; Point3d pnt3dMin = Pub.pnt3dO, pnt3dMax = Pub.pnt3dO, pnt3dIns = Pub.pnt3dO; Table objTable = null; ObjectId idTable = ObjectId.Null; int numRows = varpoi.Count + 2; int numCols = 33; double rowHeight = 5; double colWidth = 30; if ((varAlignData == null)) { if ((varPntUpper == null)) { ProfileView objProfileView = (ProfileView)fStake.HandleProfileView.getEnt(); ext3d = (Extents3d)objProfileView.Bounds; pnt3dMin = ext3d.MinPoint; pnt3dMax = ext3d.MaxPoint; pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0); idTable = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth); AlgnData algnData = new AlgnData(); algnData.AlignName = objAlign.Name; algnData.AlignHandle = objAlign.Handle; algnData.AlignLayer = objAlign.Layer; algnData.AlignID = objAlign.ObjectId; algnData.TableHandle = idTable.getHandle(); fStake.algnData.Add(algnData); } else //for WALL only { pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0); idTable = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth); AlgnData algnData = new AlgnData(); algnData.AlignName = objAlign.Name; algnData.AlignHandle = objAlign.Handle; algnData.AlignLayer = objAlign.Layer; algnData.AlignID = objAlign.ObjectId; algnData.TableHandle = idTable.getHandle(); fStake.algnData.Add(algnData); } } else { ProfileView objProfileView = (ProfileView)fStake.HandleProfileView.getEnt(); ext3d = (Extents3d)objProfileView.Bounds; pnt3dMin = ext3d.MinPoint; pnt3dMax = ext3d.MaxPoint; pnt3dIns = new Point3d(pnt3dMax.X + 10, pnt3dMax.Y, 0); idTable = Draw.addTable(pnt3dIns, numRows, numCols, rowHeight, colWidth); varAlignData.TableHandle = idTable.getHandle(); } using (Transaction tr = BaseObjs.startTransactionDb()) { objTable = (Table)tr.GetObject(idTable, OpenMode.ForWrite); objTable.Layer = strLayerName; objTable.ColorIndex = 41; objTable.SuppressRegenerateTable(true); objTable.Cells[0, 0].TextString = objAlign.Name; objTable.Cells[1, 0].TextString = "INDEX"; objTable.Cells[1, 1].TextString = "CLASS"; objTable.Cells[1, 2].TextString = "DESCO"; objTable.Cells[1, 3].TextString = "DESCX"; objTable.Cells[1, 4].TextString = "STATION"; objTable.Cells[1, 5].TextString = "OFFSET"; objTable.Cells[1, 6].TextString = "ELEVATION"; objTable.Cells[1, 7].TextString = "TOW"; objTable.Cells[1, 8].TextString = "TOF"; objTable.Cells[1, 9].TextString = "INVERT"; objTable.Cells[1, 10].TextString = "SIZE"; objTable.Cells[1, 11].TextString = "ANGDELTA"; objTable.Cells[1, 12].TextString = "ANGDIR"; objTable.Cells[1, 13].TextString = "ANGCHORD"; objTable.Cells[1, 14].TextString = "ISRIGHTHAND"; objTable.Cells[1, 15].TextString = "ISCLOSED"; objTable.Cells[1, 16].TextString = "ISSTEP"; objTable.Cells[1, 17].TextString = "CROSSDESC"; objTable.Cells[1, 18].TextString = "CROSSALIGN"; objTable.Cells[1, 19].TextString = "CROSSALIGNINV"; objTable.Cells[1, 20].TextString = "CROSSALIGNSTA"; objTable.Cells[1, 21].TextString = "CROSSALIGNSIZE"; objTable.Cells[1, 22].TextString = "PNTNUM"; objTable.Cells[1, 23].TextString = "PNTSOURCE"; objTable.Cells[1, 24].TextString = "TYPE"; objTable.Cells[1, 25].TextString = "BULGE"; objTable.Cells[1, 26].TextString = "RADIUS"; objTable.Cells[1, 27].TextString = "SIDE"; objTable.Cells[1, 28].TextString = "SLOPEAHEAD"; objTable.Cells[1, 29].TextString = "SLOPEBACK"; objTable.Cells[1, 30].TextString = "SLOPEH2H"; objTable.Cells[1, 31].TextString = "XCEN"; objTable.Cells[1, 32].TextString = "YCEN"; objTable.Columns[0].Width = 18.0; objTable.Columns[1].Width = 18.0; objTable.Columns[4].Width = 18.0; objTable.Columns[5].Width = 18.0; objTable.Columns[6].Width = 18.0; objTable.Columns[9].Width = 18.0; objTable.Columns[10].Width = 18.0; for (int i = 0; i < objTable.Rows.Count; i++) { for (int j = 0; j < objTable.Columns.Count; j++) { objTable.Cells[i, j].TextHeight = 0.09 * Misc.getCurrAnnoScale(); objTable.Cells[i, j].Alignment = CellAlignment.MiddleCenter; } } objTable.SuppressRegenerateTable(false); tr.Commit(); } TypedValue[] tvs = new TypedValue[2] { new TypedValue(1001, "TABLE"), new TypedValue(1005, objTable.Handle) }; objAlign.ObjectId.setXData(tvs, "TABLE"); Stake_Dict.updateDictSTAKE(); return(objTable.ObjectId); }
private void cmdSetup_Click(object sender, RoutedEventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Browse to Project Folder"; fbd.ShowDialog(); string strPath = fbd.SelectedPath; int intPosX = 1, intPos = 0; if (strPath == "") { System.Windows.MessageBox.Show("No Folder Selected"); return; } else { while (intPosX != 0) { intPos = intPosX + 1; intPosX = (short)(strPath.IndexOf("\\", intPos - 1) + 1); } } string strJN = strPath.Substring(intPos - 1); strPath = string.Format("{0}\\{1}EW.dwg", strPath, strJN); if (FileSystem.FileExists(strPath)) { MessageBoxResult varResponse = System.Windows.MessageBox.Show(string.Format("File {0} exists! Make Backup??", strPath), "File Exists!", MessageBoxButton.YesNoCancel); if (varResponse == MessageBoxResult.Yes) { FileInfo fileInfo; fileInfo = FileSystem.GetFileInfo(strPath); string strDateCreated = (fileInfo.LastAccessTime).ToString(); intPos = (short)(strDateCreated.IndexOf(" ") + 1); strDateCreated = strDateCreated.Substring(0, intPos - 1); strDateCreated = strDateCreated.Replace("/", "_"); intPos = strPath.IndexOf("."); FileSystem.CopyFile(strPath, string.Format("{0}_{1}.dwg", strPath.Substring(0, intPos - 1), strDateCreated)); FileSystem.DeleteFile(strPath); } else if (varResponse == MessageBoxResult.No) { FileSystem.DeleteFile(strPath); } else if (varResponse == MessageBoxResult.Cancel) { return; } } using (BaseObjs._acadDoc.LockDocument()) { Document objDwgEW = DocumentCollectionExtension.Add(BaseObjs._acadDocs, @"R:\TSET\Template\CIVIL3D2015\EW.dwt"); BaseObjs._acadDoc.Database.SaveAs(strPath, true, DwgVersion.Current, BaseObjs._acadDoc.Database.SecurityParameters); } using (BaseObjs._acadDoc.LockDocument()) { xRef.doMXR(); } Point3d pnt3dUR = BaseObjs._acadDoc.Database.Extmax; SelectionSet objSSet = EW_Utility1.buildSSetTable(); ObjectId[] ids = objSSet.GetObjectIds(); if (ids == null || ids.Length == 0) { return; } Table tbl = null; using (BaseObjs._acadDoc.LockDocument()) { ObjectId id = ids[0]; try { using (Transaction tr = BaseObjs.startTransactionDb()) { tbl = (Table)tr.GetObject(id, OpenMode.ForWrite); Extents3d ext3d = (Extents3d)tbl.Bounds; tbl.TransformBy(Matrix3d.Displacement(new Vector3d(pnt3dUR.X, pnt3dUR.Y, 0))); objSSet = Base_Tools45.Select.buildSSet(typeof(Polyline), ext3d.MinPoint, ext3d.MaxPoint); ids = objSSet.GetObjectIds(); ObjectIdCollection idsm = new ObjectIdCollection(); foreach (ObjectId idm in ids) { idsm.Add(idm); } idsm.moveObjs(Point3d.Origin, pnt3dUR); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(string.Format("{0} frmEarthwork.cs: line: 137", ex.Message)); } Layer.manageLayers("0"); string strDwgName = BaseObjs.docName; intPos = strDwgName.IndexOf(".") + 1; strDwgName = strDwgName.Substring(0, intPos - 1); BlockReference blkRef; blkRef = xRef.getXRefBlockReference("CNTL"); if (blkRef != null) { string strBlkName = blkRef.Name; BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rF\r{0}*\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|CURB\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|GB\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|BLDG\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|FL\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|FS\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|GUTTER\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|WALL\r\r", strBlkName), true, false, false); } blkRef = xRef.getXRefBlockReference("BNDRY"); if (blkRef != null) { string strBlkName = blkRef.Name; BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rF\r{0}*\r\r", strBlkName), true, false, false); BaseObjs._acadDoc.SendStringToExecute(string.Format("-LA\rT\r{0}|PL\r\r", strBlkName), true, false, false); } View.ZoomExtents(); } System.Windows.Forms.MessageBox.Show("User needs to create data shortcut for Surfaces: CPNT-ON and EXIST"); }
cmdSections(ObjectId idAlign, double dblOffR, double dblOffL) { ObjectId idSectionStyleEXIST = default(ObjectId); ObjectId idSectionStyleEXIST90 = default(ObjectId); ObjectId idSectionStyleCPNT = default(ObjectId); ObjectId idSectionStyleSG = default(ObjectId); ObjectId idSectionStyleOX = default(ObjectId); ObjectId idSectionStyleOXg = default(ObjectId); ObjectId idSectionStyleBOT = default(ObjectId); ObjectId idSectionStyleMID = default(ObjectId); ObjectIdCollection idsSurface = new ObjectIdCollection(); bool exists = false; ObjectId idSurfaceEXIST = Surf.getSurface("EXIST", out exists); if (!exists) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Surface EXIST is missing - exiting!"); return; } else { idsSurface.Add(idSurfaceEXIST); idSectionStyleEXIST = Sect_Style.getSectionStyleId("EXIST"); } ObjectId idSurfaceEXIST90 = Surf.getSurface("EXIST90", out exists); if (!exists) { // MsgBox "Surface EXIST is missing - exiting!" // Exit Sub } else { idsSurface.Add(idSurfaceEXIST90); idSectionStyleEXIST90 = Sect_Style.getSectionStyleId("EXIST90"); } ObjectId idSurfaceCPNT = Surf.getSurface("CPNT-ON", out exists); if (!exists) { // MsgBox "Surface CPNT-ON is missing - exiting!" // Exit Sub } else { idsSurface.Add(idSurfaceCPNT); idSectionStyleCPNT = Sect_Style.getSectionStyleId("CPNT"); } ObjectId idSurfaceSG = Surf.getSurface("SG", out exists); if (!exists) { } else { idsSurface.Add(idSurfaceSG); idSectionStyleSG = Sect_Style.getSectionStyleId("SG"); } ObjectId idSurfaceOX = Surf.getSurface("OX", out exists); if (!exists) { } else { idsSurface.Add(idSurfaceOX); idSectionStyleOX = Sect_Style.getSectionStyleId("OX"); } ObjectId idSurfaceOXg = Surf.getSurface("OXg", out exists); if (!exists) { } else { idsSurface.Add(idSurfaceOXg); idSectionStyleOXg = Sect_Style.getSectionStyleId("OXg"); } ObjectId idSurfaceBOT = Surf.getSurface("BOT", out exists); if (!exists) { } else { idsSurface.Add(idSurfaceBOT); idSectionStyleBOT = Sect_Style.getSectionStyleId("BOT"); } if (idSectionStyleBOT == ObjectId.Null) { EW_Utility1.copyEWstyles(); } ObjectId idSurfaceMID = Surf.getSurface("MIDGRADE", out exists); if (!exists) { } else { idsSurface.Add(idSurfaceMID); idSectionStyleMID = Sect_Style.getSectionStyleId("EXIST90"); } idAlign.removeSampleLineGroups(); ObjectId idSLG = idAlign.addSampleLineGroupAndSampleLines("EW"); idSLG.removeSampledSurfaces(); idSLG.addSurfaceToSample(idsSurface); idAlign.addSections(idSLG, dblOffL, dblOffR); ObjectId idGroupPlotStyle = ObjectId.Null; GroupPlotStyleCollection grpPltStyles = BaseObjs._civDoc.Styles.GroupPlotStyles; if (!grpPltStyles.Contains("EW")) { EW_Utility1.copyEWstyles(); idGroupPlotStyle = BaseObjs._civDoc.Styles.GroupPlotStyles["EW"]; } SampleLineStyleCollection sampleLineStyles = BaseObjs._civDoc.Styles.SampleLineStyles; ObjectId idSampleLineStyle = sampleLineStyles["Standard"]; SectionLabelSetStyleCollection sectionLabelSetStyles = BaseObjs._civDoc.Styles.LabelSetStyles.SectionLabelSetStyles; double dblWidth = 0; double dblHeight = 0; Autodesk.AutoCAD.DatabaseServices.Table objTable = default(Autodesk.AutoCAD.DatabaseServices.Table); SelectionSet objSSet = default(SelectionSet); objSSet = EW_Utility1.buildSSetTable(); objTable = (Autodesk.AutoCAD.DatabaseServices.Table)objSSet.GetObjectIds()[0].getEnt(); Point3d varPntIns = objTable.Position; dblWidth = objTable.Width; dblHeight = objTable.Height; Point3d dblPntBase = new Point3d(varPntIns.X + dblWidth + 600, varPntIns.Y - dblHeight, 0); SectionViewStyle objSectionViewStyle = Sect_Style.getSectionViewStyle("EW"); if (objSectionViewStyle == null) { EW_Utility1.copyEWstyles(); objSectionViewStyle = objSectionViewStyle = Sect_Style.getSectionViewStyle("EW"); } SectionViewBandSetStyle objSectionViewBandSetStyle = Sect_Style.getSectionViewBandSetStyle("Standard"); double dblOffX = 0; double dblOffY = 0; bool boolFirstPass = false; boolFirstPass = true; dblOffX = 0; dblOffY = 0; Point3d dblPntIns = Pub.pnt3dO; int j = 0; ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs(); using (var tr = BaseObjs.startTransactionDb()) { for (int i = 0; i < idsSampleLine.Count; i += 5) { SampleLine sl = (SampleLine)tr.GetObject(idsSampleLine[i], OpenMode.ForRead); dblPntIns = new Point3d(dblPntBase.X + i / 5 * dblOffX, dblPntBase.Y, 0); int k = -1; while (j < idsSampleLine.Count) { k = k + 1; ObjectId idSectionView = SectionView.Create(string.Format("SV-{0}", j), sl.ObjectId, dblPntIns); SectionView objSectionView = (SectionView)tr.GetObject(idSectionView, OpenMode.ForWrite); if (boolFirstPass) { dblOffX = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30; boolFirstPass = false; } Extents3d ext3d = (Extents3d)objSectionView.Bounds; dblOffY = ext3d.MaxPoint.Y - ext3d.MinPoint.Y + 30; dblPntIns = new Point3d(dblPntIns.X, dblPntIns.Y + dblOffY, 0);//increment Y after placing first section in column objSectionView = null; j = j + 1; if (k == 4) { break; } } } tr.Commit(); } BaseObjs.acadActivate(); return; }