public static void UpdateElementTransform(IfcStore _model, string projectNumber, string projectName) { DBOperation.beginTransaction(); DBOperation.commitInterval = 5000; string currStep = string.Empty; BIMRLCommon _refBIMRLCommon = new BIMRLCommon(); int commandStatus = -1; int currInsertCount = 0; OracleCommand command = new OracleCommand(" ", DBOperation.DBConn); XbimMatrix3D m3D = new XbimMatrix3D(); if (string.IsNullOrEmpty(projectName)) { projectName = projectNumber + " - Federated"; } string modelName; if (!string.IsNullOrEmpty(_model.FileName)) { modelName = Path.GetFileNameWithoutExtension(_model.FileName); } else { modelName = projectNumber + " - " + projectName; } command.CommandText = "SELECT FEDERATEDID FROM bimrl_federatedmodel WHERE MODELNAME = '" + modelName + "' AND PROJECTNUMBER='" + projectNumber + "' AND PROJECTNAME='" + projectName + "'"; object oFedID = command.ExecuteScalar(); if (oFedID == null) { return; } int fedID = int.Parse(oFedID.ToString()); command.CommandText = "SELECT ELEMENTID, LINENO FROM " + DBOperation.formatTabName("bimrl_element", fedID) + " WHERE GEOMETRYBODY IS NOT NULL"; OracleDataReader reader = command.ExecuteReader(); SortedDictionary <int, string> elemList = new SortedDictionary <int, string>(); while (reader.Read()) { string elemid = reader.GetString(0); int lineNo = reader.GetInt32(1); elemList.Add(lineNo, elemid); } reader.Close(); Xbim3DModelContext context = new Xbim3DModelContext(_model); foreach (KeyValuePair <int, string> elemListItem in elemList) { //IEnumerable<XbimGeometryData> geomDataList = _model.GetGeometryData(elemListItem.Key, XbimGeometryType.TriangulatedMesh); IIfcProduct product = _model.Instances[elemListItem.Key] as IIfcProduct; IEnumerable <XbimShapeInstance> shapeInstances = context.ShapeInstancesOf(product).Where(x => x.RepresentationType == XbimGeometryRepresentationType.OpeningsAndAdditionsIncluded); if (shapeInstances.Count() == 0) { continue; // SKip if the product has no geometry } XbimMeshGeometry3D prodGeom = new XbimMeshGeometry3D(); IXbimShapeGeometryData shapeGeom = context.ShapeGeometry(shapeInstances.FirstOrDefault().ShapeGeometryLabel); //XbimModelExtensions.Read(prodGeom, shapeGeom.ShapeData, shapeInstances.FirstOrDefault().Transformation); //XbimGeometryData sdoGeomData = geomDataList.First(); //m3D = sdoGeomData.Transform; //m3D = XbimMatrix3D.FromArray(sdoGeomData.DataArray2); // Xbim 3.0 removes Tranform property m3D = shapeInstances.FirstOrDefault().Transformation; string sqlStmt = "update " + DBOperation.formatTabName("BIMRL_ELEMENT", fedID) + " set TRANSFORM_COL1=:1, TRANSFORM_COL2=:2, TRANSFORM_COL3=:3, TRANSFORM_COL4=:4" + " Where elementid = '" + elemListItem.Value + "'"; // int status = DBOperation.updateGeometry(sqlStmt, sdoGeomData); currStep = sqlStmt; command.CommandText = sqlStmt; try { OracleParameter[] sdoGeom = new OracleParameter[4]; for (int i = 0; i < sdoGeom.Count(); ++i) { sdoGeom[i] = command.Parameters.Add((i + 1).ToString(), OracleDbType.Object); sdoGeom[i].Direction = ParameterDirection.Input; sdoGeom[i].UdtTypeName = "MDSYS.SDO_GEOMETRY"; sdoGeom[i].Size = 1; } SdoGeometry trcol1 = new SdoGeometry(); trcol1.Dimensionality = 3; trcol1.LRS = 0; trcol1.GeometryType = (int)SdoGeometryTypes.GTYPE.POINT; int gType = trcol1.PropertiesToGTYPE(); SdoPoint trcol1V = new SdoPoint(); trcol1V.XD = m3D.M11; trcol1V.YD = m3D.M12; trcol1V.ZD = m3D.M13; trcol1.SdoPoint = trcol1V; sdoGeom[1].Value = trcol1; SdoGeometry trcol2 = new SdoGeometry(); trcol2.Dimensionality = 3; trcol2.LRS = 0; trcol2.GeometryType = (int)SdoGeometryTypes.GTYPE.POINT; gType = trcol2.PropertiesToGTYPE(); SdoPoint trcol2V = new SdoPoint(); trcol2V.XD = m3D.M21; trcol2V.YD = m3D.M22; trcol2V.ZD = m3D.M23; trcol2.SdoPoint = trcol2V; sdoGeom[2].Value = trcol2; SdoGeometry trcol3 = new SdoGeometry(); trcol3.Dimensionality = 3; trcol3.LRS = 0; trcol3.GeometryType = (int)SdoGeometryTypes.GTYPE.POINT; gType = trcol3.PropertiesToGTYPE(); SdoPoint trcol3V = new SdoPoint(); trcol3V.XD = m3D.M31; trcol3V.YD = m3D.M32; trcol3V.ZD = m3D.M33; trcol3.SdoPoint = trcol3V; sdoGeom[3].Value = trcol3; SdoGeometry trcol4 = new SdoGeometry(); trcol4.Dimensionality = 3; trcol4.LRS = 0; trcol4.GeometryType = (int)SdoGeometryTypes.GTYPE.POINT; gType = trcol4.PropertiesToGTYPE(); SdoPoint trcol4V = new SdoPoint(); trcol4V.XD = m3D.OffsetX; trcol4V.YD = m3D.OffsetY; trcol4V.ZD = m3D.OffsetZ; trcol4.SdoPoint = trcol4V; sdoGeom[4].Value = trcol4; commandStatus = command.ExecuteNonQuery(); command.Parameters.Clear(); currInsertCount++; if (currInsertCount % DBOperation.commitInterval == 0) { //Do commit at interval but keep the long transaction (reopen) DBOperation.commitTransaction(); } } catch (OracleException e) { string excStr = "%%Error - " + e.Message + "\n\t" + currStep; _refBIMRLCommon.StackPushError(excStr); //command.Dispose(); // Log Oracle error and continue command = new OracleCommand(" ", DBOperation.DBConn); // throw; } catch (SystemException e) { string excStr = "%%Insert Error - " + e.Message + "\n\t" + currStep; _refBIMRLCommon.StackPushError(excStr); throw; } DBOperation.commitTransaction(); command.Dispose(); } }