コード例 #1
0
 public void Write(XbimModel model, TextWriter output, IDictionary<int, int> map = null)
 {
     _written = new HashSet<long>();
     output.Write(HeaderAsString(model.Header ?? new IfcFileHeader(IfcFileHeader.HeaderCreationMode.InitWithXbimDefaults)));
     foreach (XbimInstanceHandle item in model.InstanceHandles /*.Types.OrderBy(t=>t.Name)*/)
     {
         IPersistIfcEntity entity = model.GetInstanceVolatile(item);
         entity.WriteEntity(output, map);
     }
     output.WriteLine("ENDSEC;");
     output.WriteLine("END-ISO-10303-21;");
 }
コード例 #2
0
 public void Write(XbimModel model, TextWriter output, IDictionary <int, int> map = null)
 {
     _written = new HashSet <long>();
     output.Write(HeaderAsString(model.Header ?? new IfcFileHeader(IfcFileHeader.HeaderCreationMode.InitWithXbimDefaults)));
     foreach (XbimInstanceHandle item in model.InstanceHandles /*.Types.OrderBy(t=>t.Name)*/)
     {
         IPersistIfcEntity entity = model.GetInstanceVolatile(item);
         entity.WriteEntity(output, map);
     }
     output.WriteLine("ENDSEC;");
     output.WriteLine("END-ISO-10303-21;");
 }
コード例 #3
0
        private void Write(XbimModel model, int handle, XmlWriter output, int pos = -1)
        {
            if (_written.Contains(handle)) //we have already done it
            {
                return;
            }
            //int nextId = _written.Count + 1;
            _written.Add(handle);

            IPersistIfcEntity entity  = model.GetInstanceVolatile(handle); //load either the cache or a volatile version of the entity
            IfcType           ifcType = IfcMetaData.IfcType(entity);

            output.WriteStartElement(ifcType.Type.Name);

            output.WriteAttributeString("id", string.Format("i{0}", handle));
            if (pos > -1) //we are writing out a list element
            {
                output.WriteAttributeString("pos", pos.ToString());
            }

            IEnumerable <IfcMetaProperty> toWrite;

            if (WriteInverses)
            {
                List <IfcMetaProperty> l = new List <IfcMetaProperty>(ifcType.IfcProperties.Values);
                l.AddRange(ifcType.IfcInverses);
                toWrite = l;
            }
            else
            {
                toWrite = ifcType.IfcProperties.Values;
            }

            foreach (IfcMetaProperty ifcProperty in toWrite) //only write out persistent attributes, ignore inverses
            {
                if (ifcProperty.IfcAttribute.State != IfcAttributeState.DerivedOverride)
                {
                    Type   propType = ifcProperty.PropertyInfo.PropertyType;
                    object propVal  = ifcProperty.PropertyInfo.GetValue(entity, null);

                    WriteProperty(model, ifcProperty.PropertyInfo.Name, propType, propVal, entity, output, -1,
                                  ifcProperty.IfcAttribute);
                }
            }
            output.WriteEndElement();
        }
コード例 #4
0
        private void Write(XbimModel model, int handle, XmlWriter output, int pos = -1)
        {

            if (_written.Contains(handle)) //we have already done it
                return;
            //int nextId = _written.Count + 1;
            _written.Add(handle);

            IPersistIfcEntity entity = model.GetInstanceVolatile(handle); //load either the cache or a volatile version of the entity
            IfcType ifcType = IfcMetaData.IfcType(entity);

            output.WriteStartElement(ifcType.Type.Name);
            
            output.WriteAttributeString("id", string.Format("i{0}", handle));
            if (pos > -1) //we are writing out a list element
                output.WriteAttributeString("pos", pos.ToString());
            
            IEnumerable<IfcMetaProperty> toWrite;
            if (WriteInverses)
            {
                List<IfcMetaProperty> l = new List<IfcMetaProperty>(ifcType.IfcProperties.Values);
                l.AddRange(ifcType.IfcInverses);
                toWrite = l;
            }
            else
            {
                toWrite = ifcType.IfcProperties.Values;
            }
            
            foreach (IfcMetaProperty ifcProperty in toWrite) //only write out persistent attributes, ignore inverses
            {
                if (ifcProperty.IfcAttribute.State != IfcAttributeState.DerivedOverride)
                {
                    Type propType = ifcProperty.PropertyInfo.PropertyType;
                    object propVal = ifcProperty.PropertyInfo.GetValue(entity, null);

                    WriteProperty(model, ifcProperty.PropertyInfo.Name, propType, propVal, entity, output, -1,
                                  ifcProperty.IfcAttribute);
                }
            }
            output.WriteEndElement();
        }