Ejemplo n.º 1
0
        public void Include(string equipmentName, string specNaem)
        {
            try {
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
                var builder = new Builder();
                var spec    = MDB.CurrentMDB.FindElement(DbType.Catalog, specNaem);
                var equi    = MDB.CurrentMDB.FindElement(DbType.Design, equipmentName);

                builder.Cata             = Cata.GetWritable(equi);
                builder.Cate             = new Cate();
                builder.Reader           = new Reader();
                builder.Reader.Converter = new ConvertToBuildable.Convert();

                var scom    = builder.BuildScom(equi);
                var session = builder.Reader.GetLastSessionModified(equi);
                Console.WriteLine($" sessionmod : {session}");
                var spcoInfo = new Create.SpcoRepresentation(scom, equi, builder.Text);
                spcoInfo.DefineMatxt(builder.Cata);

                var specManager = new Create.SpecManager(spec, spcoInfo.FirstSeleTans);
                specManager.AddSpco(spcoInfo);
            } catch (Exception e) {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.Source);
            }
        }
Ejemplo n.º 2
0
        public void AddSpco(SpcoRepresentation spcoRepre)
        {
            // TODO: implement better SPCO naming strategy
            Console.WriteLine("SpecManager.AddSpco");

            if (spcoRepre.Stype == string.Empty || spcoRepre.PBore1 == 0)
            {
                Console.WriteLine($"## Invalid input for:{spcoRepre.Sdte.GetString(DbAttributeInstance.DTXR)}");
                Console.WriteLine($"Stype cannot be empty and is: {spcoRepre.Stype}");
                Console.WriteLine($"Bore cannot be 0 and is : {spcoRepre.PBore1}");
                return;
            }
            var spcoName = Spec.Name() + spcoRepre.Name;

            if (spcoName.Length > 50)
            {
                spcoName = Spec.Name() + spcoRepre.Name.Substring(Spec.Name().Length);
            }
            DBElementCollection spcos = new DBElementCollection(Spec, new AttributeRefFilter(DbAttributeInstance.CATR, spcoRepre.Scom));
            DbElement           spco;

            if (spcos.Count() > 0)
            {
                spco = spcos.First();
            }
            else
            {
                spco = BoreSele(spcoRepre.PBore1).CreateLast(DbElementTypeInstance.SPCOMPONENT);
            }

            // TODO: do something much better. with the spco name. maybe stype + size + dtxr???
            try {
                spco.SetAttribute(DbAttributeInstance.NAME, spcoName);
            } catch {
                for (int i = 0; i < 100; i++)
                {
                    try {
                        spco.SetAttribute(DbAttributeInstance.NAME, spcoName + i.ToString());
                    } catch { }
                }
            }
            spco.SetAttribute(DbAttributeInstance.TANS, spcoRepre.Stype);
            spco.SetAttribute(DbAttributeInstance.CATR, spcoRepre.Scom);

            PMLCommander.RunPMLCommand(spco, "DETR", spcoRepre.Sdte.FullName(), out string error);
            PMLCommander.RunPMLCommand(spco, "MATXT", spcoRepre.Smte.FullName(), out error);
        }