private List <DbElement> CollectStructuralItems() { List <DbElement> dbElementList = new List <DbElement>(); DbElement element = CurrentElement.get_Element(); DbElementType[] dbElementTypeArray = new DbElementType[7] { (DbElementType)DbElementTypeInstance.SCTN, (DbElementType)DbElementTypeInstance.PANEL, (DbElementType)DbElementTypeInstance.GENSEC, (DbElementType)DbElementTypeInstance.FLOOR, (DbElementType)DbElementTypeInstance.GWALL, (DbElementType)DbElementTypeInstance.STWALL, (DbElementType)DbElementTypeInstance.WALL }; DBElementCollection elementCollection = new DBElementCollection(element); elementCollection.set_IncludeRoot(true); elementCollection.set_Filter((BaseFilter) new TypeFilter(dbElementTypeArray)); DBElementEnumerator enumerator = (DBElementEnumerator)elementCollection.GetEnumerator(); while (enumerator.MoveNext()) { dbElementList.Add((DbElement)enumerator.get_Current()); } return(dbElementList); }
private static AxisDir MakeDirection(int num, bool isNeg, DbElement modelEle) { DbElement cate = modelEle.GetElement(DbAttributeInstance.SPRE).GetElement(DbAttributeInstance.CATR); DbElement ptre = cate.GetElement(DbAttributeInstance.PTRE); DbElement pt = ptre.FirstMember(); while (pt != null && pt.IsValid) { if (num != pt.GetInteger(DbAttributeInstance.NUMB)) { pt = pt.Next(); continue; } DbElementType type = pt.GetElementType(); if (type == DbElementTypeInstance.PTAXIS) { return(MakeAxialDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTCAR) { return(MakeCartesianDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTMIX) { return(MakeMixedDirection(num, isNeg, pt, modelEle)); } else if (type == DbElementTypeInstance.PTPOS) { return(MakePositionTypeDirection(num, isNeg, pt, modelEle)); } pt = pt.Next(); } return(null); }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, DbElementType sourceType) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; SourceType = sourceType; }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, ConvertToBuildable.NozzleConfig nozzleConfig) { _element = element; Size = size; Position = position; Direction = direction; NozzleConfig = nozzleConfig; BuildAs = buildAs; }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, List <Position> vertices) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; Verticies = vertices; }
public Buildable(DbElementType buildAs, DbElement element, Size size, Position position, Direction direction, Position p2, Direction d2) { BuildAs = buildAs; _element = element; Size = size; Position = position; Direction = direction; Position2 = p2; Direction2 = d2; }
private bool IsSupportedDesignGeometryEle(DbElement ele) { DbElementType type = ele.GetElementType(); return(type == DbElementTypeInstance.CYLINDER || type == DbElementTypeInstance.BOX || type == DbElementTypeInstance.DISH || type == DbElementTypeInstance.CONE || type == DbElementTypeInstance.PYRAMID ); }
public void run() { DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design); DbElementType[] dbtype = new DbElementType[] { DbElementTypeInstance.PIPE }; TypeFilter filter = new TypeFilter(dbtype); AndFilter finalfilter = new AndFilter(); AttributeStringFilter filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("Name"), FilterOperator.Equals, "/babo"); finalfilter.Add(filter); finalfilter.Add(filter2); DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter); Console.WriteLine("스펙월드갯수:" + spwl_collects.Cast <DbElement>().Count()); int speccnt = 0; List <DbElement> working_dbelement = new List <DbElement>(); foreach (DbElement element in spwl_collects) { //element.Delete(); DbCopyOption dd = new DbCopyOption(); //dd.ToName="/bbboa"; //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd); //de.InsertBefore(CurrentElement.Element); DbElement xx = DbElement.GetElement("/xx1"); CurrentElement.Element.InsertAfterLast(xx); //de.InsertAfterLast(element.Owner); ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME)); //foreach (DbElement spec in spwl.Members()) //{ // //spec.CreateLast(DbElementType.GetElementType("Sele")); // string specname = spec.GetAsString(DbAttributeInstance.NAME); // if (specname.Substring(1, 2) == "/*") // continue; // working_dbelement.Add(spec); // speccnt++; // //Console.WriteLine(" -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME)); //} } //MDB.CurrentMDB.GetWork(); }
public static DbElement OwnerInHierarchyOfType(this DbElement element, DbElementType type) { while (true) { var owner = element.Owner; if (owner.ElementType == type) { return(owner); } if (owner.IsNull) { return(owner); } element = owner; } }
private List <DbElement> CollectPrimitiveItems() { List <DbElement> dbElementList = new List <DbElement>(); try { DbElement element = CurrentElement.get_Element(); DbElementType[] dbElementTypeArray = new DbElementType[17] { (DbElementType)DbElementTypeInstance.BOX, (DbElementType)DbElementTypeInstance.CYLINDER, (DbElementType)DbElementTypeInstance.SLCYLINDER, (DbElementType)DbElementTypeInstance.RTORUS, (DbElementType)DbElementTypeInstance.CTORUS, (DbElementType)DbElementTypeInstance.POHEDRON, (DbElementType)DbElementTypeInstance.SNOUT, (DbElementType)DbElementTypeInstance.PYRAMID, (DbElementType)DbElementTypeInstance.POLYHEDRON, (DbElementType)DbElementTypeInstance.DISH, (DbElementType)DbElementTypeInstance.CONE, (DbElementType)DbElementTypeInstance.PCLAMP, (DbElementType)DbElementTypeInstance.HELEMENT, (DbElementType)DbElementTypeInstance.EXTRUSION, (DbElementType)DbElementTypeInstance.NOZZLE, (DbElementType)DbElementTypeInstance.SCLAMP, (DbElementType)DbElementTypeInstance.REVOLUTION }; DBElementCollection elementCollection = new DBElementCollection(element); elementCollection.set_IncludeRoot(true); elementCollection.set_Filter((BaseFilter) new TypeFilter(dbElementTypeArray)); DBElementEnumerator enumerator = (DBElementEnumerator)elementCollection.GetEnumerator(); while (enumerator.MoveNext()) { DbElement current = (DbElement)enumerator.get_Current(); if (Tools.CheckLevel(current, 6)) { dbElementList.Add(current); } } } catch (Exception ex) { HierarchyItem.Log.Error((object)("Error collecting primitives :" + ex.Message)); } return(dbElementList); }
private int GetColor(DbElement ele, int parentColor) { DbElementType eleType = ele.GetElementType(); if (eleType == DbElementTypeInstance.BRANCH) { return(System.Drawing.Color.Gold.ToArgb()); } else if (eleType == DbElementTypeInstance.EQUIPMENT) { return(System.Drawing.Color.Tan.ToArgb()); } else { return(parentColor); } }
private void btnModelInsert_Click(object sender, EventArgs e) { //Drawlist 정의하고 추가하는 부분 var drawListManager = DrawListManager.Instance; var currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; drawListManager.BeginUpdate(); var currentDrawList = drawListManager.CurrentDrawList; DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design); DbElementType[] dbtypes = new DbElementType[] { DbElementTypeInstance.PIPE }; if (checkPipe.Checked) { dbtypes = new DbElementType[] { DbElementTypeInstance.PIPE }; DBElementCollection pipe_collection = Get_Element_Collection(Outfit_Elements, dbtypes, txt_pipe_name.Text, txt_pipe_module.Text); currentDrawList.Add(pipe_collection.Cast <DbElement>().ToArray()); } if (checkStru.Checked) { dbtypes = new DbElementType[] { DbElementTypeInstance.STRUCTURE }; DBElementCollection stru_collection = Get_Element_Collection(Outfit_Elements, dbtypes, txt_stru_name.Text, txt_stru_module.Text); currentDrawList.Add(stru_collection.Cast <DbElement>().ToArray()); } if (checkEquip.Checked) { dbtypes = new DbElementType[] { DbElementTypeInstance.EQUIPMENT }; DBElementCollection equip_collection = Get_Element_Collection(Outfit_Elements, dbtypes, txt_equip_name.Text, txt_equip_module.Text); currentDrawList.Add(equip_collection.Cast <DbElement>().ToArray()); } drawListManager.EndUpdate(); currentDrawList.VisibleAll(); Cursor.Current = currentCursor; }
public Hashtable GetVolumeWithinElement(string elementname, Hashtable dbtypeArray, Boolean completelycover) { //DbElementType[] dbtypes = new DbElementType[] { DbElementTypeInstance.PSPOOL }; string samplerow = ((string)dbtypeArray[1.0]); List<DbElementType> dbtypeslist = new List<DbElementType>(); foreach (var item in dbtypeArray.Keys) { dbtypeslist.Add(DbElementType.GetElementType(dbtypeArray[item].ToString())); } DbElementType[] dbtypes = dbtypeslist.ToArray(); DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Design); DBElementCollection result_collection = null; TypeFilter filter = new TypeFilter(dbtypes); AndFilter finalfilter = new AndFilter(); InVolumeFilter volfilter = new InVolumeFilter(CurrentElement.Element,dbtypes, true); finalfilter.Add(filter); finalfilter.Add(volfilter); result_collection = new DBElementCollection(Outfit_Elements, finalfilter); Hashtable resultHs = new Hashtable(); double idx = 1.0; foreach (DbElement item in result_collection) { resultHs.Add(idx, item.GetAsString(DbAttributeInstance.NAME)); idx = idx + 1.0; } return resultHs; }
public void DeleteElement(DbElementType type) { switch (type) { case DbElementType.Movie: //logic for deleting movie to db here break; case DbElementType.Director: //logic for deleting director to db here break; case DbElementType.Genre: //logic for deleting genre to db here break; default: throw new Exception("Unsupportable DbElementType!"); } // after deleting top-level locals should be refreshed }
private List <DbElement> CollectPjoiItems() { List <DbElement> dbElementList = new List <DbElement>(); DbElement element = CurrentElement.get_Element(); DbElementType[] dbElementTypeArray = new DbElementType[1] { (DbElementType)DbElementTypeInstance.PJOINT }; DBElementCollection elementCollection = new DBElementCollection(element); elementCollection.set_IncludeRoot(true); elementCollection.set_Filter((BaseFilter) new TypeFilter(dbElementTypeArray)); DBElementEnumerator enumerator = (DBElementEnumerator)elementCollection.GetEnumerator(); while (enumerator.MoveNext()) { dbElementList.Add((DbElement)enumerator.get_Current()); } return(dbElementList); }
public static void Run() { //FirstMember TypeFilter filt = new TypeFilter(DbElementTypeInstance.NOZZLE); DbElement nozz1 = filt.FirstMember(Example.Instance.mEqui); DbElementType type = nozz1.GetElementType(); //NextMember DbElement nozz2 = filt.Next(nozz1); //NextMember DbElement[] members = filt.Members(Example.Instance.mEqui); //parent TypeFilter filt2 = new TypeFilter(DbElementTypeInstance.SITE); DbElement site = filt2.Parent(nozz1); type = site.GetElementType(); //Valid AndFilter andFilt4 = new AndFilter(); andFilt4.Add(new TypeFilter(DbElementTypeInstance.EQUIPMENT)); andFilt4.Add(new TrueFilter()); bool valid = andFilt4.Valid(Example.Instance.mEqui); // attribute true AttributeTrueFilter filt1 = new AttributeTrueFilter(DbAttributeInstance.ISNAME); //should be true for named element bool named = filt1.Valid(Example.Instance.mEqui); //for first member it is also true named = filt1.Valid(Example.Instance.mEqui.FirstMember()); //Element type at or below BelowOrAtType filt3 = new BelowOrAtType(DbElementTypeInstance.EQUIPMENT); bool below = filt3.ScanBelow(Example.Instance.mEqui); }
private void ExportEquip(DbElement equipEle, D3Transform transform, int parentColor) { int color = GetColor(equipEle, parentColor); D3Transform currTrans = transform.Multiply(GetTransform(equipEle)); DbElement ele = equipEle.FirstMember(); while (ele != null && ele.IsValid) { if (IsReadableEle(ele)) { if (!IsVisible(ele)) { ele = ele.Next(); continue; } DbElementType eleType = ele.GetElementType(); if (eleType == DbElementTypeInstance.NOZZLE) { ExportPipeItem(ele, currTrans, parentColor); } else if (eleType == DbElementTypeInstance.TMPLATE) { DbElement[] lcnfArray = null; if (ele.IsAttributeValid(DbAttributeInstance.LCNFA)) { lcnfArray = ele.GetElementArray(DbAttributeInstance.LCNFA); } if (lcnfArray == null || lcnfArray.Length <= 0) { DbElement tmplEle = ele.FirstMember(); while (tmplEle != null && tmplEle.IsValid) { if (IsReadableEle(tmplEle) && IsVisible(tmplEle)) { ExportDesignGeomotry(tmplEle, currTrans, color); } tmplEle = tmplEle.Next(); } } else { foreach (DbElement lcnfEle in lcnfArray) { if (IsReadableEle(lcnfEle) && IsVisible(lcnfEle)) { ExportDesignGeomotry(lcnfEle, currTrans, color); } } } } else if (eleType == DbElementTypeInstance.SUBEQUIPMENT) { ExportEquip(ele, currTrans, color); } else { ExportDesignGeomotry(ele, currTrans, color); } } ele = ele.Next(); } }
public static void Run() { //Get element type int hash = DbElementTypeInstance.EQUIPMENT.GetHashCode(); DbElementType type = DbElementType.GetElementType(hash); // Get system attributes DbAttribute[] atts = DbElementTypeInstance.EQUIPMENT.SystemAttributes(); int size = atts.Length; //Construct equi1 DbElement equi1 = DbElement.GetElement("/ExampleEqui"); //Create equi2 after equi1 DbElement equi2 = equi1.CreateAfter(DbElementTypeInstance.EQUIPMENT); //Copy equi1 to equi2 equi2.Copy(equi1); //Copy hierarchy DbCopyOption options = new DbCopyOption(); options.FromName = "ExampleEqui"; options.ToName = "equi2"; options.Rename = true; equi2.CopyHierarchy(equi1, options); DbElement first = equi2.FirstMember(); //Copy after last equi1.InsertAfterLast(Example.Instance.mZone); //Branch to head tube DbElement headTube = Example.Instance.mBran.FirstMember(); string headTubeName = headTube.GetString(DbAttributeInstance.NAME); //Next Prev DbElement nextElement = headTube.Next(); DbElement prevElement = nextElement.Previous; //First Member of given type DbElement nozz1 = Example.Instance.mEqui.FirstMember(DbElementTypeInstance.NOZZLE); //Next element of given type DbElement nozz2 = nozz1.Next(DbElementTypeInstance.NOZZLE); //Get Members DbElement[] members = Example.Instance.mBran.Members(); //Get Members of given type DbElement[] nozzles = Example.Instance.mEqui.Members(DbElementTypeInstance.NOZZLE); //Get nth Member DbElement mem = Example.Instance.mEqui.Member(2); //Expressions DbElement[] eles; eles = Example.Instance.mEqui.GetElementArray(DbAttribute.GetDbAttribute("MEMB"), DbElementType.GetElementType("NOZZ")); nozz1 = eles[1]; DbExpression expr1 = DbExpression.Parse("HEIGHT OF PREV * 2"); string val = expr1.ToString(); double dval; DbAttributeUnit units = DbAttributeUnit.DIST; dval = nozz1.EvaluateDouble(expr1, units); DbExpression expr2 = DbExpression.Parse("12"); dval = nozz1.EvaluateDouble(expr2, units); //Rules DbExpression expr = DbExpression.Parse("HEIGHT * 2.0"); DbRuleStatus status = DbRuleStatus.DYNAMIC; DbExpressionType etype = DbExpressionType.REAL; DbRule rule = DbRule.CreateDbRule(expr, status, etype); Example.Instance.mCyli.SetRule(DbAttribute.GetDbAttribute("DIAM"), rule); DbRule rule1 = Example.Instance.mCyli.GetRule(DbAttribute.GetDbAttribute("DIAM")); string text = rule1.ToString(); //Delete/Exists Rule Example.Instance.mCyli.DeleteRule(DbAttribute.GetDbAttribute("DIAM")); bool exists = Example.Instance.mCyli.ExistRule(DbAttribute.GetDbAttribute("DIAM")); Example.Instance.mCyli.SetRule(DbAttribute.GetDbAttribute("DIAM"), rule1); exists = Example.Instance.mCyli.ExistRule(DbAttribute.GetDbAttribute("DIAM")); //Change attribute Example.Instance.mCyli.SetAttribute(DbAttribute.GetDbAttribute("DIAM"), 1000.0F); double diam = Example.Instance.mCyli.GetDouble(DbAttribute.GetDbAttribute("DIAM")); //verify rule bool diff = Example.Instance.mCyli.VerifyRule(DbAttribute.GetDbAttribute("DIAM")); //execute rule Example.Instance.mCyli.ExecuteRule(DbAttribute.GetDbAttribute("DIAM")); diam = Example.Instance.mCyli.GetDouble(DbAttribute.GetDbAttribute("DIAM")); //verify rule again diff = Example.Instance.mCyli.VerifyRule(DbAttribute.GetDbAttribute("DIAM")); //change some attributes Example.Instance.mCyli.SetAttribute(DbAttribute.GetDbAttribute("DIAM"), 1000.0F); diam = Example.Instance.mCyli.GetDouble(DbAttribute.GetDbAttribute("DIAM")); //Now execute all rules under equi Example.Instance.mEqui.ExecuteAllRules(); diam = Example.Instance.mCyli.GetDouble(DbAttribute.GetDbAttribute("DIAM")); //Propagate rules Example.Instance.mCyli.SetAttribute(DbAttribute.GetDbAttribute("DIAM"), 1000.0F); Example.Instance.mCyli.PropagateRules(DbAttribute.GetDbAttribute("DIAM")); //Claim/Release Example.Instance.mEqui.Claim(); bool claimed = Example.Instance.mEqui.GetBool(DbAttribute.GetDbAttribute("LCLM")); //release equi MDB.CurrentMDB.SaveWork("Save Example"); Example.Instance.mEqui.Release(); claimed = Example.Instance.mEqui.GetBool(DbAttribute.GetDbAttribute("LCLM")); //Claim hierarchy try { Example.Instance.mEqui.ClaimHierarchy(); } catch (PdmsException ex) { } claimed = Example.Instance.mEqui.GetBool(DbAttribute.GetDbAttribute("LCLMH")); //release all equi Example.Instance.mEqui.ReleaseHierarchy(); claimed = Example.Instance.mEqui.GetBool(DbAttribute.GetDbAttribute("LCLM")); //change type string stype = Example.Instance.mTee.GetElementType().ToString(); Example.Instance.mTee.ChangeType(DbElementType.GetElementType("OLET")); stype = Example.Instance.mTee.GetElementType().ToString(); //UDA at default string special = "Test UDA"; DbAttribute uda = DbAttribute.GetDbAttribute(":SPECIAL"); if (uda != null) { Example.Instance.mElbo.SetAttribute(uda, special); special = Example.Instance.mElbo.GetString(uda); bool dflt = Example.Instance.mElbo.AtDefault(uda); //is one element above another in the hierarchy bool result = Example.Instance.mSite.IsDescendant(Example.Instance.mZone); result = Example.Instance.mZone.IsDescendant(Example.Instance.mSite); //Set uda to default Example.Instance.mElbo.SetAttributeDefault(uda); special = Example.Instance.mElbo.GetString(uda); dflt = Example.Instance.mElbo.AtDefault(uda); } }
private void CreateSpecification(string connstr, string query, string dept) { OdbcConnection conn = new OdbcConnection(connstr); OdbcCommand cmd = new OdbcCommand(query, conn); DataTable dt = new DataTable(); OdbcDataAdapter da = new OdbcDataAdapter(cmd); da.Fill(dt); string comp_ref_query = "select * from STD_PDST_COMP_REF_AM"; cmd.CommandText = comp_ref_query; DataTable comp_ref_dt = new DataTable(); da.SelectCommand = cmd; da.Fill(comp_ref_dt); DbElement Outfit_Elements = MDB.CurrentMDB.GetFirstWorld(Aveva.Pdms.Database.DbType.Catalogue); DbElementType[] dbtype = new DbElementType[] { DbElementTypeInstance.SPWLD }; TypeFilter filter = new TypeFilter(dbtype); AndFilter finalfilter = new AndFilter(); AttributeStringFilter filter2 = new AttributeStringFilter(DbAttribute.GetDbAttribute("Description"), FilterOperator.Equals, "HMD_PIPE_SPEC"); finalfilter.Add(filter); finalfilter.Add(filter2); DBElementCollection spwl_collects = new DBElementCollection(Outfit_Elements, finalfilter); Console.WriteLine("스펙갯수:" + spwl_collects.Cast <DbElement>().Count()); //dt.Rows.OfType<DataRow>().Where(x => x[1].ToString() == "WB").Count(); //dt.Rows.OfType<DataRow>().GroupBy(x=>x[11].ToString()) //var xx =spwl_collects.Cast<DbElement>().Where(x => x.GetAsString(DbAttributeInstance.NAME).Substring(0, 2) == "AA"); int speccnt = 0; List <DbElement> working_dbelement = new List <DbElement>(); var system_analysis = dt.Rows.OfType <DataRow>().GroupBy(x => x["LINE_NO"], x => x["NOM_DIA"], (lineno, nomdia) => new { lineno, nomdia }).OrderBy(x => x.lineno.ToString()); int cnt = 0; foreach (var lineno in system_analysis) { cnt++; //if (cnt == 3) // break; //스펙생성부분 //DbElement spec_element = DbElement.GetElement("/PROJ_SPWL").CreateAfter(DbElementTypeInstance.SPECIFICATION); string specname = dept + "." + lineno.lineno.ToString().Replace(' ', '.'); DbElement spec_element = null; if (DbElement.GetElement("/" + specname).IsNull) { spec_element = DbElement.GetElement("/PROJ_SPWL").CreateLast(DbElementTypeInstance.SPECIFICATION); spec_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname); spec_element.SetAttribute(DbAttributeInstance.QUES, "TYPE"); spec_element.SetAttribute(DbAttributeInstance.PURP, "PIPE"); spec_element.SetAttribute(DbAttributeInstance.DESC, "PROJ.SPEC"); } try { //SPEC TEXT 추가 DbElement spectext_element = spec_element.CreateLast(DbElementTypeInstance.TEXT); spectext_element.SetAttribute(DbAttributeInstance.NAME, "/" + specname + "." + "PIPINGTEXT"); spectext_element.SetAttribute(DbAttributeInstance.STEX, "PIPING"); spectext_element.SetAttribute(DbAttributeInstance.RTEX, "PIPING"); } catch (Exception ee) { } try { foreach (var nomdia in lineno.nomdia) { //Aveva.Pdms.Utilities.Messaging.PdmsException. Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |size: {0} |", nomdia.ToString())).RunInPdms(); DataRow[] targetrow = dt.Rows.OfType <DataRow>().Where(row => row["LINE_NO"].ToString() == lineno.lineno.ToString() && row["NOM_DIA"].ToString() == nomdia.ToString()).ToArray(); string press = targetrow[0]["PRESS"].ToString(); string temp = targetrow[0]["TEMP"].ToString(); string matlspec = targetrow[0]["MATL_SPEC"].ToString(); string connspec = targetrow[0]["PIPE_C_TYPE"].ToString() + "/" + targetrow[0]["PIPE_C_STD"].ToString() + "/" + targetrow[0]["PIPE_C_MATL"].ToString(); connspec = connspec.Replace("\n", ""); string valvespec = targetrow[0]["VALVE_C_TYPE"].ToString(); DataRow[] matl_datarow = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == matlspec).ToArray(); DataRow[] conn_datarow = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == connspec).ToArray(); DataRow[] valve_datarow = comp_ref_dt.Rows.Cast <DataRow>().Where(row => row[0].ToString() == valvespec).ToArray(); List <int> diameters = get_dias(nomdia.ToString()); //Material Spec생성 if (matl_datarow.Count() == 0) { //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError(); Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} material ref 없음|", matlspec)).RunInPdms(); } else { //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError(); DbElement material_spec = DbElement.GetElement(matl_datarow[0][1].ToString()); string[] allowtype = new string[] { "ELBO" };// foreach (DbElement element in material_spec.Members()) { if (element.GetElementType().ToString() != "TEXT") { //if (!allowtype.Contains(element.GetAsString(DbAttributeInstance.TANS))) // continue; //Aveva.Pdms.Utilities.CommandLine.Command.OutputAndClearError(); reculsive_copy_spec(spec_element, element, specname, diameters); } } } //Conn spec 생성 if (conn_datarow.Count() == 0) { Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} conn ref 없음|", connspec)).RunInPdms(); } else { //Gasket 생성 DbElement gask_spec = null; if (connspec.Contains("5K")) { gask_spec = DbElement.GetElement("/POGASASF05/HMDP_SPEC"); } else if (connspec.Contains("10K")) { gask_spec = DbElement.GetElement("/POGASASF10/HMDP_SPEC"); } else if (connspec.Contains("16K")) { gask_spec = DbElement.GetElement("/POGASASF16/HMDP_SPEC"); } else if (connspec.Contains("20K")) { gask_spec = DbElement.GetElement("/POGASASF20/HMDP_SPEC"); } else if (connspec.Contains("30K")) { gask_spec = DbElement.GetElement("/POGASASF30/HMDP_SPEC"); } foreach (DbElement element in gask_spec.Members()) { reculsive_copy_spec(spec_element, element, specname, diameters); } //Flange Spec DbElement conn_spec = DbElement.GetElement(conn_datarow[0][1].ToString()); foreach (DbElement element in conn_spec.Members()) { reculsive_copy_spec(spec_element, element, specname, diameters); } } //Valve Spec생성 if (valve_datarow.Count() == 0) { Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} valve ref 없음|", valvespec).Replace("\n", "")).RunInPdms(); } else { DbElement valve_spec = DbElement.GetElement(valve_datarow[0][1].ToString()); foreach (DbElement element in valve_spec.Members()) { reculsive_copy_spec(spec_element, element, specname, diameters); } } //DbElement conn_spec = DbElement.GetElement("/PFSF30/HMDP_SPEC"); //DbElement valve_spec = DbElement.GetElement("/PVVVV10/HMDP_SPEC"); //Select 생성 } } catch (Exception ee) { Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} 오륭", "11")).RunInPdms(); Console.WriteLine("오류:" + ee.Message); } //break; } Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |뻥뻥2|")).RunInPdms(); //MDB.CurrentMDB.SaveWork("스펙생성"); //CurrentElement.Element.Copy(DbElement.GetElement("/ACCOM.(DF)")); //DbElement de = CurrentElement.Element.Clone(); //지정된 Element 뒤에 object생성하는 부분 //DbElement xx= CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION); //xx.SetAttribute(DbAttributeInstance.NAME, "/바보야4"); //새로운 Element를 만들고 다른object의 하위구조를 모두 복사하는 부분. //DbElement xx = CurrentElement.Element.CreateAfter(DbElementTypeInstance.SPECIFICATION); //DbCopyOption op=new DbCopyOption(); //op.ToName="vvd"; ////DbElement yy= DbElement.GetElement("/ALDJSAFKL"); //xx.CopyHierarchy(DbElement.GetElement("/ALDJSAFKL"),op); //DbCopyOption op = new DbCopyOption(); // ALDJSAFKL을 복사하는데 /xxx 다음에 만들어서 복사한다. //DbElement yy= DbElement.GetElement("/ALDJSAFKL").CreateCopyHierarchyAfter(DbElement.GetElement("/xxx"), op); //테스트가 필요하네요 //삭제 //DbElement.GetElement("/xxx").Delete(); //Rename //DbElement.GetElement("/보바").SetAttribute(DbAttributeInstance.NAME, "/보바1"); //CurrentElement.Element.Copy(DbElement.GetElement("/보바1")); //MDB.CurrentMDB.SaveWork("여기는 테스트1"); // //foreach (DbElement element in spwl_collects) //{ // //element.Delete(); // DbCopyOption dd= new DbCopyOption(); // //dd.ToName="/bbboa"; // //DbElement de= element.CreateCopyHierarchyAfter(CurrentElement.Element, dd); // //de.InsertBefore(CurrentElement.Element); // //DbElement xx=DbElement.GetElement("/ACCOM.(DF)"); // CurrentElement.Element.InsertAfterLast(xx); // //de.InsertAfterLast(element.Owner); // ////Console.WriteLine("스펙월드]" + spwl.GetAsString(DbAttributeInstance.NAME)); // //foreach (DbElement spec in spwl.Members()) // //{ // // //spec.CreateLast(DbElementType.GetElementType("Sele")); // // string specname = spec.GetAsString(DbAttributeInstance.NAME); // // if (specname.Substring(1, 2) == "/*") // // continue; // // working_dbelement.Add(spec); // // speccnt++; // // //Console.WriteLine(" -->스펙]"+spec.GetAsString(DbAttributeInstance.NAME)); // //} //} //MDB.CurrentMDB.GetWork(); }
public void reculsive_copy_spec(DbElement owner, DbElement copy_from_element, string specname, List <int> diameters) { try { int ddepth = copy_from_element.GetInteger(DbAttributeInstance.DDEP); DbElementType copy_from_type = copy_from_element.GetElementType(DbAttributeInstance.TYPE); if (copy_from_type == DbElementTypeInstance.TEXT) { return; } string copy_from_name = copy_from_element.GetAsString(DbAttributeInstance.NAME); string tanswer = copy_from_element.GetAsString(DbAttributeInstance.TANS); //if (copy_from_type == DbElementTypeInstance.SPCOMPONENT) //return; //if (ddepth == 6) // return; DbElement sel = null; if (ddepth == 3) //comp 타입 결정 { string type_name = "/" + specname + "." + tanswer; try { var selobj = owner.Members().Where(x => x.GetAsString(DbAttributeInstance.NAME) == type_name); if (selobj.Count() == 0) { sel = owner.CreateLast(copy_from_type); sel.SetAttribute(DbAttributeInstance.NAME, type_name); sel.Copy(copy_from_element); } else { sel = selobj.First(); } foreach (DbElement org in copy_from_element.Members()) { reculsive_copy_spec(sel, org, specname, diameters); } } catch (Exception ee) { Console.WriteLine("해당 Selec는 존재하기에 오류남"); Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} Selec는 존재하기에 오류남222|", type_name)).RunInPdms(); } } else { if (ddepth == 4) { int size = Convert.ToInt32(copy_from_element.GetAsString(DbAttributeInstance.ANSW).Replace("mm", "")); if (!diameters.Contains(size)) { return; } //if (size != 32) Console.WriteLine("11"); } //sel = owner.CreateLast(DbElementTypeInstance.SELEC); if (tanswer.Contains("JOINT-MITRE") || tanswer.Contains("JOINT-THREAD")) { return; } if (copy_from_name == "/PPPG40S/HMDP_SPEC/PEPG409SS-25") { //return; Console.WriteLine("11"); } sel = owner.CreateLast(copy_from_type); if (copy_from_type == DbElementTypeInstance.SPCOMPONENT) { //spco이름 세팅 try { sel.SetAttribute(DbAttributeInstance.NAME, "/" + specname + copy_from_element.GetAsString(DbAttributeInstance.CATR).Replace("-SCOM", "")); }catch (Exception ee) { } try { sel.SetAttribute(DbAttributeInstance.CMPR, copy_from_element.GetElement(DbAttributeInstance.CMPR)); } catch (Exception ee) { } try { sel.SetAttribute(DbAttributeInstance.CATR, copy_from_element.GetElement(DbAttributeInstance.CATR)); } catch (Exception ee) { } try { sel.SetAttribute(DbAttributeInstance.DETR, copy_from_element.GetElement(DbAttributeInstance.DETR)); } catch (Aveva.Pdms.Utilities.Messaging.PdmsException ee) { } try { sel.SetAttribute(DbAttributeInstance.PRTREF, copy_from_element.GetElement(DbAttributeInstance.PRTREF)); }catch (Exception ee) { } try { sel.SetAttribute(DbAttributeInstance.TANS, copy_from_element.GetAsString(DbAttributeInstance.TANS)); } catch (Exception ee) { } } else { sel.Copy(copy_from_element); } foreach (DbElement org in copy_from_element.Members()) { reculsive_copy_spec(sel, org, specname, diameters); } } } catch (Exception ee) { Aveva.Pdms.Utilities.CommandLine.Command.CreateCommand(string.Format("$p |{0} any is wrong|", "--")).RunInPdms(); } //DbCopyOption op = new DbCopyOption(); //sel.CopyHierarchy(copy_from_element, op); //reculsive_copy_spec() }