public void AddProjection() { if (IsProjectionAdded_) { return; } BCOM.LineElement contour = Task.GetLineContour(); BCOM.LineElement cross = ElementHelper.createCrossInContour(contour); BCOM.Level level = ElementHelper.GetOrCreateLevel(LEVEL_PROJECTION_NAME); FrameList.AddProjection(contour, "contour", level); FrameList.AddProjection(cross, "cross", level); // 2-ая проекция: var contour2 = (BCOM.LineElement)contour.Clone(); var cross2 = (BCOM.LineElement)cross.Clone(); contour2.Move(App.Point3dScale(Task.DepthVec, Task.Depth)); cross2.Move(App.Point3dScale(Task.DepthVec, Task.Depth)); FrameList.AddProjection(contour2, "contour", level); FrameList.AddProjection(cross2, "cross", level); IsProjectionAdded_ = true; }
//#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; } }
public static void RunByRecovertingSettings(Action action, params object[] args) { var activeSets = App.ActiveSettings; BCOM.Level activeLevel = activeSets.Level; BCOM.LineStyle activeLineStyle = activeSets.LineStyle; int activeLineWeight = activeSets.LineWeight; int activeColor = activeSets.Color; try { action?.DynamicInvoke(args); } catch (Exception ex) { ex.ShowMessageBox(); } finally { activeSets.Level = activeLevel; activeSets.LineStyle = activeLineStyle; activeSets.LineWeight = activeLineWeight; activeSets.Color = activeColor; } }
public static void SetByLevel(this BCOM.Settings settings, BCOM.Level level) { settings.Level = level; settings.LineStyle = level.ElementLineStyle; settings.LineWeight = level.ElementLineWeight; settings.Color = level.ElementColor; }
public Opening(OpeningTask task) { Task = task; FrameList = new TFCOM.TFFrameListClass(); BCOM.Level level = ElementHelper.GetOrCreateLevel(LEVEL_NAME); contour_ = task.GetContourShape(); BCOM.SmartSolidElement body = App.SmartSolid.ExtrudeClosedPlanarCurve(contour_, task.Depth, 0.0, false); body.Level = level; ElementHelper.setSymbologyByLevel(body); FrameList.Add3DElement(body); FrameList.AsTFFrame.SetName(CELL_NAME); }
public void AddProjection() { if (IsProjectionAdded_) { return; } CatchExceptionsByMessageCenter(() => { IEnumerable <ProjectionInfo> projInfoList = GetProjectionInfoList(); foreach (ProjectionInfo projInfo in projInfoList) { BCOM.Level level = ElementHelper.GetOrCreateLevel(projInfo.LevelName); FrameList.AddProjection( projInfo.Element, projInfo.ProjectionName, level); } IsProjectionAdded_ = true; }); }
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); }
private bool addToModel_(BCOM.ModelReference model = null) { model = model ?? App.ActiveModelReference; BCOM.Level level = ElementHelper.GetOrCreateLevel(LevelName); App.ActiveSettings.SetByLevel(level); BCOM.Element element; FrameList.GetElement(out element); if (element.ID != 0 && element.ModelReference == model) { return(true); } FrameList.AddToModel(model); FrameList.GetElement(out element); bool res = element.ID != 0; return(res); }
public bool AddToModel(bool recoverSettings = true, BCOM.ModelReference model = null) { model = model ?? App.ActiveModelReference; bool res = false; BCOM.Level level = ElementHelper.GetOrCreateLevel(LEVEL_NAME); App.ActiveSettings.SetByLevel(level); if (recoverSettings) { ElementHelper.RunByRecovertingSettings(() => { res = addToModel_(model); }); } else { res = addToModel_(model); } // DataGroup свойства: res |= SetDataGroupInstance(); return(res); }
public void Initialize() { if (IsInitialized_) { return; } BCOM.Level level = ElementHelper.GetOrCreateLevel(LevelName); FrameList = new TFCOM.TFFrameListClass(); IEnumerable <BCOM.Element> bodyElements = GetBodyElements(); foreach (BCOM.Element element in bodyElements) { element.Level = level; ElementHelper.setSymbologyByLevel(element); FrameList.Add3DElement(element); } FrameList.SetName(CellName); IsInitialized_ = true; }
public static void AddProjection(this TFCOM.TFFrameList frameList, BCOM.Element element, string projectionName, BCOM.Level level) { TFCOM.TFProjectionList tfProjection = AppTF.CreateTFProjection((string)null); tfProjection.Init(); element.Level = level; ElementHelper.setSymbologyByLevel(element); tfProjection.AsTFProjection.SetDefinitionName(projectionName); tfProjection.AsTFProjection.SetEmbeddedElement(element); tfProjection.AsTFProjection.SetIsDoubleSided(true); TFCOM.TFProjectionList projectionList = frameList.AsTFFrame.GetProjectionList(); if (projectionList == null) { frameList.AsTFFrame.SetProjectionList(tfProjection); } else { projectionList.Append(tfProjection); } }
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); }
public static void addPerforator(TFCOM.TFFrameList frameList, IPenetrTask task, PenetrInfo penInfo, BCOM.Level levelSymb, bool isVisible) { var taskUOR = new UOR(task.ModelRef); double pipeInsideDiam = penInfo.pipeDiameterInside / taskUOR.activeSubPerMaster; double pipeOutsideDiam = penInfo.pipeDiameterOutside / taskUOR.activeSubPerMaster; double flangeInsideDiam = penInfo.flangeDiameterInside / taskUOR.activeSubPerMaster; double flangeOutsideDiam = penInfo.flangeDiameterOutside / taskUOR.activeSubPerMaster; double flangeThick = penInfo.flangeThick / taskUOR.activeSubPerMaster; double length = task.LengthCm * 10 / taskUOR.activeSubPerMaster; var angles = task.CorrectiveAngles; BCOM.Transform3d taskTran = App.Transform3dFromMatrix3d(task.Rotation); // ПЕРФОРАТОР BCOM.EllipseElement perfoEl = App.CreateEllipseElement2(null, App.Point3dZero(), pipeInsideDiam / 2, pipeInsideDiam / 2, App.Matrix3dIdentity(), BCOM.MsdFillMode.Filled); { BCOM.Point3d offset = App.Point3dAddScaled( App.Point3dZero(), App.Point3dFromXYZ(0, 0, 1), length / 2); perfoEl.Move(offset); perfoEl.Rotate(App.Point3dZero(), angles.X, angles.Y, angles.Z); } perfoEl.Level = levelSymb; ElementHelper.setSymbologyByLevel(perfoEl); perfoEl.Transform(taskTran); perfoEl.Move(task.Location); BCOM.Point3d perfoVec = perfoEl.Normal; TFCOM.TFPerforatorList perfoList = AppTF.CreateTFPerforator(); var tranIdentity = 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); perfoList.SetIsVisible(isVisible); frameList.AsTFFrame.SetPerforatorList(perfoList); frameList.AsTFFrame.SetSenseDistance2(length / 2); frameList.AsTFFrame.SetPerforatorsAreActive(true); frameList.Synchronize(); { // ! без этого кода не срабатывает перфорация в стенке/плите // судя по всему инициализирует обновление объектов, с которыми // взаимодействует frame AppTF.ModelReferenceUpdateAutoOpeningsByFrame( App.ActiveModelReference, frameList.AsTFFrame, true, false, TFCOM.TFdFramePerforationPolicy.tfdFramePerforationPolicyNone); } }
public static TFCOM.TFFrameListClass createFrameList( IPenetrTask task, PenetrInfo penInfo, BCOM.Level level) { task.scanInfo(); var taskUOR = new UOR(task.ModelRef); double pipeInsideDiam = penInfo.pipeDiameterInside / taskUOR.activeSubPerMaster; double pipeOutsideDiam = penInfo.pipeDiameterOutside / taskUOR.activeSubPerMaster; double flangeInsideDiam = penInfo.flangeDiameterInside / taskUOR.activeSubPerMaster; double flangeOutsideDiam = penInfo.flangeDiameterOutside / taskUOR.activeSubPerMaster; double flangeThick = penInfo.flangeThick / taskUOR.activeSubPerMaster; double length = task.LengthCm * 10 / taskUOR.activeSubPerMaster; var solids = 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>(); { double shift = task.FlangesCount == 1 ? delta : 0; shift *= task.IsSingleFlangeFirst ? 1 : -1; elements.Add(cylindr, (length + shift) / 2); } // Фланцы: 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 = App.Vector3dEqualTolerance(task.SingleFlangeSide, App.Vector3dFromXYZ(0, 0, -1), 0.1); // 0.001 // 0.5 - для видимости фланцев на грани стены/плиты shift = isNearest ? 0.0 + flangeThick / 2 - task.FlangeWallOffset: length - flangeThick / 2 + task.FlangeWallOffset; } else { shift = i == 0 ? 0.0 : length; // для самих фланцев: shift += Math.Pow(-1, i) * (flangeThick / 2 - task.FlangeWallOffset); //0.02); } elements.Add(flangeCylindr, shift); } BCOM.Transform3d taskTran = App.Transform3dFromMatrix3d(task.Rotation); var angles = task.CorrectiveAngles; TFCOM.TFFrameListClass frameList = new TFCOM.TFFrameListClass(); foreach (var pair in elements) { BCOM.Element elem = pair.Key; double shift = pair.Value; elem.Color = 0; // TODO BCOM.Point3d offset = App.Point3dAddScaled( App.Point3dZero(), App.Point3dFromXYZ(0, 0, 1), shift); elem.Move(offset); elem.Rotate(App.Point3dZero(), angles.X, angles.Y, angles.Z); elem.Transform(taskTran); elem.Move(task.Location); elem.Level = level; ElementHelper.setSymbologyByLevel(elem); frameList.AsTFFrame.Add3DElement(elem); } frameList.AsTFFrame.SetName(PenConfigVariables.CellName.Value); // ранее было 'EmbeddedPart' return(frameList); }