Ejemplo n.º 1
0
        /// <summary>
        /// Writes full model into output writer as STEP21 file
        /// </summary>
        /// <param name="model">Model to be serialized</param>
        /// <param name="output">Output writer</param>
        /// <param name="metadata">Metadata to be used for serialization</param>
        /// <param name="map">Optional map can be used to map occurrences in the file</param>
        private void Write(TextWriter output)
        {
            ExpressMetaData metadata       = Metadata;
            var             header         = Header ?? new StepFileHeader(StepFileHeader.HeaderCreationMode.InitWithXbimDefaults, this);
            string          fallBackSchema = EntityFactory.SchemasIds.FirstOrDefault();

            if (!header.FileSchema.Schemas.Any())
            {
                foreach (var id in EntityFactory.SchemasIds)
                {
                    header.FileSchema.Schemas.Add(id);
                }
            }

            Part21Writer.WriteHeader(header, output, fallBackSchema);

            foreach (var entity in Instances)
            {
                if (_comments.TryGetValue(entity.EntityLabel, out string comment))
                {
                    comment = comment.Trim('\r', '\n');
                    comment = comment.Replace("\r\n", "\r\n* ");
                    output.WriteLine();
                    output.WriteLine($"/**");
                    output.WriteLine("* " + comment);
                    output.WriteLine($"* {GetMetaComment(entity)}*/");
                }
                Part21Writer.WriteEntity(entity, output, metadata, null);
                output.WriteLine();
            }
            Part21Writer.WriteFooter(output);
        }
Ejemplo n.º 2
0
        public static void Save(TextWriter writer, IModel model)
        {
            Part21Writer.WriteHeader(model.Header, writer, "IFC4");
            var metadata = model.Metadata;

            foreach (var instance in model.Instances)
            {
                WriteEntity(instance, writer, metadata);
            }
            Part21Writer.WriteFooter(writer);
        }