/// <summary> /// Проверка на пересечения с другими закладными элементами. /// TRUE - если проверка пройдена /// </summary> private bool checkForIntersects(PenetrVueTask task, PenetrInfo penInfo) { task.scanInfo(); BCOM.Element penElement = PenetrHelper.getPenElementWithoutFlanges(task, penInfo); IEnumerable <BCOM.Element> intersects = ElementHelper.scanIntersectsInElementRange(penElement, App.ActiveModelReference); foreach (BCOM.Element intersection in intersects) { if (intersection.IsPenetrationCell()) { var body = getBodyWithOutFlanges(intersection.AsCellElement()); var contrIntersects = ElementHelper.scanIntersectsInElementRange(body, App.ActiveModelReference); BCOM.Range3d res = App.Range3dInit(); if (App.Range3dIntersect2(ref res, body.Range, penElement.Range)) { return(false); } } else if (intersection.IsCompundCell()) { return(false); } } return(true); }
private void init(BCOM.Element element, Sp3dTask_Old task) { elemRef = element.MdlElementRef(); modelRef = element.ModelReference.MdlModelRefP(); elemId = element.ID; Oid = task.pipe.Oid; if (task.pipe == null || task.component == null) { ErrorText = "Не удалось прочитать данные задания"; return; } Code = task.pipe.Name; BCOM.Point3d pt = new BCOM.Point3d(); pt.X = task.pipe.LocationX; pt.Y = task.pipe.LocationY; pt.Z = task.pipe.LocationZ; Location = pt; // разбор типоразмера: try { string[] parameters = task.pipe.Description.TrimStart('T').Split('-'); Diametr = int.Parse(parameters[1]); } catch (Exception) { ErrorText = string.Format("Не удалость разобрать типоразмер \"{0}\"", task.pipe.Description); } }
public static bool setTagOnElement <T>(BCOM.Element element, string tagSetName, string tagName, T value, BCOM.MsdTagType type = BCOM.MsdTagType.Character) { BCOM.TagElement tag = null; BCOM.DesignFile dgnFile = element.ModelReference.DesignFile; BCOM.TagSet tagSet = getTagSetOrCreate(dgnFile, tagSetName); try { tag = element.GetTag(tagSet, tagName); } catch (Exception) {} if (tag == null) { BCOM.TagDefinition tagDef = getTagDefOrCreate(tagSet, tagName, type); // TODO tagDef.IsHidden = ... tag = element.AddTag(tagDef); } if (tag != null) { tag.Value = value; tag.Rewrite(); return(true); } return(false); }
//private void readDatabaseData() //{ // логика взята из оригинального simpen от Л.Вибе // BCOM.Workspace wspace = Addin.App.ActiveWorkspace; // string server = wspace.IsConfigurationVariableDefined("AEP_SAVRD_SERVER") ? // wspace.ConfigurationVariableValue("AEP_SAVRD_SERVER") : "vibe1.sp.spbaep.ru"; // { // ОТЛАДКА // // server = "badserver"; // } // string passServer = // wspace.IsConfigurationVariableDefined("AEP_SAVRD_PASS_SERVER") ? // wspace.ConfigurationVariableValue("AEP_SAVRD_PASS_SERVER") : // "pw-srv.sp.spbaep.ru"; // string db = wspace.IsConfigurationVariableDefined("AEP_SAVRD_BASE") ? // wspace.ConfigurationVariableValue("AEP_SAVRD_BASE") : "parts"; // projId = wspace.IsConfigurationVariableDefined("EMBDB_PROJECT_ID") ? // long.Parse(wspace.ConfigurationVariableValue("EMBDB_PROJECT_ID")) : // 0; // offtake project id // // 0 - no project // // TODO read vba settings: // string user = "******"; // string pwd = "so2user"; // string connectionString = string.Format( // "Persist Security Info=False;" + // "Timeout=3;" + // "Data Source={0};" + // "Initial Catalog={1};" + // "User ID={2};" + // "Password={3}", // server, db, user, pwd); // SqlConnection connection = null; // try // { // connection = new SqlConnection(connectionString); // connection.Open(); // } // catch (SqlException) // { // if (connection != null) // { // connection.Close(); // connection.Dispose(); // connection = null; // } // } // try // { // string linked = string.Empty; // if (connection == null && server != passServer) // { // // если не доступен первый сервер, то пробуем через linkedserver // var connBldr = new SqlConnectionStringBuilder(connectionString); // { // ОТЛАДКА // //connBldr.DataSource = "vibe1.sp.spbaep.ru"; // } // linked = string.Format("[{0}].[{1}].[dbo].", // connBldr.DataSource, connBldr.InitialCatalog); // connBldr.DataSource = passServer; // connBldr.InitialCatalog = string.Empty; // connBldr.UserID = "oimread"; // connBldr.Password = connBldr.UserID; // connection = new SqlConnection(connBldr.ToString()); // connection.Open(); // } // string sql = string.Format("select top 1 * from {0}usr" + // " where usrLogin = '******' order by usrID desc", // linked, userName); // using (SqlDataReader reader = // new SqlCommand(sql, connection).ExecuteReader()) // { // if (reader != null && reader.HasRows) // { // DataTable dt = new DataTable(); // dt.Load(reader); // userId = dt.Rows[0].Field<long>("usrID"); // catalogId = dt.Rows[0].Field<long?>("usrCatalogID") ?? 0L; // depId = dt.Rows[0].Field<long>("depID"); // } // } // bool resHasRows = false; // using (SqlDataReader reader = new SqlCommand( // string.Format( // "select distinct flanNumber from {0}pendiam where {1} = {2}", // linked, // projId > 0 ? "prjID" : "depID", // projId > 0 ? projId : depId ), // connection).ExecuteReader()) // { // // todo caption project // resHasRows = reader.HasRows; // } // if (!resHasRows) // { // depId = 0; // } // penData.Clear(); // using (SqlDataReader reader = new SqlCommand( // string.Format("select * from {0}view_pendiam2", linked), // connection).ExecuteReader()) // { // if (reader != null && reader.HasRows) // { // penData.Load(reader); // } // } // //if (projId > 0) // //{ // // reader = new SqlCommand("select distinct flanNumber " + // // "from pendiam where prjID = " + projId, // // connection).ExecuteReader(); // //} // //else // //{ // //} // //command = new SqlCommand(sql, connection); // //reader = command.ExecuteReader(); // //if (!reader.HasRows) // //{ // // reader.Close(); // // reader = new SqlCommand("select distinct flanNumber " + // // "from pendiam where prjID = " + projId, // // connection).ExecuteReader(); // // reader. // //} // //dt = new DataTable(); // //dt.Load(reader); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } // finally // { // if (connection != null) // { // connection.Close(); // connection.Dispose(); // } // } //} private void btnPreview_Click(object sender, EventArgs e) { previewTranContainer.Reset(); try { foreach (TFCOM.TFFrameList frameList in getFramesData().Keys) { previewTranContainer.AppendCopyOfElement( frameList.AsTFFrame.Get3DElement()); var projList = frameList.AsTFFrame.GetProjectionList(); BCOM.Element projEl = null; do { try { projList.AsTFProjection.GetElement(out projEl); if (projEl != null) { previewTranContainer.AppendCopyOfElement(projEl); } } catch (Exception) { } } while ((projList = projList.GetNext()) != null); } } catch (Exception ex) // TODO { // ex.ShowMessage(); } }
//#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 object GetDataGroupPropertyValue(this BCOM.Element bcomElement, string propertyPath, string catalogType = null) { Element element = ElementHelper.getElement(bcomElement); if (element == null) { return(null); } using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { foreach (DataGroupProperty property in catalogEditHandle.GetProperties()) { if (catalogType != null && !catalogType.Equals(catalogEditHandle.CatalogTypeName)) { continue; } if (property.Xpath.Equals(propertyPath)) { return(property.Value); } } } return(null); }
public static BCOM.LineElement getElementRangeBox(BCOM.Element el) { BCOM.View view = ViewHelper.getActiveView(); BCOM.Point3d[] verts = new BCOM.Point3d[16]; verts[0] = el.Range.Low; verts[1] = verts[0]; verts[1].X = el.Range.High.X; verts[2] = verts[1]; verts[2].Y = el.Range.High.Y; verts[3] = verts[2]; verts[3].X = el.Range.Low.X; verts[4] = verts[5] = verts[0]; verts[5].Z = el.Range.High.Z; verts[6] = verts[5]; verts[6].Y = el.Range.High.Y; verts[7] = verts[6]; verts[7].X = el.Range.High.X; verts[8] = verts[7]; verts[8].Y = el.Range.Low.Y; verts[9] = verts[5]; verts[10] = verts[6]; verts[11] = verts[3]; verts[12] = verts[2]; verts[13] = verts[7]; verts[14] = verts[8]; verts[15] = verts[1]; return(App.CreateLineElement1(null, verts)); }
//WS: attached an instance of a class to element. If already exists, delete it and re-attach. private void AttachInstanceAndValues(BCOM.Element oEle, string strClassName, GeoTagDataBase oGeoTagData) { //WS: create an empty class instance. ECOI.IECInstance pInstance = oECAdaptor.CreateClassInstance(oECAdaptor.Schema, strClassName); //WS: populate instance values oECAdaptor.SetInstancePropertyValue(ref pInstance, "Tag_Number", oGeoTagData.Tag_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Tag_Status", oGeoTagData.Tag_Status); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Location", oGeoTagData.Location); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Service_Description", oGeoTagData.Service_Description); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Type", oGeoTagData.Type); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Plot_Plan_Document_Number", oGeoTagData.Plot_Plan_Document_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Detail_Drawing_Document_Number", oGeoTagData.Detail_Drawing_Document_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Month", oGeoTagData.Construction_Month); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Year", oGeoTagData.Construction_Year); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Originating_Contractor", oGeoTagData.Originating_Contractor); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Document_Number", oGeoTagData.Document_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Material_Main", oGeoTagData.Material_Main); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Procument_Package_Number", oGeoTagData.Procument_Package_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Contract_Package_Number", oGeoTagData.Contract_Package_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Contractor_Name", oGeoTagData.Construction_Contractor_Name); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Construction_Specification_Document_Number", oGeoTagData.Construction_Specification_Document_Number); if (strClassName == "Pond") { oECAdaptor.SetInstancePropertyValue(ref pInstance, "Supplier_Name", (oGeoTagData as Pond).Supplier_Name); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Supplier_Reference_Drawing_Doc_Number", (oGeoTagData as Pond).Supplier_Reference_Drawing_Doc_Number); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Design_Capacity", (oGeoTagData as Pond).Design_Capacity); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Fluid_Description", (oGeoTagData as Pond).Fluid_Description); oECAdaptor.SetInstancePropertyValue(ref pInstance, "Max_Fluid_Level", (oGeoTagData as Pond).Max_Fluid_Level); } if (strClassName == "Road") { oECAdaptor.SetInstancePropertyValue(ref pInstance, "Number_of_Lanes", (oGeoTagData as Road).Number_of_Lanes); } if (strClassName == "OpenChannel") { oECAdaptor.SetInstancePropertyValue(ref pInstance, "Fluid_Description", (oGeoTagData as OpenChannel).Fluid_Description); } //WS: check if an instance of the class already exists in the element. if (!oECAdaptor.HasECInstanceAttached(oEle, strClassName)) { //WS: attach to element oECAdaptor.CreateInstance(oEle, ref pInstance); } else //WS: if already has instance attached, delete it first, and then create a new one. { //WS: update instance, need to modify.. //oECAdaptor.UpdateInstance(oEle, ref pInstance); oECAdaptor.DeleteInstancesOnElement(oEle, strClassName); oECAdaptor.CreateInstance(oEle, ref pInstance); } }
public void LocateFilter(BCOM.Element element, ref BCOM.Point3d point, ref bool accepted) { accepted = false; if (element != null && element.IsPenetrationCell()) { accepted = true; startLeaderPrimitive(element); } }
public static bool SetDataGroupPropertyValue(this BCOM.Element bcomElement, string catalogName, string instanceName, string propXpath, string propName, object value, bool readOnly = false, bool visible = true) { Element element = ElementHelper.getElement(bcomElement); if (element == null) { return(false); } //var schemas = DataGroupDocument.Instance.CatalogSchemas.Schemas; // НВС для подгрузки схем using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { if (catalogEditHandle == null || (catalogEditHandle.CatalogInstanceName != null && catalogEditHandle.CatalogInstanceName != instanceName)) { return(false); } if (!(catalogEditHandle.HasDataGroupData() && catalogEditHandle.CatalogTypeName.Equals(catalogName) && catalogEditHandle.CatalogInstanceName.Equals(instanceName))) { catalogEditHandle.InsertDataGroupCatalogInstance(catalogName, instanceName); catalogEditHandle.UpdateInstanceDataDefaults(); } DataGroupProperty prop = catalogEditHandle.Properties .FirstOrDefault(x => x.Xpath.Equals(propXpath)); if (prop == null) { prop = new DataGroupProperty(propName, value, readOnly, visible) { Xpath = propXpath }; catalogEditHandle.Properties.Add(prop); } else { catalogEditHandle.SetValue(prop, value.ToString()); } int res = catalogEditHandle.Rewrite((int)BCOM.MsdDrawingMode.Normal); return(res == 0); // TODO решить проблему вылета при команде Modify DataGroup Instance } return(true); }
public static void ExportToCsv() { BCOM.ModelReference model = App.ActiveModelReference; BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass(); criteria.ExcludeAllTypes(); criteria.ExcludeNonGraphical(); criteria.IncludeType(BCOM.MsdElementType.CellHeader); BCOM.ElementEnumerator iter = App.ActiveModelReference.Scan(criteria); var builder = new StringBuilder(); string dltr = ";"; while (iter.MoveNext()) { BCOM.Element element = iter.Current; XDocument xDoc = ElementHelper.getSp3dXDocument(element.ToElement()); var dgPropColl = new Dictionary <Sp3dToDataGroupMapProperty, string>(); Sp3dToDGMapping.Instance.LoadValuesFromXDoc(xDoc, dgPropColl, true); if (builder.Length == 0) { // строка заголовков: builder.Append("ElementId"); foreach (var pair in dgPropColl) { builder.Append(dltr + pair.Key.TargetName); } builder.AppendLine(); } builder.Append(element.ID); foreach (var pair in dgPropColl) { builder.Append(dltr + pair.Value); } builder.AppendLine(); } string path = Path.ChangeExtension(App.ActiveDesignFile.FullName, ".csv"); File.WriteAllText(path, builder.ToString()); if (File.Exists(path)) { System.Diagnostics.Process.Start(path); App.MessageCenter.AddMessage($"SUCCESS: экспорт '{path}'", "", BCOM.MsdMessageCenterPriority.None, false); } else { App.MessageCenter.AddMessage($"FAILED: экспорт '{path}'", "", BCOM.MsdMessageCenterPriority.Warning, false); } }
public MstnNodeData(long parID, long ID, BCOM.Point3d rmCoordinates, BCOM.Element nodeElement, BCOM.LineElement lineElement, string nodeName, string nodeDescr) { //ParentNodeID = 0;// ; this.ID = nodeElement.ID; this.nodeElement = nodeElement; //if (sourceElement.IsCellElement()) // //this in as LV transfomer //else // //it is a source shape, ellipse }
public MstnNodeData(BCOM.Element sourceElement) { ParentNodeID = 0;// ; this.ID = sourceElement.ID; nodeElement = sourceElement; //if (sourceElement.IsCellElement()) // //this in as LV transfomer //else // //it is a source shape, ellipse }
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 transformToBase(BCOM.Element element, BCOM.Point3d origin) { // инвертируем трансформацию: if (App.Matrix3dHasInverse(Rotation)) { BCOM.Transform3d tran = App.Transform3dFromMatrix3d(Rotation); element.Transform(App.Transform3dInverse(tran)); } var angles = CorrectiveAngles; element.Rotate(App.Point3dZero(), -angles.X, -angles.Y, -angles.Z); }
public static bool IsPenetrationCell(this BCOM.Element element) { if (!element.IsCompundCell()) { return(false); } var cell = element.AsCellElement(); return(cell.Name == PenConfigVariables.CellName.Value || cell.Name == PenConfigVariables.CellNameOld.Value); }
public static Element ToElement(this BCOM.Element bcomElement) { #if CONNECT return(Element.GetFromElementRefAndModelRef( (IntPtr)bcomElement.MdlElementRef(), (IntPtr)bcomElement.ModelReference.MdlModelRefP())); #elif V8i return(Element.ElementFactory( (IntPtr)bcomElement.MdlElementRef(), (IntPtr)bcomElement.ModelReference.MdlModelRefP() )); #endif }
public void LocateFilter(BCOM.Element Element, ref BCOM.Point3d Point, ref bool Accepted) { if (Element.IsCellElement()) { if (Element.AsCellElement().Name == "Embankment" || Element.AsCellElement().Name == "RetainWall" || Element.AsCellElement().Name == "Pond" || Element.AsCellElement().Name == "Road" || Element.AsCellElement().Name == "OpenChannel" || Element.AsCellElement().Name == "Dike") { AddInMain.ComApp.ShowPrompt("GeoTag element selected, data point to accept."); Accepted = true; } } }
public static bool IsCompundCell(this BCOM.Element element) { TFCOM.TFElementList tfList = AppTF.CreateTFElement(); tfList.InitFromElement(element); if (tfList.AsTFElement == null) { return(false); } int tfType = tfList.AsTFElement.GetApplicationType(); return(tfList.AsTFElement.GetIsCompoundCellType()); }
private BCOM.Element createLeader() { List <BCOM.Element> elements = new List <BCOM.Element>(); if (pointIndex_ < 1) { points_[1] = points_[2] = points_[0]; } else if (pointIndex_ < 2) { points_[2] = points_[1]; } else { points_[2] = app_.Point3dFromXY(points_[2].X, points_[1].Y); } int kX = (points_[2].X - points_[1].X) >= 0 ? 1 : -1; BCOM.TextElement textUpper = app_.CreateTextElement1( null, leaderInfo_.TextLines[0], app_.Point3dZero(), app_.Matrix3dZero()); textUpper.Redraw(BCOM.MsdDrawingMode.Temporary); textUpper.set_Origin(points_[2].shift(dY: textUpper.Range.getHeight() * 0.75)); BCOM.TextElement textLower = app_.CreateTextElement1( null, leaderInfo_.TextLines[1], app_.Point3dZero(), app_.Matrix3dZero()); textLower.Redraw(BCOM.MsdDrawingMode.Temporary); textLower.set_Origin(points_[2].shift(dY: -textUpper.Range.getHeight() * 0.25)); double maxwidth = Math.Max(textUpper.Range.getWidth(), textLower.Range.getWidth()); if (kX < 0) { textUpper.set_Origin(textUpper.get_Origin().shift(-maxwidth)); textLower.set_Origin(textLower.get_Origin().shift(-maxwidth)); } points_[3] = app_.Point3dFromXY(points_[2].X + kX * (maxwidth + leaderInfo_.GapTextAfter), points_[2].Y); BCOM.Element line = app_.CreateLineElement1(null, points_); elements.Add(line); elements.Add(textUpper); elements.Add(textLower); return(app_.CreateCellElement1( "PenetrLeader", elements.ToArray(), points_[0])); }
public static bool getFromElement(BCOM.Element element, out PenetrTaskFlange penTask) { Sp3dTask_Old task = null; penTask = null; if (!ElementHelper.getElement(element) .isElementSp3dTask_Old(out task) || !(task.isFlange())) { return(false); } penTask = new PenetrTaskFlange(element, task); return(true); }
//public static BCOM.Level getLevel(string name) //{ // BCOM.Levels levels = App.ActiveDesignFile.Levels; // var activeModel = App.ActiveModelReference; // activeModel.Levels.IncludeHidden = true; // try // { // return activeModel.Levels[name]; // } // catch (Exception) {} // не найден // BCOM.Level activeLevel = App.ActiveSettings.Level; // try // { // Addin.Instance.sendKeyin( // string.Format("level set active {0}", name)); // activeModel.Levels.IncludeHidden = true; // return activeModel.Levels[name]; // } // catch (Exception) // { // return null; // } // finally // { // App.ActiveSettings.Level = activeLevel; // } //} //public static BCOM.Level getLevelOrActive(string name) //{ // return getLevel(name) ?? App.ActiveSettings.Level; //} /// <summary> /// Поиск пересечений с элементами по диапазону заданного элемента в /// в пространстве заданной модели /// </summary> public static IEnumerable <BCOM.Element> scanIntersectsInElementRange( this BCOM.Element element, BCOM.ModelReference model = null) { model = model ?? App.ActiveModelReference; BCOM.ElementScanCriteria criteria = new BCOM.ElementScanCriteriaClass(); criteria.ExcludeAllTypes(); criteria.ExcludeNonGraphical(); criteria.IncludeType(BCOM.MsdElementType.CellHeader); BCOM.Range3d scanRange = getElementScanRange(element, model); criteria.IncludeOnlyWithinRange(scanRange); return(model.Scan(criteria).BuildArrayFromContents()); }
public static bool getFacePlaneByLabel(out BCOM.Plane3d plane, BCOM.Element element, TFCOM.TFdFaceLabel faceLabel) { TFCOM.TFBrepList brepList; var formRecipeList = new TFCOM.TFFormRecipeListClass(); formRecipeList.InitFromElement(element); string options = string.Empty; formRecipeList.GetBrepList(out brepList, false, false, false, ref options); return(getFacePlaneByLabel(out plane, brepList, faceLabel)); }
public static bool MatchParams(BCOM.Element oElem, string lvlName, BCOM.MsdElementType elmType) { bool oSFlag, oLvlFlag, oColFlag, oTypeFlag; oSFlag = oLvlFlag = oColFlag = oTypeFlag = false; if (oElem.Type == elmType) { oTypeFlag = true; } if (oElem.Level.Name == lvlName) { oTypeFlag = true; } return(oTypeFlag); }
public MstnNodeData(long ID, BCOM.Point3d rmCoordinates, BCOM.Element nodeElement, BCOM.LineElement lineElement, string nodeName, string nodeDescr) { this.ParentNodeID = -1; this.ID = nodeElement.ID; this.nodeElement = nodeElement; this.nodeName = nodeName; this.nodeDescription = nodeDescr; this._reticMasterPt3D = rmCoordinates; this.conductor = lineElement; //if (nodeElement.IsCellElement()) // this in as LV transfomer // get MVLV cell in that position // assign the parent node ID to the mvlv cell id //else // it is a source shape, ellipse // ParentNodeID = 0; }
public static bool IsElementOfCatalogType(this BCOM.Element comElement, string catalogTypeName) { Element element = ElementHelper.getElement(comElement); using (var catalogEditHandle = new CatalogEditHandle(element, true, true)) { if (catalogEditHandle != null && catalogTypeName.Equals(catalogEditHandle.CatalogTypeName, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }
public static BCOM.Range3d getElementScanRange( BCOM.Element element, BCOM.ModelReference model = null) { BCOM.Range3d scanRange = element.Range; #if CONNECT // корректировака для версии CONNECT if (element.ModelReference.IsAttachmentOf(model)) { // здесь есть различия с V8i: // TODO проверить double k = model.UORsPerStorageUnit / element.ModelReference.UORsPerStorageUnit; scanRange.High = App.Point3dScale(scanRange.High, k); scanRange.Low = App.Point3dScale(scanRange.Low, k); } #endif return(scanRange); }
public static bool IsPlanarAndIntersectsElement( this TFCOM.TFBrepFace face, BCOM.Element element, out TFCOM.TFPlane tfPlane) { if (face.IsPlanar(out tfPlane)) { //faceList.AsTFBrepFace.GetLabel(out faceLabel); BCOM.Point3d[] faceVerts; face.GetVertexLocations(out faceVerts); var faceShape = App.CreateShapeElement1(null, faceVerts); BCOM.Range3d result = new BCOM.Range3d(); if (App.Range3dIntersect2(ref result, element.Range, faceShape.Range)) { return(true); } } return(false); }
public static void setSymbologyByLevel(BCOM.Element element, ref bool dirty) { if (element.LineStyle != App.ByLevelLineStyle()) { dirty = true; element.LineStyle = App.ByLevelLineStyle(); } if (element.LineWeight != App.ByLevelLineWeight()) { dirty = true; element.LineWeight = App.ByLevelLineWeight(); } if (element.Color != App.ByLevelColor()) { dirty = true; element.Color = App.ByLevelColor(); } }
public void changeSelection(IEnumerable <DataRow> selection) { selectionTranCon_?.Reset(); foreach (DataRow taskRow in selection) { PenetrVueTask task = rowsToTasks_[taskRow]; BCOM.ModelReference modelRef = task.ModelRef; BCOM.View view = ViewHelper.getActiveView(); var taskUOR = new UOR(task.ModelRef); var activeUOR = new UOR(App.ActiveModelReference); 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 temp = modelRef.GetElementByID(id).Clone(); temp.Color = 2; // зелёный temp.LineWeight = 5; #if CONNECT // для версии CONNECT требуется поправка // в V8i возмоно она производится автоматически BCOM.Attachment attachment = task.getAttachment(); if (attachment != null) { temp.Transform(attachment.GetReferenceToMasterTransform()); } #endif selectionTranCon_.AppendCopyOfElement(temp); } } }