xBimTeam / XbimExchange

XbimExchange contains several COBie schemas and serialisation functions as well as the Model Validation library adopted by theNBS digital toolkit.
https://xbimteam.github.io/
Other
46 stars 41 forks source link

Some COBie properties showing empty #10

Closed chirdeeptomar closed 7 years ago

chirdeeptomar commented 8 years ago

I have an Ifc file parser to extract data out of an IFC file. Some of the cobie data is not extracted when I am sure the data is available and Xbim xpolorer is showing the data.

AssetIdentifier, InstallationDate etc...

   public class IfcFileParser : IFileParser
    {
        private readonly Logger _logger = new Logger(nameof(IfcFileParser));

        public event EventHandler<COBieDataEventArgs> COBieDataExtracted;

        public void Parse(string userId, string filePath, Guid projectId, Guid versionNumber, bool isRevision)
        {
            var xbimDatabase = GetXbimDatabase(filePath, ".xbim");

            var model = GetXbimModel(filePath, xbimDatabase, true);

            model.Open(xbimDatabase, XbimDBAccess.Exclusive);

            var context = new COBieContext
            {
                Model = model,
            };

            var builder = new COBieBuilder(context);          

            var components = Task.Factory.StartNew(() => COBieExtractor.ExtractComponent(builder.Workbook), TaskCreationOptions.LongRunning);

            Task.WaitAll(
                components,
               );

        model.Dispose();

        var components = components.Result;

        }

        private static string GetXbimDatabase(string file, string extension)
        {
            return Path.ChangeExtension(file, extension);
        }

        private static XbimModel GetXbimModel(string inFileName, string xbimDb, bool caching)
        {
            var model = new XbimModel();

            if (SupportedFormat.IsIfc(inFileName))
            {
                model.CreateFrom(
                    inFileName,
                    xbimDb,
                    null, false, caching
                    );
                return model;
            }
            if (SupportedFormat.IsXbim(inFileName))
            {
                return model;
            }
            throw new UnsupportedFormatException(
                $"XbimConvert does not support {Path.GetExtension(inFileName)} file formats currently");
        }
    }
internal static IEnumerable<Component> ExtractComponent(COBieWorkbook newbook)
        {
            var sheet = newbook[6] as COBieSheet<COBieComponentRow>;
            return sheet?.Rows.Select(row => new Component
            {
                Id = Guid.NewGuid(),
                CreatedOn = row.CreatedOn,
                CreatedBy = row.CreatedBy,
                Description = row.Description,
                Name = row.Name,
                ExtObject = row.ExtObject,
                ExtSystem = row.ExtSystem,
                ExtIdentifier = row.ExtIdentifier,
                TypeName = row.TypeName,
                Space = row.Space,
                SerialNumber = row.SerialNumber,
                InstallationDate = row.InstallationDate,
                WarrantyStartDate = row.WarrantyStartDate,
                TagNumber = row.TagNumber,
                BarCode = row.BarCode,
                AssetIdentifier = row.AssetIdentifier,
            }).ToList();
        }

Any clue what I am doing wrong?

SteveLockley commented 7 years ago

Please use the latest version on Develop and look at the Pas1192 example for how to call the Cobie engine