private IFCType GetIfcType(string path) { IFCType result = IFCType.None; IntPtr ifcModel = ifcEngine.OpenModelUnicode(IntPtr.Zero, path, Constants.IFC2X3_SCHEMA_NAME); if (ifcModel != IntPtr.Zero) { ifcEngine.GetSPFFHeaderItem(ifcModel, 9, 0, IfcEngine.SdaiType.String, out IntPtr outputValue); string headerItem = Marshal.PtrToStringAnsi(outputValue); if (!string.IsNullOrEmpty(headerItem)) { if (headerItem.Contains(IFCType.IFC2.ToString())) { result = IFCType.IFC2; } else if (headerItem.Contains(IFCType.IFC4.ToString())) { result = IFCType.IFC4; } } ifcEngine.CloseModel(ifcModel); } return(result); }
public void closeModel() { if (!IntPtr.Zero.Equals(_ifcModel)) { //close model _ifcEngine.CloseModel(_ifcModel); } }
private bool ParseIfcFile(string sPath) { if (File.Exists(sPath)) { IntPtr ifcModel = _ifcEngine.OpenModel(IntPtr.Zero, sPath, "IFC2X3_TC1.exp"); string xmlSettings_IFC2x3 = @"IFC2X3-Settings.xml"; string xmlSettings_IFC4 = @"IFC4-Settings.xml"; if (ifcModel != IntPtr.Zero) { IntPtr outputValue = IntPtr.Zero; _ifcEngine.GetSPFFHeaderItem(ifcModel, 9, 0, IfcEngine.SdaiType.String, out outputValue); string s = Marshal.PtrToStringAnsi(outputValue); XmlTextReader textReader = null; if (string.IsNullOrEmpty(s) || s.Contains("IFC2")) { textReader = new XmlTextReader(xmlSettings_IFC2x3); } else if (s.Contains("IFC4")) { _ifcEngine.CloseModel(ifcModel); ifcModel = _ifcEngine.OpenModel(IntPtr.Zero, sPath, "IFC4.exp"); if (ifcModel != IntPtr.Zero) { textReader = new XmlTextReader(xmlSettings_IFC4); } } if (textReader == null) { return(false); } // if node type us an attribute while (textReader.Read()) { textReader.MoveToElement(); if (textReader.AttributeCount > 0) { if (textReader.LocalName == "object") { if (textReader.GetAttribute("name") != null) { string Name = textReader.GetAttribute("name").ToString(); //string Desc = textReader.GetAttribute("description").ToString(); RetrieveObjects(ifcModel, Name, Name); } } } } int a = 0; GenerateGeometry(ifcModel, _rootIfcItem, ref a); // Generate Tree Control _treeData.BuildTree(this, ifcModel, _rootIfcItem, _treeControl); _ifcEngine.CloseModel(ifcModel); return(true); } } return(false); }