public void Add() { try { if (SelectedDgnLevel == null) { MessageBox.Show("未选择线段所在图层\n请重新选择图层", "未选择图层", MessageBoxButton.OK, MessageBoxImage.Error); return; } //扫描图中的线段 BD.ScanCriteria sc = new Bentley.DgnPlatformNET.ScanCriteria(); sc.SetModelRef(Program.GetActiveDgnModelRef()); BD.BitMask bm = new BD.BitMask(true); bm.Set((uint)BD.MSElementType.Line); sc.SetElementTypeTest(bm); var elelist = new List <BDE.Element>(); sc.Scan((ele, dgnmodel) => { var level = Program.GetActiveDgnModel().GetLevelCache().GetLevel(ele.LevelId, true); if (ele.ElementType == BD.MSElementType.Line && ele.LevelId == SelectedDgnLevel.LevelId) { elelist.Add(ele); } return(BD.StatusInt.Success); }); if (elelist.Count == 0) { MessageBox.Show("所选图层中不存在线段元素\n请重新选择图层或绘制代表桩的线段", "所选图层无线段", MessageBoxButton.OK, MessageBoxImage.Error); return; } PileFactory pilefactory = null; var pileproplist = new List <IPileProperty>(); var pilenamelist = new List <string>(); var pileIdlist = new List <long>(); switch (SelectedPileType) { case PileType.Solid: pilefactory = new SolidPileFactory(GammaR); foreach (var pile in elelist) { //BG.DRange3d range; //((BDE.LineElement)pile).CalcElementRange(out range);//有问题 BG.DPoint3d startp, endp; if (!((BDE.LineElement)pile).GetCurveVector().GetStartEnd(out startp, out endp)) { System.Windows.Forms.MessageBox.Show($"无法获取Pile ID:{pile.ElementId}的起始点和终点"); return; } switch (SelectedPileCrossSectionType) { case SoildPileCrossSectionType.SquareWithRoundHole: pileproplist.Add(new SquareWithRoundHolePileGeometry() { PileDiameter = this.PileDiameter, PileInnerDiameter = this.PileInnerDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = startp.DPoint3dToPoint3d(1e-4), PileBottomPoint = endp.DPoint3dToPoint3d(1e-4) }); break; case SoildPileCrossSectionType.Square: pileproplist.Add(new SquarePileGeometry() { PileDiameter = this.PileDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = startp.DPoint3dToPoint3d(1e-4), PileBottomPoint = endp.DPoint3dToPoint3d(1e-4) }); break; case SoildPileCrossSectionType.Polygon: pileproplist.Add(new PolygonPileGeometry() { CrossSectionArea = this.PolygonCrossSectionArea, PileCrossSectionPerimeter = this.PolygonCrossSectionPerimeter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = startp.DPoint3dToPoint3d(1e-4), PileBottomPoint = endp.DPoint3dToPoint3d(1e-4) }); break; } var pilecodereaddatablock = pile.GetLinkage((ushort)BD.ElementLinkageId.String); string pilename = string.Empty; if (null != pilecodereaddatablock) { //throw new NotSupportedException($"Pile Id:{pile.ElementId} doesn't contain pilecode linkage"); pilename = pilecodereaddatablock.ReadString(); } else { pilename = pile.Description + " ID:" + pile.ElementId.ToString(); } pilenamelist.Add(PileName + pilename); pileIdlist.Add(pile.ElementId); } break; case PileType.SteelAndPercastConcrete: pilefactory = new SteelAndPercastConcretePileFactory(GammaR, Eta); foreach (var pile in elelist) { //BG.DRange3d range; //((BDE.LineElement)pile).CalcElementRange(out range); BG.DPoint3d startp, endp; if (!((BDE.LineElement)pile).GetCurveVector().GetStartEnd(out startp, out endp)) { System.Windows.Forms.MessageBox.Show($"无法获取Pile ID:{pile.ElementId}的起始点和终点"); return; } pileproplist.Add(new AnnularPileGeometry() { PileDiameter = this.PileDiameter, PileInnerDiameter = this.PileInnerDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = startp.DPoint3dToPoint3d(1e-4), PileBottomPoint = endp.DPoint3dToPoint3d(1e-4) }); var pilecodereaddatablock = pile.GetLinkage((ushort)BD.ElementLinkageId.String); string pilename = string.Empty; if (null != pilecodereaddatablock) { //throw new NotSupportedException($"Pile Id:{pile.ElementId} doesn't contain pilecode linkage"); pilename = pilecodereaddatablock.ReadString(); } pilenamelist.Add(PileName + pilename); pileIdlist.Add(pile.ElementId); } break; //case PileType.Filling: // pilefactory = new FillingPileFactory(); // break; //case PileType.Socketed: // pilefactory = new SocketedPileFactory(); // break; //case PileType.PostgroutingFilling: // pilefactory = new PostgroutingFillingPileFactory(); // break; } //foreach (var pile in elelist) //{ // BG.DRange3d range; // ((BDE.LineElement)pile).CalcElementRange(out range); // switch (SelectedPileCrossSectionType) // { // case PileCrossSectionType.Roundness: // pileproplist.Add(new RoundnessPileGeometry() { PileDiameter = this.PileDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = range.High.DPoint3dToPoint3d(1e-4), PileBottomPoint = range.Low.DPoint3dToPoint3d(1e-4) }); // break; // case PileCrossSectionType.Square: // pileproplist.Add(new SquarePileGeometry() { PileDiameter = this.PileDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = range.High.DPoint3dToPoint3d(1e-4), PileBottomPoint = range.Low.DPoint3dToPoint3d(1e-4) }); // break; // case PileCrossSectionType.Annular: // pileproplist.Add(new AnnularPileGeometry() { PileDiameter = this.PileDiameter, PileInnerDiameter = this.PileInnerDiameter, PileWeight = this.PileWeight, PileUnderWaterWeight = this.PileUnderwaterWeight, WaterLevel = WaterLevel, PileTopPoint = range.High.DPoint3dToPoint3d(1e-4), PileBottomPoint = range.Low.DPoint3dToPoint3d(1e-4) }); // break; // } // pilenamelist.Add(PileName + pile.GetLinkage((ushort)BD.ElementLinkageId.String).ReadString()); // pileIdlist.Add(pile.ElementId); //} var templist = pilefactory?.CreateNewPileArray(pileproplist.ToArray(), pilenamelist.ToArray(), pileIdlist.ToArray()); Piles.AddRange(templist); CloseAction(); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
void GetGetPileCalculateInfo(out Dictionary <double, double> pileLengthAndBearingForce) { pileLengthAndBearingForce = new Dictionary <double, double>(); Point3d originalBottomPoint = new HCHXCodeQueryLib.Point3d() { X = m_pile.PilePropertyInfo.PileBottomPoint.X, Y = m_pile.PilePropertyInfo.PileBottomPoint.Y, Z = m_pile.PilePropertyInfo.PileBottomPoint.Z, }; IPileProperty tempprop = m_pile.PilePropertyInfo;//set pile to the whole length pile tempprop.PileBottomPoint = GetVirtualPileAxisBottomPoint(2 * GetActiveModelBoundaryZ() * 1e-4).DPoint3dToPoint3d(); List <double> eachlayerz = new List <double>(); #region SolidPile if (m_pile is SolidPile) { var solidpile = m_pile as SolidPile; SolidPileFactory solidfactory = new SolidPileFactory(solidpile.GammaR); var tempsolidpile = solidfactory.CreateNewPile(tempprop, solidpile.PileCode, solidpile.PileId) as SolidPile; //double[] qfiliacummlate = new double[tempsolidpile.SolidPileSoilLayerInfoProp.Count]; //double[] qri = new double[tempsolidpile.SolidPileSoilLayerInfoProp.Count]; //double gammar = solidpile.GammaR; //double perimeter = solidpile.PilePropertyInfo.GetPilePerimeter(); //double area = solidpile.PilePropertyInfo.GetPileOutLineArea(); //for (int i = 0; i < tempsolidpile.SolidPileSoilLayerInfoProp.Count; i++) //{ // if (i == 0) // qfiliacummlate[i] = tempsolidpile.SolidPileSoilLayerInfoProp[i].Qfi * tempsolidpile.SolidPileSoilLayerInfoProp[i].PileInSoilLayerLength; // else // qfiliacummlate[i] = qfiliacummlate[i - 1] + tempsolidpile.SolidPileSoilLayerInfoProp[i].Qfi * tempsolidpile.SolidPileSoilLayerInfoProp[i].PileInSoilLayerLength; // qri[i] = tempsolidpile.SolidPileSoilLayerInfoProp[i]. //} for (int i = 0; i < tempsolidpile.SolidPileSoilLayerInfoProp.Count; i++) { if (i == 0) { eachlayerz.Add(tempsolidpile.SolidPileSoilLayerInfoProp[i].PileInSoilLayerTopZ); } else { eachlayerz.Add(tempsolidpile.SolidPileSoilLayerInfoProp[i].PileInSoilLayerTopZ + 1e-4); eachlayerz.Add(tempsolidpile.SolidPileSoilLayerInfoProp[i].PileInSoilLayerTopZ - 1e-4); } } eachlayerz.Add(2 * GetActiveModelBoundaryZ() * 1e-4); //添加底点 for (int i = 0; i < eachlayerz.Count; i++) { tempprop.PileBottomPoint = GetVirtualPileAxisBottomPoint(eachlayerz[i]).DPoint3dToPoint3d(); if (i == 0) { pileLengthAndBearingForce.Add(tempprop.GetPileLength(), 0); } else { tempsolidpile = solidfactory.CreateNewPile(tempprop, solidpile.PileCode, solidpile.PileId) as SolidPile; double tempbearing = tempsolidpile.CalculateQd(); pileLengthAndBearingForce.Add(tempprop.GetPileLength(), tempbearing); if (tempbearing > m_wantedPileBearing) { break; } } } } #endregion #region steelpile if (m_pile is SteelAndPercastConcretePile) { var steelandpercastconcretepile = m_pile as SteelAndPercastConcretePile; SteelAndPercastConcretePileFactory steelandpercastpilefactory = new SteelAndPercastConcretePileFactory(steelandpercastconcretepile.GammaR, steelandpercastconcretepile.Eta); var temppile = steelandpercastpilefactory.CreateNewPile(tempprop, steelandpercastconcretepile.PileCode, steelandpercastconcretepile.PileId) as SteelAndPercastConcretePile; //foreach (var layer in temppile.SteelAndPercastConcretPileLayerInfoProp) //{ // eachlayerz.Add(layer.PileInSoilLayerTopZ); //} for (int i = 0; i < temppile.SteelAndPercastConcretPileLayerInfoProp.Count; i++) { if (i == 0) { eachlayerz.Add(temppile.SteelAndPercastConcretPileLayerInfoProp[i].PileInSoilLayerTopZ); } else { eachlayerz.Add(temppile.SteelAndPercastConcretPileLayerInfoProp[i].PileInSoilLayerTopZ + 1e-4); eachlayerz.Add(temppile.SteelAndPercastConcretPileLayerInfoProp[i].PileInSoilLayerTopZ - 1e-4); } } eachlayerz.Add(2 * GetActiveModelBoundaryZ() * 1e-4); //添加底点 for (int i = 0; i < eachlayerz.Count; i++) { tempprop.PileBottomPoint = GetVirtualPileAxisBottomPoint(eachlayerz[i]).DPoint3dToPoint3d(); if (i == 0) { pileLengthAndBearingForce.Add(tempprop.GetPileLength(), 0); } else { temppile = steelandpercastpilefactory.CreateNewPile(tempprop, steelandpercastconcretepile.PileCode, steelandpercastconcretepile.PileId) as SteelAndPercastConcretePile; double tempbearing = temppile.CalculateQd(); pileLengthAndBearingForce.Add(tempprop.GetPileLength(), tempbearing); if (tempbearing > m_wantedPileBearing) { break; } } } } #endregion tempprop.PileBottomPoint = originalBottomPoint;//setback }