public void init(string ifcFile, string ifcSchema) { _ifcEngine = new IfcEngine(); _ifcModel = _ifcEngine.OpenModel(IntPtr.Zero, ifcFile, ifcSchema); ifcProp2IfcPropType = new Dictionary <string, string>(); ifcProp2IfcPropValueType = new Dictionary <string, string>(); ifcPropSetTypeByIfcPropType = new Dictionary <string, string>(); ifcElemntContainerTypeByIfcPropType = new Dictionary <string, string>(); ifcProp2IfcPropType.Add("NetVolume", "IfcQuantityVolume"); ifcProp2IfcPropValueType.Add("NetVolume", "VolumeValue"); ifcProp2IfcPropType.Add("Weight", "IfcPropertySingleValue"); ifcProp2IfcPropValueType.Add("Weight", "NominalValue"); ifcProp2IfcPropType.Add("Profile", "IfcPropertySingleValue"); ifcProp2IfcPropValueType.Add("Profile", "NominalValue"); ifcPropSetTypeByIfcPropType.Add("IfcQuantityVolume", "IfcElementQuantity"); ifcPropSetTypeByIfcPropType.Add("IfcPropertySingleValue", "IfcPropertySet"); ifcElemntContainerTypeByIfcPropType.Add("IfcElementQuantity", "Quantities"); ifcElemntContainerTypeByIfcPropType.Add("IfcPropertySet", "hasProperties"); #region commented Oleg' code //if (!String.Empty.Equals(ifcFilePath)) //{ // _ifcEngine = new IfcEngine(); // path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); // // open model // _ifcModel = _ifcEngine.OpenModel(IntPtr.Zero, @ifcFilePath, @String.Concat(path, @"/IFC2X3_TC1.exp")); // if (IntPtr.Zero.Equals(_ifcModel)) // { // throw new Exception("Error: incorrect file name"); // } //} //else //{ // throw new Exception("Error: incorrect file name"); //} #endregion }
public void init(String ifcFilePath) { if (!String.Empty.Equals(ifcFilePath)) { _ifcEngine = new IfcEngine(); path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); // open model _ifcModel = _ifcEngine.OpenModel(IntPtr.Zero, @ifcFilePath, @String.Concat(path, @"/IFC2X3_TC1.exp")); if (IntPtr.Zero.Equals(_ifcModel)) { throw new Exception("Error: incorrect file name"); } } else { throw new Exception("Error: incorrect file name"); } }
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); }