//#define FILEPOS_EOF 0 //#define FILEPOS_CURRENT 1 //#define FILEPOS_FIRST_ELE 2 //#define FILEPOS_NEXT_ELE 3 //#define FILEPOS_WORKING_SET 4 //#define FILEPOS_COMPONENT 5 //#define FILEPOS_NEXT_NEW_ELEMENT 6 private void btnAddToModel_Click(object sender, EventArgs e) { previewTranContainer.Reset(); BCOM.Level activeLevel = Addin.App.ActiveSettings.Level; BCOM.LineStyle activeLineStyle = Addin.App.ActiveSettings.LineStyle; int activeLineWeight = Addin.App.ActiveSettings.LineWeight; int activeColor = Addin.App.ActiveSettings.Color; var activeModel = Addin.App.ActiveModelReference; try { foreach (var pair in getFramesData()) { TFCOM.TFFrameList frameList = pair.Key; PenetrTask task = pair.Value; { // ! без этого кода не срабатывает перфорация в стенке/плите // судя по всему инициализирует обновление объектов, с которыми // взаимодействует frame Addin.AppTF.ModelReferenceUpdateAutoOpeningsByFrame( activeModel, frameList.AsTFFrame, true, false, TFCOM.TFdFramePerforationPolicy.tfdFramePerforationPolicyNone); } // добавление в модель Addin.AppTF.ModelReferenceAddFrameList( Addin.App.ActiveModelReference, frameList); BCOM.Element newElement = activeModel.GetLastValidGraphicalElement(); setDataGroupInstance(newElement, task); { // TODO ОТЛАДКА: //XmlInstanceSchemaManager modelSchema = // new XmlInstanceSchemaManager((IntPtr)newElement.ModelReference.MdlModelRefP()); // XmlInstanceApi api = XmlInstanceApi.CreateApi(modelSchema); // IList<string> instances = api.ReadInstances((IntPtr)newElement.MdlElementRef()); // foreach (string inst in instances) // { // string instId = XmlInstanceApi.GetInstanceIdFromXmlInstance(inst); // } } } } catch (Exception ex) { ex.ShowMessage(); } finally { Addin.App.ActiveSettings.Level = activeLevel; Addin.App.ActiveSettings.LineStyle = activeLineStyle; Addin.App.ActiveSettings.LineWeight = activeLineWeight; Addin.App.ActiveSettings.Color = activeColor; } }
private void DgvFields_CellMouseDoubleClick( object sender, DataGridViewCellMouseEventArgs e) { PenetrTask task = (PenetrTask)dgvFields.Rows[e.RowIndex].DataBoundItem; ViewHelper.zoomToElement( ElementHelper.getElementCOM(task.elemRefP, task.modelRefP)); }
private void DgvFields_SelectionChanged(object sender, EventArgs e) { // выделить(подсветить) объект задания в модели для пользователя selectionTranContainer?.Reset(); foreach (DataGridViewRow row in dgvFields.SelectedRows) { PenetrTask task = (PenetrTask)dgvFields.Rows[row.Index].DataBoundItem; BCOM.ModelReference modelRef = Addin.App.MdlGetModelReferenceFromModelRefP((int)task.modelRefP); BCOM.View view = ViewHelper.getActiveView(); List <long> itemsIds = new List <long> { task.elemId }; // добавляем фланцы: foreach (PenetrTaskFlange flangeTask in task.FlangesGeom) { itemsIds.Add(flangeTask.elemId); } foreach (long id in itemsIds) { BCOM.Element el = modelRef.GetElementByID(id); el.Color = 2; // зелёный el.LineWeight = 5; // для ОТЛАДКИ ************************************************* //BCOM.Transform3d taskTran; //{ // BCOM.Point3d origin = (el as BCOM.CellElement).Origin; // var shift = Addin.App.Vector3dSubtractPoint3dPoint3d( // Addin.App.Point3dZero(), task.Location); // el.Move(Addin.App.Point3dFromXYZ(shift.X, shift.Y, shift.Z)); // taskTran = Addin.App.Transform3dInverse( // Addin.App.Transform3dFromMatrix3d(task.Rotation)); // el.Transform(taskTran); // el.Move(task.Location); //} //************************************************************** selectionTranContainer.AppendCopyOfElement(el); } view.Redraw(); } }
private void DgvFields_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) { updateRowsCountInfo(); for (int i = e.RowIndex; i < e.RowIndex + e.RowCount; ++i) { DataGridViewRow gridRow = dgvFields.Rows[i]; PenetrTask task = (PenetrTask)gridRow.DataBoundItem; List <DiameterType> diameters = penData.getDiameters(task.FlangesType); //var dataRows = penData.AsEnumerable(). // Where(x => projId != 0 ? x.Field<long>("prjId") == projId : // x.Field<long>("depID") == depId). // Where(x => x.Field<long>("flanNumber") == task.FlangesType). // OrderBy(x => x.Field<long>("diamNumber")). // ThenByDescending(x => x.Field<float>("pipeDiam")). // ThenByDescending(x => x.Field<float>("pipeThick")); var comboCell = gridRow.Cells["Диаметр"] as DataGridViewComboBoxCell; var diametersStringList = new List <string>(); DiameterType matchValue = null; foreach (DiameterType diamType in diameters) { if (diamType.number == DiameterType.Parse(task.DiameterTypeStr).number) { matchValue = diamType; } diametersStringList.Add(diamType.ToString()); } // TODO comboCell.DataSource = diametersStringList; if (matchValue != null) { comboCell.Value = matchValue.ToString(); } else { comboCell.ErrorText = "не валидное значение диаметра"; } if (!Keyins.Penetrations.DEBUG_MODE && task.TFFormsIntersected.Count == 0) { gridRow.ReadOnly = true; gridRow.DefaultCellStyle.BackColor = readonlyColor; } } }
private void Instance_SelectionChangedEvent( AddIn sender, AddIn.SelectionChangedEventArgs eventArgs) { try { switch (eventArgs.Action) { case AddIn.SelectionChangedEventArgs.ActionKind.SetEmpty: penTaskSelection.Clear(); bindSource.Clear(); previewTranContainer.Reset(); break; case AddIn.SelectionChangedEventArgs.ActionKind.Remove: { Element element = ElementHelper.getElement(eventArgs); if (penTaskSelection.ContainsKey(element.ElementRef)) { bindSource.Remove(penTaskSelection[element.ElementRef]); penTaskSelection.Remove(element.ElementRef); } break; } case AddIn.SelectionChangedEventArgs.ActionKind.New: { Element element = ElementHelper.getElement(eventArgs); PenetrTask task; if (PenetrTask.getFromElement(element, out task)) { if (penTaskSelection.ContainsKey(element.ElementRef)) { penTaskSelection.Remove(element.ElementRef); bindSource.Remove(task); } penTaskSelection.Add(element.ElementRef, task); bindSource.Add(task); } break; } } } catch (Exception ex) { // todo обработать MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
Dictionary <TFCOM.TFFrameList, PenetrTask> getFramesData() { var res = new Dictionary <TFCOM.TFFrameList, PenetrTask>(); foreach (DataGridViewRow row in dgvFields.Rows) { PenetrTask task = (PenetrTask)row.DataBoundItem; TFCOM.TFFrameList frameList = createFrameList(task); if (frameList != null) // TODO исключение? { res.Add(frameList, task); } } return(res); }
private void DgvFields_CellValueChanged(object sender, DataGridViewCellEventArgs e) { DataGridViewRow gridRow = dgvFields.Rows[e.RowIndex]; PenetrTask task = (PenetrTask)gridRow.DataBoundItem; var lengthCell = gridRow.Cells[ColumnName.LENGTH]; lengthCell.ReadOnly = false; // тип фланцев == 3 - расстояние насквозь (толщина фланцев не вычитается!) if (task.FlangesType == 3) { double thickness; if (task.getTFFormThickness(out thickness)) { lengthCell.ReadOnly = true; task.Length = (int)thickness / 10; } } }
TFCOM.TFFrameList createFrameList(PenetrTask task) { BCOM.Level level = ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_NAME); BCOM.Level levelSymb = ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_SYMB_NAME); BCOM.Level levelRefPoint = ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_POINT_NAME); long diamIndex = DiameterType.Parse(task.DiameterTypeStr).number; PenetrInfo penInfo = penData.getPenInfo(task.FlangesType, diamIndex); TFCOM.TFFrameList frameList = PenetrHelper.createFrameList(task, penInfo, level); PenetrHelper.addProjection(ref frameList, task, penInfo, levelSymb, levelRefPoint); // TODO видимость контура перфоратора можно в конфиг. переменную PenetrHelper.addPerforator(ref frameList, task, penInfo, levelSymb, false); return(frameList); }
//TFCOM.TFFrameList createFrameList_Old(PenetrTask task) //{ // task.scanInfo(); // if (!Keyins.Penetrations.DEBUG_MODE) { // if (task.isCompoundExistsInPlace || task.TFFormsIntersected.Count == 0) // return null; // } // BCOM.ModelReference taskModel = // Addin.App.MdlGetModelReferenceFromModelRefP((int)task.modelRefP); // taskModel.MdlModelRefP(); // double task_toUOR = taskModel.UORsPerMasterUnit; // double task_subPerMaster = taskModel.SubUnitsPerMasterUnit; // double task_unit3 = taskModel.UORsPerStorageUnit; // double task_unit4 = taskModel.UORsPerSubUnit; // BCOM.ModelReference activeModel = Addin.App.ActiveModelReference; // double toUOR = activeModel.UORsPerMasterUnit; // double subPerMaster = activeModel.SubUnitsPerMasterUnit; // double unit3 = activeModel.UORsPerStorageUnit; // double unit4 = activeModel.UORsPerSubUnit; // if (Keyins.Penetrations.DEBUG_MODE) { // ОТЛАДКА: // BCOM.LineElement line = // Addin.App.CreateLineElement2(null, task.Location, task.ProjectPoint); // line.Color = 3; // line.LineWeight = 5; // previewTranContainer.AppendCopyOfElement(line); // } // long diamIndex = DiameterType.Parse(task.DiameterTypeStr).number; // PenetrInfo penInfo = penData.getPenInfo(task.FlangesType, diamIndex); // double pipeInsideDiam = penInfo.pipeDiameterInside / subPerMaster; // double pipeOutsideDiam = penInfo.pipeDiameterOutside / subPerMaster; // double flangeInsideDiam = penInfo.flangeDiameterInside / subPerMaster; // double flangeOutsideDiam = penInfo.flangeDiameterOutside / subPerMaster; // double flangeThick = penInfo.flangeThick / subPerMaster; // double length = task.Length *10 / subPerMaster; // var solids = Addin.App.SmartSolid; // // ! длина трубы меньше размера проходки на толщину фланца // // ! ЕСЛИ ФЛАНЕЦ ЕСТЬ // double delta = task.FlangesCount == 0 ? 0 : // task.FlangesCount * flangeThick / 2; // BCOM.SmartSolidElement cylindrInside = // solids.CreateCylinder(null, pipeInsideDiam / 2, length - delta); // BCOM.SmartSolidElement cylindrOutside = // solids.CreateCylinder(null, pipeOutsideDiam / 2, length - delta); // var cylindr = solids.SolidSubtract(cylindrOutside, cylindrInside); // var elements = new Dictionary<BCOM.Element, double>(); // var projections = new Dictionary<BCOM.Element, double>(); // { // double shift = task.FlangesCount == 1 ? delta : 0; // shift *= task.isSingleFlangeFirst() ? 1 : -1; // elements.Add(cylindr, (length + shift)/2); // } // { // Перекрестия: всегда в плоскости стены // var zero = Addin.App.Point3dZero(); // projections.Add( // ElementHelper.createCrossRound(ref zero, pipeInsideDiam), // 0.0); // projections.Add(ElementHelper.createCircle(ref zero, pipeInsideDiam), // 0.0); // projections.Add( // ElementHelper.createCrossRound(ref zero, pipeInsideDiam), // length); // projections.Add(ElementHelper.createCircle(ref zero, pipeInsideDiam), // length); // } // { // Точка установки: // var pt = Addin.App.Point3dZero(); // BCOM.Element refPoint = // Addin.App.CreateLineElement2(null, pt, pt); // projections.Add(refPoint, 0.0); // } // // Фланцы: // for (int i = 0; i < task.FlangesCount; ++i) // { // BCOM.SmartSolidElement flangeCylindr = solids.SolidSubtract( // solids.CreateCylinder(null, flangeOutsideDiam / 2, flangeThick), // solids.CreateCylinder(null, pipeOutsideDiam / 2, flangeThick)); // double shift = 0; // if (task.FlangesCount == 1) // { // bool isNearest = Addin.App.Vector3dEqualTolerance(task.singleFlangeSide, // Addin.App.Vector3dFromXYZ(0, 0, -1), 0.1); // 0.001 // // 0.5 - для видимости фланцев на грани стены/плиты // shift = isNearest ? // 0.0 + flangeThick / 2 - 1: // 0.02: // length - flangeThick / 2 + 1; // 0.02; // } // else // { // shift = i == 0 ? 0.0 : length; // // для самих фланцев: // // 0.5 - для видимости фланцев на грани стены/плиты // shift += Math.Pow(-1, i) * (flangeThick/2 - 1); //0.02); // } // elements.Add(flangeCylindr, shift); // } // //********************************************************************** // //{ // ПОСТРОЕНИЕ ЧЕРЕЗ ПРОФИЛЬ И ПУТЬ // // ********************************************************************* // // BCOM.LineElement line = Addin.App.CreateLineElement2(null, // // Addin.App.Point3dZero(), Addin.App.Point3dFromXYZ(0, 1, 1)); // // BCOM.EllipseElement circle = Addin.App.CreateEllipseElement2(null, // // Addin.App.Point3dZero(), pipeOutsideDiam/2, pipeOutsideDiam/2, // // Addin.App.Matrix3dIdentity()); // // elements.Clear(); // // elements.Add(solids.SweepProfileAlongPath(circle, line),task.Location); // //} // BCOM.Transform3d taskTran; // { // taskTran = Addin.App.Transform3dFromMatrix3d(task.Rotation); // //taskTran = Addin.App.Transform3dInverse( // // Addin.App.Transform3dFromMatrix3d(task.Rotation)); // //taskTran = Addin.App.Transform3dFromMatrix3d( // // Addin.App.Matrix3dIdentity()); // } // /* // Ориентация тела построения solid - вдоль оси Z // Z _____ // ^ Y | // | /' | // !/___> X __*__ // */ // double correctAboutX; // double correctAboutY; // if (task.TaskType == PenetrTask.TaskObjectType.PipeEquipment) // { // /* Ориентация проходки перед применением матрицы поворота задания // * должна быть вдоль оси X // * // Y | | // ^ • ========| // !___> X | | // */ // correctAboutX = 0; // correctAboutY = Math.PI/2; // //rawVector = Addin.App.Point3dFromXYZ(1, 0, 0); // } // else // { // /* Ориентация проходки перед применением матрицы поворота задания // * должна быть вдоль оси Y // * _____ // Y | // ^ | // !___> X __*__ // */ // correctAboutX = -Math.PI/2; // correctAboutY = 0; // //rawVector = Addin.App.Point3dFromXYZ(0, 1, 0); // } // //BCOM.Point3d taskLocation = taskModel.IsAttachment ? // // Addin.App.Point3dScale(task.Location, task_subPerMaster) : // // task.Location; // BCOM.Point3d taskLocation = task.Location; // BCOM.Level level = ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_NAME); // BCOM.Level levelSymb = // ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_SYMB_NAME); // BCOM.Level levelRefPoint = // ElementHelper.getOrCreateLevel(PenetrTask.LEVEL_POINT_NAME); // TFCOM.TFFrameList frameList = Addin.AppTF.CreateTFFrame(); // foreach (var pair in elements) // { // BCOM.Element elem = pair.Key; // double shift = pair.Value; // elem.Color = 0; // TODO // BCOM.Point3d offset = Addin.App.Point3dAddScaled( // Addin.App.Point3dZero(), Addin.App.Point3dFromXYZ(0, 0, 1), shift); // elem.Move(offset); // elem.Rotate(Addin.App.Point3dZero(), correctAboutX, correctAboutY, 0); // elem.Transform(taskTran); // elem.Move(taskLocation); // elem.Level = level; // ElementHelper.setSymbologyByLevel(elem); // frameList.AsTFFrame.Add3DElement(elem); // } // //frameList.AsTFFrame.Get3DElement().Level = level; // //ElementHelper.setSymbologyByLevel(frameList.AsTFFrame.Get3DElement()); // TFCOM.TFProjectionList projList = Addin.AppTF.CreateTFProjection(); // projList.Init(); // foreach (var pair in projections) // { // BCOM.Element elem = pair.Key; // double shift = pair.Value; // elem.Color = 0; // TODO // BCOM.Point3d offset = Addin.App.Point3dAddScaled( // Addin.App.Point3dZero(), Addin.App.Point3dFromXYZ(0, 0, 1), shift); // elem.Move(offset); // elem.Rotate(Addin.App.Point3dZero(), correctAboutX, correctAboutY, 0); // elem.Transform(taskTran); // elem.Move(taskLocation); // elem.Level = (elem.Type == BCOM.MsdElementType.Line) ? // levelRefPoint : levelSymb; // ElementHelper.setSymbologyByLevel(elem); // if (elem.Type == BCOM.MsdElementType.Line) { // // точка вставки - линия с нулевой длинной // elem.Level = levelRefPoint; // } // var elemProjList = Addin.AppTF.CreateTFProjection(); // elemProjList.AsTFProjection.SetEmbeddedElement(elem); // projList.Append(elemProjList); // } // frameList.AsTFFrame.SetProjectionList(projList); // // ПЕРФОРАТОР // BCOM.EllipseElement perfoEl = // Addin.App.CreateEllipseElement2(null, Addin.App.Point3dZero(), // pipeInsideDiam/2, pipeInsideDiam/2, // Addin.App.Matrix3dIdentity(), BCOM.MsdFillMode.Filled); // { // BCOM.Point3d offset = Addin.App.Point3dAddScaled( // Addin.App.Point3dZero(), // Addin.App.Point3dFromXYZ(0, 0, 1), length/2); // perfoEl.Move(offset); // perfoEl.Rotate(Addin.App.Point3dZero(), correctAboutX, correctAboutY, 0); // } // perfoEl.Level = levelSymb; // ElementHelper.setSymbologyByLevel(perfoEl); // perfoEl.Transform(taskTran); // perfoEl.Move(taskLocation); // BCOM.Point3d perfoVec = perfoEl.Normal; // TFCOM.TFPerforatorList perfoList = Addin.AppTF.CreateTFPerforator(); // var tranIdentity = Addin.App.Transform3dIdentity(); // perfoList.InitFromElement(perfoEl, perfoVec, length/2 * 1.01, tranIdentity); // perfoList.SetSweepMode( // TFCOM.TFdPerforatorSweepMode.tfdPerforatorSweepModeBi); // //perfoList.SetSenseDist(1.01 * length / 2); // perfoList.SetPolicy( // TFCOM.TFdPerforatorPolicy.tfdPerforatorPolicyThroughHoleWithinSenseDist); // frameList.AsTFFrame.SetPerforatorList(perfoList); // frameList.AsTFFrame.SetSenseDistance2(length/2); // frameList.AsTFFrame.SetName("Penetration"); // ранее было 'EmbeddedPart' // frameList.AsTFFrame.SetPerforatorsAreActive(true); // frameList.Synchronize(); // return frameList; //} private static void setDataGroupInstance( BCOM.Element bcomElement, PenetrTask task) { Element element = ElementHelper.getElement(bcomElement); if (element == null) { return; } using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { if (catalogEditHandle == null || catalogEditHandle.CatalogInstanceName != null) { return; } catalogEditHandle.InsertDataGroupCatalogInstance("EmbeddedPart", "Embedded Part"); catalogEditHandle.UpdateInstanceDataDefaults(); DataGroupProperty code = null; DataGroupProperty name = null; foreach (DataGroupProperty property in catalogEditHandle.GetProperties()) { if (property?.Xpath == "EmbPart/@PartCode") { code = property; } else if (property?.Xpath == "EmbPart/@CatalogName") { name = property; } } if (code != null) { catalogEditHandle.SetValue(code, task.Code); } else { code = new DataGroupProperty("PartCode", task.Code, false, true); code.SchemaName = "EmbPart"; code.Xpath = "EmbPart/@PartCode"; catalogEditHandle.Properties.Add(code); } catalogEditHandle.SetValue(code, task.Code); if (name != null) { catalogEditHandle.SetValue(name, task.Name); } else { name = new DataGroupProperty("CatalogName", task.Name, false, true); name.SchemaName = "EmbPart"; name.Xpath = "EmbPart/@CatalogName"; catalogEditHandle.Properties.Add(name); } catalogEditHandle.Properties.Add(name); catalogEditHandle.Rewrite((int)BCOM.MsdDrawingMode.Normal); // TODO решить проблему вылета при команде Modify DataGroup Instance } }
public static ITFFrameList createFrameCN (PenetrTask task, PenetrInfo penInfo) { task.scanInfo(); // TODO отключено временно, до решения по алгоритму пересечений фланцев: //if (!Keyins.Penetrations.DEBUG_MODE) { // if (task.isCompoundExistsInPlace || task.TFFormsIntersected.Count == 0) // return null; //} var taskUOR = task.UOR; double pipeInsideDiam = penInfo.pipeDiameterInside * taskUOR.active_perSub; double pipeOutsideDiam = penInfo.pipeDiameterOutside * taskUOR.active_perSub; double flangeInsideDiam = penInfo.flangeDiameterInside * taskUOR.active_perSub; double flangeOutsideDiam = penInfo.flangeDiameterOutside * taskUOR.active_perSub; double flangeThick = penInfo.flangeThick * taskUOR.active_perSub; double length = task.Length * taskUOR.active_perSub; double pipeInRadius = pipeInsideDiam / 2; double pipeOutRadius = pipeOutsideDiam / 2; var tfApi = new Bentley.Building.Api.TFApplicationList().AsTFApplication; BCOM.ModelReference activeModel = App.ActiveModelReference; //ITFBrepList brepList; //tfApi.CreateTFBrep(0, out brepList); DPoint3d origin = task.Location.ToDPoint(); origin.ScaleInPlace(taskUOR.active_perMaster); DMatrix3d rot = task.Rotation.ToDMatrix3d(); var dTran = DTransform3d.FromMatrixAndTranslation(rot, origin); var tranInfo = new TransformInfo(dTran); // DMatrix3d.FromColumns( //rot.RowX.ToDVector(), rot.RowX.ToDVector(), rot.RowX.ToDVector()); //ITFFormRecipeList recipeList; var model = Session.Instance.GetActiveDgnModel(); var modelRef = Session.Instance.GetActiveDgnModelRef(); //CellHeaderElement taskEl = Element.GetFromElementRef(task.elemRefP) as CellHeaderElement; //DPoint3d taskOrigin; //taskEl.GetSnapOrigin(out taskOrigin); var ellips = new EllipseElement(model, null, DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, pipeOutRadius, DVector3d.FromXY(0, 1))); ellips.ApplyTransform(tranInfo); var cone = new ConeElement(model, null, pipeOutRadius, pipeOutRadius, DPoint3d.FromXYZ(0, length, 0), DPoint3d.Zero, DMatrix3d.Rotation(DVector3d.UnitX, Angle.FromDegrees(-90)), true); cone.ApplyTransform(tranInfo); var ellips2 = new EllipseElement(model, null, DEllipse3d.FromCenterRadiusNormal( DPoint3d.Zero, pipeInRadius, DVector3d.FromXY(0, 1))); ellips2.ApplyTransform(tranInfo); var cone2 = new ConeElement(model, null, pipeInRadius, pipeInRadius, DPoint3d.Zero, DPoint3d.FromXYZ(0, length, 0), DMatrix3d.Zero, false); cone2.ApplyTransform(tranInfo); //int status = brepList.InitCylinder(pipeInsideRadius*task_subPerMaster, // (length - flangeThick)*task_subPerMaster, ref origin, // ref matrix, ""); //ITFElementList elemList; //tfApi.CreateTFElement(0, out elemList); // Bentley.GeometryNET.Common.CircularCylinder //ITFBrepList coneBrepList, cone2BrepList, resBrepList; //tfApi.CreateTFBrep(0, out coneBrepList); //tfApi.CreateTFBrep(0, out cone2BrepList); //coneBrepList.InitFromElement(cone, modelRef, ""); //cone2BrepList.InitFromElement(cone2, modelRef, ""); //coneBrepList.AsTFBrep.InitCylinder(pipeInsideRadius, length, ref origin, // ref matrix, 0); ITFItemList itemList; tfApi.CreateTFItem(0, out itemList); //var sweepDir = DVector3d.FromXY(1, 0); //coneBrepList.AsTFBrep.Drop(out resBrepList, cone2BrepList, 0); //sweepDir.NegateInPlace(); // coneBrepList.AsTFBrep.Cut(out resBrepList, cone2BrepList, ref sweepDir, length + 150, false, 0); //coneBrepList.AsTFBrep.SweepByVector3(ref sweepDir, length + 300, // pipeOutsideRadius - pipeInsideRadius, 0, 0); //Array arr = new System.Collections.ArrayList().ToArray(); //coneBrepList.AsTFBrep.Cut2(out resBrepList, cone2BrepList.AsTFBrep, ref sweepDir, //Bentley.Building.Api.TFdBrepCutMethod.tfdBrepCutMethod_Outside, //Bentley.Building.Api.TFdBrepCutDirection.tfdBrepCutDirection_Both, //Bentley.Building.Api.TFdBrepCutDepth.tfdBrepCutDepth_UpToSolid, length, //arr, 0, false, Bentley.Building.Api.TFdBrepCutDepth.tfdBrepCutDepth_UpToSolid, length, //arr, 0, false, 0, 0, 0.00005, 0); //lement resElement; //resBrepList.GetElement(out resElement, 0, ""); //coneBrepList.GetElement(out resElement, 0, ""); ITFFrameList frameList; tfApi.CreateTFFrame(0, out frameList); frameList.AsTFFrame.Add3DElement(cone, 0); //frameList.AsTFFrame.Add3DElement(cone2, 0); //frameList.AsTFFrame.Add3DElement(resElement, 0); //ITFFrameList openingFrameList; //tfApi.CreateTFFrame(0, out openingFrameList); //openingFrameList.AsTFFrame.Add3DElement(cone2, 0); //ITFFormRecipeList openRecipeList; ////tfApi.CreateTFFormRecipeArc //ITFFormRecipe openRecipe; //openingFrameList.AsTFFrame.GetFormRecipeList(0, out openRecipeList); //openRecipe = openRecipeList.AsTFFormRecipe; //ITFItemList featureList; //frameList.AsTFFrame.AddOpeningsToForm(out featureList, ref openRecipe, "", 0); ITFPerforatorList perfoList; tfApi.CreateTFPerforator(0, out perfoList); var dir = DVector3d.FromXY(1, 0); var tran = DTransform3d.Identity; perfoList.InitFromElement(ellips, ref dir, length, ref tran, ""); perfoList.AsTFPerforator.SetIsVisible(false, 0); perfoList.SetSweepMode(Bentley.Building.Api.TFdPerforatorSweepMode.tfdPerforatorSweepModeBi, ""); perfoList.SetPolicy(Bentley.Building.Api.TFdPerforatorPolicy.tfdPerforatorPolicyThroughHoleWithinSenseDist, ""); frameList.AsTFFrame.SetPerforatorList(ref perfoList, 0); frameList.AsTFFrame.SetSenseDistance2(length / 100, 0); frameList.AsTFFrame.SetPerforatorsAreActive(true, 0); int stat; // = tfApi.ModelReferenceAddFrameList(modelRef, ref frameList, 0); var frame = frameList.AsTFFrame; stat = tfApi.ModelReferenceUpdateAutoOpeningsByFrame(modelRef, ref frame, true, false, Bentley.Building.Api.TFdFramePerforationPolicy.tfdFramePerforationPolicyNone, 0); //Element cylindr; //brepList.GetElement(out cylindr, 0, ""); //cylindr.AddToModel(); //Element tfElement; //Element perfo = null; //Element dp_2d = null; //int value; //tfApi.ModelReferenceAddElement(ref cylindr, Session.Instance.GetActiveDgnModel(), // 0, 0, out value); //tfApi.ModelReferenceConstructFrameElement(Session.Instance.GetActiveDgnModel(), // 0, ref cylindr, ref perfo, ref origin, ref dp_2d, "name", null, // 1, 0, false, null, false, task.Length, 0.00005, 0, out tfElement); //frameList.InitFromElement(cylindr, ""); // frameList.AsTFFrame.Add3DElement(cylindr, 0); return(frameList); }
public static void addToModelWithProjAndPerfo(ref TFCOM.TFFrameList frameList, PenetrTask task, PenetrInfo penInfo, BCOM.Level levelSymb, BCOM.Level levelRefPoint) { var taskUOR = new UOR(task.modelRef); double pipeInsideDiam = penInfo.pipeDiameterInside / taskUOR.active_subPerMaster; double pipeOutsideDiam = penInfo.pipeDiameterOutside / taskUOR.active_subPerMaster; double flangeInsideDiam = penInfo.flangeDiameterInside / taskUOR.active_subPerMaster; double flangeOutsideDiam = penInfo.flangeDiameterOutside / taskUOR.active_subPerMaster; double flangeThick = penInfo.flangeThick / taskUOR.active_subPerMaster; double length = task.LengthCm * 10 / taskUOR.active_subPerMaster; BCOM.ModelReference activeModel = App.ActiveModelReference; //AppTF.ModelReferenceAddFrameList(activeModel, ref frameList); frameList.Synchronize(); var frameListClass = frameList as TFCOM.TFFrameListClass; BCOM.Element bcomElem; frameListClass.GetElement(out bcomElem); var tfApi = new Bentley.Building.Api.TFApplicationList().AsTFApplication; var modelRef = Session.Instance.GetActiveDgnModelRef(); var model = Session.Instance.GetActiveDgnModel(); Element ielement = Element.GetFromElementRef((IntPtr)bcomElem.MdlElementRef()); modelRef.GetFromElementRef((IntPtr)bcomElem.MdlElementRef()); ITFFrameList iframeList; tfApi.CreateTFFrame(0, out iframeList); iframeList.InitFromElement(ielement, ""); iframeList.Synchronize(""); DPoint3d origin = task.Location.ToDPoint(); origin.ScaleInPlace(taskUOR.active_perMaster); DMatrix3d matrix = DMatrix3d.FromRows( task.Rotation.RowX.ToDVector(), task.Rotation.RowY.ToDVector(), task.Rotation.RowZ.ToDVector()); DTransform3d dTran = DTransform3d.FromMatrixAndTranslation(matrix, origin); TransformInfo tranInfo = new TransformInfo(dTran); double pipeInsideRadius = pipeOutsideDiam / 2 * taskUOR.active_perMaster; double dgnLength = length * taskUOR.active_perMaster; var ellips = new EllipseElement(model, null, DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, pipeInsideRadius, DVector3d.FromXY(0, 1))); ellips.ApplyTransform(tranInfo); //{ // ПЕРФОРАТОР: // ITFPerforatorList perfoList; // tfApi.CreateTFPerforator(0, out perfoList); // var dir = DVector3d.FromXY(1, 0); // var tran = DTransform3d.Identity; // //perfoList.InitFromElement(ellips, ref dir, length*toUOR, ref tran, ""); // perfoList.InitFromElement2(ellips, length*taskUOR.active_perMaster, ""); // perfoList.AsTFPerforator.SetIsVisible(false, 0); // perfoList.SetSweepMode(Bentley.Building.Api.TFdPerforatorSweepMode.tfdPerforatorSweepModeBi, ""); // perfoList.SetPolicy(Bentley.Building.Api.TFdPerforatorPolicy.tfdPerforatorPolicyThroughHoleWithinSenseDist, ""); // (iframeList as Bentley.Building.Api.TFFrameList).SetPerforatorList(ref perfoList, 0); // // iframeList.AsTFFrame.SetPerforatorList(ref perfoList, 0); // iframeList.AsTFFrame.SetSenseDistance2(length, 0); // iframeList.AsTFFrame.SetPerforatorsAreActive(true, 0); // var frame = iframeList.AsTFFrame; // tfApi.ModelReferenceUpdateAutoOpeningsByFrame(modelRef, //ref frame, true, false, Bentley.Building.Api.TFdFramePerforationPolicy.tfdFramePerforationPolicyStrict, 0); //} // tfApi.ModelReferenceRewriteFrameInstance(modelRef, iframeList.AsTFFrame, 0); //iframeList.AsTFFrame.Synchronize(0); { // ПРОЕКЦИОННАЯ ГЕОМЕТРИЯ ITFProjectionList projList, projList1, projList2, projList3; tfApi.CreateTFProjection(0, out projList); tfApi.CreateTFProjection(0, out projList1); tfApi.CreateTFProjection(0, out projList2); tfApi.CreateTFProjection(0, out projList3); var zero = DPoint3d.Zero; DPoint3d[] verts = { zero, zero, zero, zero, zero }; double k = pipeInsideRadius * Math.Cos(Math.PI / 4); verts[0].X = -k; verts[0].Z = -k; verts[1].X = k; verts[1].Z = k; verts[3] = verts[0]; verts[3].Z *= -1; verts[4] = verts[1]; verts[4].Z *= -1; LineStringElement cross1 = new LineStringElement(model, null, verts); for (int i = 0; i < verts.Count(); ++i) { verts[i].Y = dgnLength; } LineStringElement cross2 = new LineStringElement(model, null, verts); cross1.ApplyTransform(tranInfo); cross2.ApplyTransform(tranInfo); projList1.AsTFProjection.SetEmbeddedElement(cross1, 0); projList2.AsTFProjection.SetEmbeddedElement(cross2, 0); LineElement refPoint = new LineElement(model, null, new DSegment3d(zero, zero)); refPoint.ApplyTransform(tranInfo); ElementPropertiesSetter setter = new ElementPropertiesSetter(); setter.SetWeight(7); setter.Apply(refPoint); projList3.AsTFProjection.SetEmbeddedElement(refPoint, 0); projList.Append(projList1, ""); projList.Append(projList2, ""); projList.Append(projList3, ""); iframeList.AsTFFrame.SetProjectionList(projList, 0); //iframeList.AsTFFrame.Synchronize(0); //iframeList.Synchronize(string.Empty); } tfApi.ModelReferenceRewriteFrameInstance(modelRef, iframeList.AsTFFrame, 0); // int stat = tfApi.ModelReferenceRewriteFrameList(modelRef, iframeList, 0); //tfApi.ModelReferenceAddFrameList(modelRef, ref iframeList, 0); // tfApi.ModelReferenceRewriteFrameList(modelRef, iframeList, 0); //frameListClass = frameList as TFCOM.TFFrameListClass; //frameListClass.GetElement(out bcomElem); // setDataGroupInstance(bcomElem, task); }