Exemplo n.º 1
0
        public DBElementCollection ElementCollectionOfZones()
        {
            TypeFilter            zoneFilter  = new TypeFilter(DbElementTypeInstance.ZONE);
            AttributeStringFilter valueFilter = new AttributeStringFilter(DbAttributeInstance.FUNC, FilterOperator.Equals, "modelcatalogue");

            AndFilter af = new AndFilter(zoneFilter, valueFilter);

            DBElementCollection zones = new DBElementCollection(DbType.Design, af);

            foreach (DbElement item in zones)
            {
                Console.WriteLine(item.GetAsString(DbAttributeInstance.FUNC));
            }
            Console.WriteLine(zones.Count());
            return(zones);
        }
Exemplo 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);
        }