Exemplo n.º 1
0
        public string AddNewSite(string currentFilename, string siteCode, string siteDescription, string siteStreet, string sitePostalCode, string siteTown, string siteCountry)
        {
            if (Current.Documents.ContainsKey(currentFilename))
            {
                Ifc4.IfcSite ifcSite = Current.Documents[currentFilename].Project.Sites.AddNewSite();
                ifcSite.GlobalId    = Ifc4.GlobalId.ConvertToIfcGuid(Guid.NewGuid());
                ifcSite.Name        = siteCode;
                ifcSite.LongName    = siteDescription;
                ifcSite.Description = siteCode;

                siteStreet     = SetString(siteStreet);
                sitePostalCode = SetString(sitePostalCode);
                siteTown       = SetString(siteTown);
                siteCountry    = SetString(siteCountry);

                var ifcPostalAddress = (from item in Current.Documents[currentFilename].IfcXmlDocument.Items.OfType <Ifc4.IfcPostalAddress>()
                                        where
                                        item.AddressLines != null &&
                                        item.AddressLines.IfcLabelwrapper.Any() &&
                                        item.AddressLines.IfcLabelwrapper[0].Value == siteStreet &&
                                        item.Town.Equals(siteTown) &&
                                        item.PostalCode.Equals(sitePostalCode)
                                        select item).FirstOrDefault();

                if (ifcPostalAddress == null)
                {
                    ifcPostalAddress = new Ifc4.IfcPostalAddress()
                    {
                        Id = Current.Documents[currentFilename].GetNextSid()
                    };

                    ifcPostalAddress.AddressLines = new Ifc4.IfcPostalAddressAddressLines();
                    ifcPostalAddress.AddressLines.IfcLabelwrapper.Add(new Ifc4.IfcLabelwrapper()
                    {
                        Value = siteStreet
                    });
                    ifcPostalAddress.Town       = siteTown;
                    ifcPostalAddress.PostalCode = sitePostalCode;
                    ifcPostalAddress.Country    = siteCountry;

                    Current.Documents[currentFilename].IfcXmlDocument.Items.Add(ifcPostalAddress);
                }
                ifcSite.SiteAddress = new Ifc4.IfcPostalAddress()
                {
                    Ref = ifcPostalAddress.Id
                };
                return(ifcSite.GlobalId);
            }

            return(null);
        }
Exemplo n.º 2
0
        public override bool Remove()
        {
            bool result = true;

            IfcPostalAddress ifcPostalAddress = this.BuildingAddress;

            if (ifcPostalAddress != null && ifcPostalAddress.IsRef)
            {
                ifcPostalAddress = this.Document.IfcXmlDocument.Items.OfType <IfcPostalAddress>().FirstOrDefault(item => item.Id == ifcPostalAddress.Ref);
            }

            if (ifcPostalAddress != null)
            {
                result = ifcPostalAddress.Remove();
            }

            result &= base.Remove();
            return(result);
        }
Exemplo n.º 3
0
        private bool InternalCreateCafmConnectTestFile(string ifcFullName)
        {
            string schemaFullName;

            Ifc4.Document document;

            // create new ifc file
            document = Ifc4.Workspace.CurrentWorkspace.CreateDocument(ifcFullName, true);
            document.MessageLogged += document_MessageLogged;

            // add project info
            document.Project.GlobalId    = document.GetNewGlobalId();
            document.Project.Name        = "CEBP";
            document.Project.LongName    = "Cologne, Ehrenfelder Business Park";
            document.Project.Description = "Ehrenfelder Business Park";

            Ifc4.IfcSite           site;
            Ifc4.IfcBuilding       building;
            Ifc4.IfcBuildingStorey buildingStorey;
            Ifc4.IfcSpace          space;

            // --------------------------------------------------------------------------
            site             = document.Project.Sites.AddNewSite();
            site.Name        = "CEBP01";
            site.LongName    = "Cologne, Ehrenfelder Tower";
            site.Description = "Cologne Ehrenfelder Tower";


            for (int nBuilding = 0; nBuilding < 10; nBuilding++) // buildings
            {
                building             = site.Buildings.AddNewBuilding();
                building.Name        = String.Format("Site:{0} Building:{1}", "1", nBuilding);
                building.LongName    = "Tower 01";
                building.Description = "Tower 01";

                for (int nStorey = 0; nStorey < 10; nStorey++) // storeys
                {
                    buildingStorey      = building.BuildingStoreys.AddNewBuildingStorey();
                    buildingStorey.Name = String.Format("Storey:{0}", nStorey);

                    for (int nSpace = 0; nSpace < 10; nSpace++) // rooms
                    {
                        space      = buildingStorey.Spaces.AddNewSpace();
                        space.Name = String.Format("Storey:{0} Space:{1}", nStorey, nSpace);
                    }
                }
            }

            IfcPostalAddress postalAddress;

            postalAddress = new IfcPostalAddress();
            postalAddress.AddressLines = new IfcPostalAddressAddressLines();
            postalAddress.AddressLines.IfcLabelwrapper = new List <IfcLabelwrapper>();
            postalAddress.AddressLines.IfcLabelwrapper.Add(new IfcLabelwrapper()
            {
                Value = "eTASK Headquarter Wilhelm-Ruppert-Straße 38 Gebäude K15"
            });

            postalAddress.Id         = document.GetNextSid();
            postalAddress.Region     = "NRW";
            postalAddress.Town       = "Cologne";
            postalAddress.Country    = "Germany";
            postalAddress.PostalCode = "51147";

            document.IfcXmlDocument.Items.Add(postalAddress);

            postalAddress = new IfcPostalAddress();
            postalAddress.AddressLines = new IfcPostalAddressAddressLines();
            postalAddress.AddressLines.IfcLabelwrapper = new List <IfcLabelwrapper>();
            postalAddress.AddressLines.IfcLabelwrapper.Add(new IfcLabelwrapper()
            {
                Value = "Joachim Vollberg\r\nHadersleber Str. 28\r\n50825 Köln"
            });

            postalAddress.Id         = document.GetNextSid();
            postalAddress.Region     = "NRW";
            postalAddress.Town       = "Cologne";
            postalAddress.Country    = "Germany";
            postalAddress.PostalCode = "50825";

            document.IfcXmlDocument.Items.Add(postalAddress);

            try
            {
                document.Save(new SaveOptions());
                document.Close();
                return(true);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine(exc.Message);
                Exception innerException = exc.InnerException;
                while (innerException != null)
                {
                    RaiseMessageLogged(innerException.Message);
                    innerException = innerException.InnerException;
                }
                return(false);
            }
            finally
            {
                document.MessageLogged -= document_MessageLogged;
            }
        }