コード例 #1
0
        public virtual void ToSql(int ProjectId)//.........................................................
        {
            new ifcSQL.ifcInstance.Entity_Row(GlobalEntityInstanceId: this.ifcSqlGlobalId, EntityTypeId: this.SqlTypeId());
            ifcSqlInstance.cp.Entity.Add(new ifcSQL.ifcInstance.Entity_Row(GlobalEntityInstanceId: this.ifcSqlGlobalId, EntityTypeId: this.SqlTypeId()));
            ifcSqlInstance.cp.EntityInstanceIdAssignment.Add(new ifcSQL.ifcProject.EntityInstanceIdAssignment_Row(ProjectId: ProjectId, ProjectEntityInstanceId: this.LocalId, GlobalEntityInstanceId: this.ifcSqlGlobalId));


            if (this is EntityComment)
            {
                ifcSqlInstance.cp.EntityAttributeOfString.Add(new ifcSQL.ifcInstance.EntityAttributeOfString_Row(GlobalEntityInstanceId: this.ifcSqlGlobalId, OrdinalPosition: -1, TypeId: -2, Value: ((EntityComment)this).CommentLine));
            }
            else if (this.EndOfLineComment != null)
            {
                ifcSqlInstance.cp.EntityAttributeOfString.Add(new ifcSQL.ifcInstance.EntityAttributeOfString_Row(GlobalEntityInstanceId: this.ifcSqlGlobalId, OrdinalPosition: -1, TypeId: -2, Value: this.EndOfLineComment));
            }


            if (this is CartesianPoint)
            {
                double X = 0; double Y = 0; double?Z = null;
                if (((CartesianPoint)this).Coordinates.Count > 1)
                {
                    X = (double)((CartesianPoint)this).Coordinates[0]; Y = (double)((CartesianPoint)this).Coordinates[1];
                }
                if (((CartesianPoint)this).Coordinates.Count > 2)
                {
                    Z = (double)((CartesianPoint)this).Coordinates[2];
                }
                ifcSqlInstance.cp.EntityAttributeOfVector.Add(new ifcSQL.ifcInstance.EntityAttributeOfVector_Row(this.ifcSqlGlobalId, 1, 25, X, Y, Z));
            }
            else if (this is Direction)
            {
                double X = 0; double Y = 0; double?Z = null;
                if (((Direction)this).DirectionRatios.Count > 1)
                {
                    X = (double)((Direction)this).DirectionRatios[0]; Y = (double)((Direction)this).DirectionRatios[1];
                }
                if (((Direction)this).DirectionRatios.Count > 2)
                {
                    Z = (double)((Direction)this).DirectionRatios[2];
                }
                ifcSqlInstance.cp.EntityAttributeOfVector.Add(new ifcSQL.ifcInstance.EntityAttributeOfVector_Row(this.ifcSqlGlobalId, 1, 42, X, Y, Z));
            }
            else
            {
                AttribListType AttribList = TypeDictionary.GetComponents(this.GetType()).AttribList; Console.WriteLine(this.ToStepLine());
                foreach (AttribInfo attrib in AttribList)
                {
                    SqlOut0(this.ifcSqlGlobalId, attrib.OrdinalPosition, attrib.field.GetValue(this));
                }
            }
        }//....................................................................................................................
コード例 #2
0
        }//------------------------------------------------------------------------------------------------

        public virtual string ToStepLine()//--------------------------------------------------------------
        {
            string         s          = this.IfcId() + "=IFC" + this.GetType().Name.ToUpper() + "(";
            AttribListType AttribList = TypeDictionary.GetComponents(this.GetType()).AttribList;
            int            sep        = 0; foreach (AttribInfo attrib in AttribList)

            {
                s += ((++sep > 1)?",":"") + StepAttributeOut(attrib.field.GetValue(this), attrib);
            }

            s += ");";
            if (EndOfLineComment != null)
            {
                s += "/* " + EndOfLineComment + " */";
            }
            return(s);
        } //------------------------------------------------------------------------------------------------
コード例 #3
0
        public virtual string ToCs(Model CurrentModel)
        {
            Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            string s = "";

            string ElementName        = this.GetType().ToString();//.Replace("IFC4","ifc");
            int    ElementNameMaxSize = 35;

            if (ElementName.Length < ElementNameMaxSize)
            {
                ElementName += new string(' ', ElementNameMaxSize - ElementName.Length);
            }
            int IdStringMaxSize = ElementNameMaxSize + 4;

            string IdString = EntityVarName(this.LocalId, CurrentModel);

            if (IdString.Length < IdStringMaxSize)
            {
                IdString += new string(' ', IdStringMaxSize - IdString.Length);
            }

            if (this is ifc.EntityComment)
            {
                s = new string(' ', IdStringMaxSize) + "     new " + ElementName + "(";
            }
            else
            {
                s = "var " + IdString + "=new " + ElementName + "(";
            }
            int VarInsert = s.Length;

            if (VarInsert < 4)
            {
                VarInsert = 4;
            }
            if (VarInsert > 3)
            {
                VarInsert -= 3;
            }
            bool CR = true;

            if (this.GetType() == typeof(ifc.CartesianPoint))
            {//-------------------------------------------------------------------------------------------
                ifc.CartesianPoint p = (ifc.CartesianPoint) this; CR = false;
                s += "x:" + p.x + ",y:" + p.y; if (p.Coordinates.Count > 2)
                {
                    s += ",z:" + p.z;
                }
            }//-------------------------------------------------------------------------------------------
            else
            if (this.GetType() == typeof(ifc.Direction))
            {//-------------------------------------------------------------------------------------------
                ifc.Direction p = (ifc.Direction) this; CR = false;
                s += "x:" + p.x + ",y:" + p.y; if (p.DirectionRatios.Count > 2)
                {
                    s += ",z:" + p.z;
                }
            }    //-------------------------------------------------------------------------------------------
            else //-------------------------------------------------------------------------------------------

            {
                AttribListType AttribList = TypeDictionary.GetComponents(this.GetType()).AttribList;
                int            sep        = 0; foreach (AttribInfo attrib in AttribList)//bool optional=((ifcAttribute)field.GetCustomAttributes(inherit:(true))[0]).optional;
                {
                    bool Cmt = attrib.optional; if (CsOut(attrib.field.GetValue(this), CurrentModel) != "null")
                    {
                        Cmt = false;
                    }
                    s += ((++sep > 1)?"\r\n" + new string(' ', VarInsert) + (Cmt?"//,":"  ,"):"") + attrib.field.Name + ":" + CsOut(attrib.field.GetValue(this), CurrentModel);
                    s += "// #" + attrib.OrdinalPosition;                           //((ifcAttribute)field.GetCustomAttributes(inherit:(true))[0]).OrdinalPosition;
                    if (attrib.optional)
                    {
                        s += " [optional]";
                    }
                    if (Cmt)
                    {
                        s += " (" + attrib.field.FieldType.ToString() + ")";
                    }
                }
            }//-------------------------------------------------------------------------------------------

            if (this.EndOfLineComment != null)
            {
                if (this.EndOfLineComment.Length > 0)
                {
                    s += "\r\n" + new string(' ', VarInsert) + "  ,EndOfLineComment:" + "\"" + this.EndOfLineComment + "\"";
                }
            }
            if (this is ifc.EntityComment)
            {
                s += "\"" + ((ifc.EntityComment) this).CommentLine.TrimEnd(' ') + '"'; CR = false;
            }
            if (CR)
            {
                s += "\r\n" + new string(' ', VarInsert + 2);
            }
            return(s += ");");// //#"+(this.SortPos);
        }