public static void GetTransformerCellText(BCOM.CellElement ECell, string TrfrName, string Rating) { BCOM.ElementEnumerator oEE1; // = default(ElementEnumerator); BCOM.Element AElement1; //= default(Element); string Txt = null; string myString = null; oEE1 = ECell.GetSubElements(); while ((oEE1.MoveNext())) { AElement1 = oEE1.Current; if ((AElement1.IsCellElement())) { GetTransformerCellText(AElement1.AsCellElement(), TrfrName, Rating); } else if (AElement1.IsTextElement()) { Txt = AElement1.AsTextElement().Text; // if (Strings.InStr(Strings.UCase(Txt), "KVA") > 0) if (Txt.Contains("KVA")) { Rating = AElement1.AsTextElement().Text; //myString = Strings.Left(Rating, Strings.Len(Rating) - 3); myString = Rating.TrimEnd("KVA".ToCharArray()); Rating = myString; } else { TrfrName = AElement1.AsTextElement().Text; } } } }
private BCOM.CellElement GroupGeoTagCell(string strCellName) { BCOM.CellElement oCel = null; try { AddInMain.ComApp.CadInputQueue.SendCommand("GROUP SELECTION"); //WS: can I use this .NET version of keyin instead of COM based as above? //Bentley.Internal.MicroStation.Session.Instance.Keyin("GROUP SELECTION"); BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements(); while (oEnum.MoveNext()) { if (oEnum.Current.IsCellElement()) { oCel = oEnum.Current.AsCellElement(); break; } } oCel.Name = strCellName; oCel.Redraw(); oCel.Rewrite(); } catch { } return(oCel); }
public static IEnumerable <T> getSubElementsRecurse <T>( this BCOM.CellElement cell) where T : BCOM.Element { var res = new List <T>(); getSubElements_(cell, res); return(res); }
//WS: keyin Command public static void ListTags(string unparsed) { GeoTagList oListForm = new GeoTagList(); BCOM.ElementScanCriteria oScanCriteria = new BCOM.ElementScanCriteriaClass(); oScanCriteria.ExcludeAllTypes(); oScanCriteria.IncludeType(BCOM.MsdElementType.CellHeader); BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.Scan(oScanCriteria); while (oEnum.MoveNext()) { BCOM.CellElement oCel = null; if (oEnum.Current.IsCellElement()) { if (oEnum.Current.AsCellElement().Name == "Embankment" || oEnum.Current.AsCellElement().Name == "RetainWall" || oEnum.Current.AsCellElement().Name == "Pond" || oEnum.Current.AsCellElement().Name == "Road" || oEnum.Current.AsCellElement().Name == "OpenChannel" || oEnum.Current.AsCellElement().Name == "Dike") { oCel = oEnum.Current.AsCellElement(); ECInstanceList oECInstancelist = GeoTagList.oECAdaptor.ReadInstancesFromElement(oCel, false); foreach (ECInstance oEC in oECInstancelist) { if (oEC.ClassDefinition.Name == "Embankment" || oEC.ClassDefinition.Name == "RetainWall" || oEC.ClassDefinition.Name == "Pond" || oEC.ClassDefinition.Name == "Road" || oEC.ClassDefinition.Name == "OpenChannel" || oEC.ClassDefinition.Name == "Dike") { //WS: loop through each class instance, get properties enumerator. IEnumerator <IECProperty> pFields = oEC.ClassDefinition.GetEnumerator(true); //WS: get properties values enumberator.. IEnumerator <IECPropertyValue> pVals = oEC.GetEnumerator(true); while (pFields.MoveNext()) { pVals.MoveNext(); if (pFields.Current.Name == "Tag_Number") { oListForm.WriteLine("Tag: " + pVals.Current.XmlStringValue + "; ElementId: " + oCel.ID.ToString()); } } } } } } } oListForm.ShowDialog(); }
//WS: note: the drop command is uing MS built UI command, so always make sure element got selected first. private void btnDrop_Click(object sender, EventArgs e) { BCOM.CellElement oCel = null; BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements(); BCOM.Element[] oEleSet = oEnum.BuildArrayFromContents(); if (oEleSet.Length != 1) { AddInMain.ComApp.CadInputQueue.SendCommand("CHOOSE NONE"); AddInMain.ComApp.CommandState.StartLocate(new DropTagCell()); } if (oEleSet.Length == 1) { if (oEleSet[0].IsCellElement()) { if (oEleSet[0].AsCellElement().Name == "Embankment" || oEleSet[0].AsCellElement().Name == "Dike" || oEleSet[0].AsCellElement().Name == "Pond" || oEleSet[0].AsCellElement().Name == "Road" || oEleSet[0].AsCellElement().Name == "OpenChannel" || oEleSet[0].AsCellElement().Name == "RetainWall") { oCel = oEleSet[0].AsCellElement(); oECAdaptor.DeleteInstancesOnElement(oCel, oCel.Name); //WS: delete the ECInstance first. //oECAdaptor.DeleteInstancesOnElement(oCel, "Tag"); BCOM.Point3d oPt = oCel.Origin; //WS: window pops up here AddInMain.ComApp.CadInputQueue.SendCommand("DROP ELEMENT"); AddInMain.ComApp.SetCExpressionValue("dropOptions.complex", -1, "DROP"); int iActiveViewNum = Commons.GetActiveViewIndex(); AddInMain.ComApp.CadInputQueue.SendDataPoint(ref oPt, iActiveViewNum); MessageBox.Show("Please re-select elements for old tag, and start Step 3."); btnSelect.Enabled = false; btnDrop.Enabled = false; btnEdit.Enabled = true; } else { AddInMain.ComApp.CadInputQueue.SendCommand("CHOOSE NONE"); AddInMain.ComApp.CommandState.StartLocate(new DropTagCell()); } } } }
private BCOM.CellElement getTaskCell() { BCOM.ModelReference taskModel = // TODO App.MdlGetModelReferenceFromModelRefP(modelRefP); BCOM.ModelReference activeModel = App.ActiveModelReference; bool isAttachment = taskModel.IsAttachment; BCOM.CellElement cell = taskModel.IsAttachment ? taskModel.AsAttachment.GetElementByID(elemId).AsCellElement() : taskModel.GetElementByID(elemId).AsCellElement(); return(cell); }
private static void getSubElements_ <T>( BCOM.CellElement cell, List <T> coll) where T : BCOM.Element { BCOM.ElementEnumerator iter = cell.GetSubElements(); while (iter.MoveNext()) { if (iter.Current is T) { coll.Add((T)iter.Current); } else if (iter.Current.IsCellElement()) { getSubElements_ <T>(iter.Current.AsCellElement(), coll); } } }
private BCOM.SmartSolidElement getBodyWithOutFlanges(BCOM.CellElement penCell) { BCOM.SmartSolidElement body = null; double maxVolume = 0.0; foreach (var solid in penCell.getSubElementsRecurse <BCOM.SmartSolidElement>()) { double volume = solid.ComputeVolume(); if (volume > maxVolume) { body = solid; maxVolume = volume; } } return(body); }
private void scanInfoPerModel(BCOM.ModelReference model) { BCOM.CellElement cell = getTaskCell(); if (cell == null) { return; } //BCOM.ModelReference activeModel = App.ActiveModelReference; BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass(); criteria.ExcludeAllTypes(); criteria.ExcludeNonGraphical(); criteria.IncludeType(BCOM.MsdElementType.CellHeader); BCOM.Range3d scanRange = cell.Range; #if CONNECT // корректировака для версии CONNECT if (cell.ModelReference.IsAttachmentOf(model)) // TODO ПРОВЕРИТЬ { // здесь есть различия с V8i: double k = model.UORsPerStorageUnit / cell.ModelReference.UORsPerStorageUnit; scanRange.High = App.Point3dScale(scanRange.High, k); scanRange.Low = App.Point3dScale(scanRange.Low, k); } #endif criteria.IncludeOnlyWithinRange(scanRange); BCOM.ElementEnumerator res = model.Scan(criteria); foreach (BCOM.Element current in res?.BuildArrayFromContents()) { TFCOM.TFElementList tfList = AppTF.CreateTFElement(); tfList.InitFromElement(current); if (tfList.AsTFElement == null) { continue; } int tfType = tfList.AsTFElement.GetApplicationType(); if (tfList.AsTFElement.GetIsCompoundCellType()) { CompoundsIntersected.Add(tfList); } else if (tfList.AsTFElement.GetIsFormType()) { bool coorrectType = isAvaliableTFFromType(tfType); if (isAvaliableTFFromType(tfType)) { TFFormsIntersected.Add(tfList); } } } projectLocationPointOnTFForm(TFFormsIntersected); }
private void findFlanges() { BCOM.CellElement cell = getTaskCell(); if (cell == null) { return; } BCOM.ModelReference taskModel = // TODO App.MdlGetModelReferenceFromModelRefP(modelRefP); BCOM.ModelReference activeModel = App.ActiveModelReference; FlangesGeom.Clear(); // Поиск фланцев BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass(); //criteria.IncludeOnlyVisible(); criteria.ExcludeAllTypes(); criteria.ExcludeNonGraphical(); criteria.IncludeType(BCOM.MsdElementType.CellHeader); BCOM.Range3d scanRange = cell.Range; // App.Range3dScaleAboutCenter(cell.Range, 1.01); if (taskModel.IsAttachment) { double k = taskModel.UORsPerStorageUnit / activeModel.UORsPerStorageUnit; scanRange.High = App.Point3dScale(scanRange.High, k); scanRange.Low = App.Point3dScale(scanRange.Low, k); } criteria.IncludeOnlyWithinRange(scanRange); BCOM.ElementEnumerator res = taskModel.Scan(criteria); foreach (BCOM.Element current in res?.BuildArrayFromContents()) { // todo использовать только один тип точек PenetrTaskFlange flangeTask = null; //Element curEl = Element.FromElementID((ulong)current.ID, // (IntPtr)current.ModelReference.MdlModelRefP()); if (PenetrTaskFlange.getFromElement(current, out flangeTask)) { BCOM.Range3d range = current.Range; if (flangeTask.Oid.Equals(Oid)) { FlangesGeom.Add(flangeTask); } } } //BCOM.Transform3d tran = App.Transform3dInverse( // App.Transform3dFromMatrix3d(Rotation)); //cell.Transform(tran); // TODO проверить корректность transform отн. rawLocation_ transformToBase(cell, rawLocation_); if (FlangesCount != FlangesGeom.Count) { Warnings.Add(string.Format("Несоответствие количества фланцев, " + "указанных в атрибутах - {0} и заданных геометрически - {1}", FlangesCount, FlangesGeom.Count)); } if (FlangesCount == 1 && FlangesGeom.Count > 0) { BCOM.Element flangeEl = taskModel.GetElementByID(FlangesGeom[0].elemId); //flangeEl.Transform(tran); // TODO проверить корректность transform отн. rawLocation_ transformToBase(flangeEl, rawLocation_); SingleFlangeSide = App.Vector3dSubtractPoint3dPoint3d( ElementHelper.getCenter(flangeEl), ElementHelper.getCenter(cell)); } else { SingleFlangeSide = App.Vector3dFromXYZ(0, 0, -1); } }
/// <summary> /// Поиск фланцев на объекте задания старого типа /// </summary> private void findFlangesOld() { BCOM.ModelReference model = App.MdlGetModelReferenceFromModelRefP(modelRefP); SingleFlangeSide = App.Vector3dZero(); // Todo из правильной модели BCOM.CellElement cell = model.GetElementByID(elemId).AsCellElement(); if (cell == null) { return; } //var tran = App.Transform3dFromMatrix3d(Rotation); //if (App.Matrix3dHasInverse(Rotation)) //{ // tran = App.Transform3dInverse(tran); //} //var tran = App.Transform3dInverse( // App.Transform3dFromMatrix3d(Rotation)); //cell.Transform(tran); // TODO проверить корректность transform отн. rawLocation_ transformToBase(cell, rawLocation_); var cones = new List <BCOM.ConeElement>(); collectSubElementsByType(cell, ref cones); //var iter = bcomEl.AsCellElement().GetSubElements(); //while (iter.MoveNext()) //{ // var iterSub = iter.Current.AsCellElement().GetSubElements(); // while (iterSub.MoveNext()) // { // if (iterSub.Current.IsConeElement()) // cones.Add(iterSub.Current.AsConeElement()); // } //} cones.Sort((BCOM.ConeElement lhs, BCOM.ConeElement rhs) => { return(-1 * ElementHelper.getHeight(lhs).CompareTo( ElementHelper.getHeight(rhs))); }); /* cones.Count == * 2: без фланцев * 4: 1 фланец, определяем вектор с какой стороны фланец * 6: 2 фланца */ int geomFlangesCount = cones.Count / 2 - 1; if (geomFlangesCount == 1) { // 1 фланец, определяем вектор с какой стороны фланец относительно центра SingleFlangeSide = App.Vector3dSubtractPoint3dPoint3d( ElementHelper.getCenter(cones[2]), ElementHelper.getCenter(cones[0])); } else { // базовая ориентация при построении // фланец совпадает с Точкой установки SingleFlangeSide = App.Vector3dFromXYZ(0, 0, -1); } if (FlangesCount != geomFlangesCount) { Warnings.Add(string.Format("Несоответствие количества фланцев, " + "указанных в атрибутах - {0} и заданных геометрически - {1}", FlangesCount, geomFlangesCount)); } }
private bool ApplyTagFromUI2Selection(string strFunctionCode) { bool retVal = false; try { GeoTagDataBase oGeoTagDataBase = null; string strClassName = Commons.MapFunctionCode2ClassName(strFunctionCode); if (strFunctionCode == "PND") { oGeoTagDataBase = new Pond(); } else if (strFunctionCode == "ROAD") { oGeoTagDataBase = new Road(); } else if (strFunctionCode == "CHN") { oGeoTagDataBase = new OpenChannel(); } else if (strFunctionCode == "EMB") { oGeoTagDataBase = new Embankment(); } else if (strFunctionCode == "DIKE") { oGeoTagDataBase = new Dike(); } else if (strFunctionCode == "RW") { oGeoTagDataBase = new RetainWall(); } oGeoTagDataBase.Tag_Number = this.lblTagValue.Text; oGeoTagDataBase.Tag_Status = this.cmbTagStatus.Text; oGeoTagDataBase.Location = this.txtLocation.Text; oGeoTagDataBase.Service_Description = this.txtSerDesc.Text; oGeoTagDataBase.Type = this.cmbType.Text; oGeoTagDataBase.Plot_Plan_Document_Number = this.txtPlotPlan.Text; oGeoTagDataBase.Detail_Drawing_Document_Number = this.txtDetailDwg.Text; oGeoTagDataBase.Construction_Month = this.dateTimePickerMon.Text; oGeoTagDataBase.Construction_Year = this.dateTimePickerYear.Text; oGeoTagDataBase.Originating_Contractor = this.txtOriContractor.Text; oGeoTagDataBase.Document_Number = this.txtDocNo.Text; oGeoTagDataBase.Material_Main = this.cmbMaterial.Text; oGeoTagDataBase.Procument_Package_Number = this.txtProcumentPkg.Text; oGeoTagDataBase.Contract_Package_Number = this.txtContractPkgNo.Text; oGeoTagDataBase.Construction_Contractor_Name = this.txtConstrContractor.Text; oGeoTagDataBase.Construction_Specification_Document_Number = this.txtConstrSpec.Text; if (oGeoTagDataBase is Pond) { (oGeoTagDataBase as Pond).Supplier_Name = this.txt17.Text; (oGeoTagDataBase as Pond).Design_Capacity = this.txt19.Text; (oGeoTagDataBase as Pond).Fluid_Description = this.txt16.Text; (oGeoTagDataBase as Pond).Max_Fluid_Level = this.txt20.Text; (oGeoTagDataBase as Pond).Supplier_Reference_Drawing_Doc_Number = this.txt18.Text; } if (oGeoTagDataBase is Road) { (oGeoTagDataBase as Road).Number_of_Lanes = this.txt16.Text; } if (oGeoTagDataBase is OpenChannel) { (oGeoTagDataBase as OpenChannel).Fluid_Description = this.txt16.Text; } BCOM.CellElement oCel = null; BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements(); BCOM.Element[] oEleSet = oEnum.BuildArrayFromContents(); if (oEleSet.Length < 1) { return(false); } //WS: if a tagged celll is selected. if (oEleSet.Length == 1) { if (oEleSet[0].IsCellElement()) { if (oEleSet[0].AsCellElement().Name == "Embankment" || oEleSet[0].AsCellElement().Name == "RetainWall" || oEleSet[0].AsCellElement().Name == "Pond" || oEleSet[0].AsCellElement().Name == "Road" || oEleSet[0].AsCellElement().Name == "OpenChannel" || oEleSet[0].AsCellElement().Name == "Dike") { oCel = oEleSet[0].AsCellElement(); } } } else //WS: when more than 1 elements selected. { oCel = GroupGeoTagCell(strClassName); } if (oCel == null) { return(false); } AttachInstanceAndValues(oCel, strClassName, oGeoTagDataBase); retVal = true; } catch (Exception) { throw new Exception("Unexpected error: GeoTag.ApplyTagFromUI2Selection"); } return(retVal); }
public MstnNodeData(BCOM.CellElement _cell) { this.ID = _cell.ID; nodeElement = _cell; }
public static bool getFromElement(Element element, XDocument attrsXDoc, out OpeningTask task) { task = null; BCOM.Element bcomEl = element.ToElementCOM(); var tfEl = AppTF.CreateTFElement(); tfEl.InitFromElement(bcomEl); var tfElType = (TFCOM.TFdElementType)tfEl.AsTFElement.GetApplicationType(); //if (tfElType != TFCOM.TFdElementType.tfdElementTypeEBrep) //{ // return false; //} BCOM.CellElement cell = element.ToCellElementCOM(); var brep = AppTF.CreateTFBrep(); brep.InitFromElement(bcomEl, App.ActiveModelReference); BCOM.Point3d[] verts; brep.GetVertexLocations(out verts); if (verts == null || verts.Count() < 8) { return(false); } if (verts.Count() > 8) { // встречались случаи с количеством вершин 24 шт. verts = new HashSet <BCOM.Point3d>(verts).Take(8).ToArray(); } var formsIntersected = new List <TFCOM.TFElementList>(); { // Пересечения со стеной/плитой/аркой; foreach (BCOM.Element current in bcomEl.scanIntersectsInElementRange()) { TFCOM.TFElementList tfList = AppTF.CreateTFElement(); tfList.InitFromElement(current); if (tfList.AsTFElement == null) { continue; } int tfType = tfList.AsTFElement.GetApplicationType(); if (isAvaliableTFFromType(tfType)) { //if (tfList.AsTFElement.GetIsFormType()) //{ formsIntersected.Add(tfList); //} } } } var planeFirst = new BCOM.Plane3d(); var planeSecond = new BCOM.Plane3d(); TFFormTypeEnum formType = TFFormTypeEnum.UNDEFINED; bool planesAreFound = false; if (formsIntersected.Count > 0) { // todo определение граней параллельных поверхности стены/плиты/арки; var tfElement = formsIntersected.First().AsTFElement; BCOM.Element formElement; tfElement.GetElement(out formElement); formType = ElementHelper.ParseFormType(tfElement.GetApplicationType()); switch (formType) { case TFFormTypeEnum.TF_LINEAR_FORM_ELM: planesAreFound = ElementHelper.getFacePlaneByLabel(out planeFirst, formElement, TFCOM.TFdFaceLabel.tfdFaceLabelLeft); planesAreFound &= ElementHelper.getFacePlaneByLabel(out planeSecond, formElement, TFCOM.TFdFaceLabel.tfdFaceLabelRight); break; case TFFormTypeEnum.TF_SLAB_FORM_ELM: planesAreFound = ElementHelper.getFacePlaneByLabel(out planeFirst, formElement, TFCOM.TFdFaceLabel.tfdFaceLabelTop); planesAreFound &= ElementHelper.getFacePlaneByLabel(out planeSecond, formElement, TFCOM.TFdFaceLabel.tfdFaceLabelBase); break; case TFFormTypeEnum.TF_ARC_FORM_ELM: // TODO РАДИАЛЬНЫЕ СТЕНЫ break; case TFFormTypeEnum.TF_EBREP_ELM: case TFFormTypeEnum.TF_SMOOTH_FORM_ELM: TFCOM.TFBrepList brepList = AppTF.CreateTFBrep(); brepList.InitFromElement(formElement, App.ActiveModelReference); planesAreFound = ElementHelper.getFacePlaneByLabel(out planeFirst, brepList, TFCOM.TFdFaceLabel.tfdFaceLabelTop); var intersectedPlanes = new List <TFCOM.TFPlane>(); TFCOM.TFPlane tfPlane; IEnumerable <TFCOM.TFBrepFace> faceLists = brepList.GetFacesEx(); foreach (var faceList in faceLists) { if (faceList.IsPlanarAndIntersectsElement(bcomEl, out tfPlane)) { intersectedPlanes.Add(tfPlane); } } if (intersectedPlanes.Count > 2) { // TODO ?? /* * 1. собрать коллекцию с суммой площадей параллельных поверхностей * 2. у большей коллекции по суммарной площади вычислить нормаль * 3. выбирать плоскости проекции задания в соответсвии с выбранной нормалью */ var facesInfo = new List <FaceInfo>(); foreach (var faceList in faceLists) { TFCOM.TFPlane faceTFPlane; if (faceList.IsPlanar(out faceTFPlane)) { double area; faceList.GetArea(out area, string.Empty); BCOM.Plane3d plane3D = faceTFPlane.ToPlane3d(); FaceInfo faceInfo = facesInfo.FirstOrDefault(x => x.Normal.IsVectorParallelTo(plane3D.Normal)); if (faceInfo.Area == 0) { facesInfo.Add(new FaceInfo() { Area = area, Normal = plane3D.Normal }); } else { faceInfo.Area += area; } } } facesInfo.Sort((x, y) => - 1 * x.Area.CompareTo(y.Area)); FaceInfo faceTarget = facesInfo[0]; intersectedPlanes.RemoveAll((x) => { BCOM.Point3d norm; x.GetNormal(out norm); return(!norm.IsVectorParallelTo(faceTarget.Normal)); }); ; } if (intersectedPlanes.Count == 2) { // ! должно выполняться условие параллельности planeFirst = intersectedPlanes[0].ToPlane3d(); planeSecond = intersectedPlanes[1].ToPlane3d(); planesAreFound = planeFirst.IsParallelTo(planeSecond); } { /* TODO * Если только одна поверхность: * 1. через точку контура провести нормаль * 2. найти поверхности, кот. пересекает нормаль */ } break; } } if (!planesAreFound) { return(false); } { // корректировка плоскостей относительно пользователя BCOM.Point3d projOrigin = planeFirst.Origin.ProjectToPlane3d(planeSecond); switch (formType) { case TFFormTypeEnum.TF_LINEAR_FORM_ELM: if ((int)projOrigin.Y < (int)planeFirst.Origin.Y || (int)projOrigin.X > (int)planeFirst.Origin.X) { BCOM.Plane3d buff = planeFirst; planeFirst = planeSecond; planeSecond = buff; } break; case TFFormTypeEnum.TF_SLAB_FORM_ELM: case TFFormTypeEnum.TF_FREE_FORM_ELM: if ((int)projOrigin.Z > (int)planeFirst.Origin.Z) { BCOM.Plane3d buff = planeFirst; planeFirst = planeSecond; planeSecond = buff; } break; } } { // Определение параметров контура: var sorted = new List <VertexInfo>(); foreach (BCOM.Point3d pt in verts) { var projPt = pt.ProjectToPlane3d(planeFirst); sorted.Add(new VertexInfo() { Distance = App.Point3dDistance(pt, projPt), Point = projPt }); } sorted.Sort(); var firstFaceBounds = sorted.Take(4).Select(x => x.Point); var checkSet = new HashSet <BCOM.Point3d>(firstFaceBounds); if (checkSet.Count < 4) { return(false); } sorted.Clear(); foreach (BCOM.Point3d pt in verts) { var projPt = pt.ProjectToPlane3d(planeSecond); sorted.Add(new VertexInfo() { Distance = App.Point3dDistance(pt, projPt), Point = projPt }); } sorted.Sort(); var secondFaceBounds = sorted.Take(4).Select(x => x.Point); checkSet = new HashSet <BCOM.Point3d>(secondFaceBounds); if (checkSet.Count < 4) { return(false); } var pts = firstFaceBounds.ToArray(); var dimensions = new List <DimensionInfo>() { new DimensionInfo(pts[0], pts[1]), new DimensionInfo(pts[0], pts[2]), new DimensionInfo(pts[0], pts[3]), }; dimensions.Sort(); if (planeFirst.IsParallelTo(App.GetPlane3dXY())) { // TOTO ширина и высота относительно ориентации } // опорная точка Origin: //contourOrigin BCOM.ShapeElement contour = App.CreateShapeElement1(null, pts); BCOM.Point3d projOriginFirst = contour.Centroid().ProjectToPlane3d(planeFirst); task = new OpeningTask(); { // инициализация объекта задания XDocument xDoc = ElementHelper.getSp3dXDocument(element); xDoc.Merge(attrsXDoc); Sp3dToDGMapping.Instance.LoadValuesFromXDoc(xDoc, task.DataGroupPropsValues); // TODO //task.Code = xDoc.Root. // getChildByRegexPath("P3DEquipment/Name", out propName)?.Value; //string propName; task.Origin = projOriginFirst; { // Высота task.Height = dimensions[0].Length; task.HeigthVec = App.Point3dNormalize(dimensions[0].Vector); } { // Ширина task.Width = dimensions[1].Length; task.WidthVec = App.Point3dNormalize(dimensions[1].Vector); } { // Глубина BCOM.Point3d projOriginSecond = projOriginFirst.ProjectToPlane3d(planeSecond); task.Depth = Math.Round( App.Point3dDistance(projOriginFirst, projOriginSecond), 5); task.DepthVec = App.Point3dNormalize( App.Point3dSubtract(projOriginSecond, projOriginFirst)); } } } return(true); }