Class XbimExtract 项目中无法识别 IfcStore
Class IfcStore not recognized in XbimExtract project
我正在尝试将 Xbim Extract project 用于我正在处理的应用程序。但是,Visual Studio 在一些 class 下用红色下划线表示找不到它们。我设法解决了一些错误,例如我输入了:
using Xbim.XbimExtensions.Interfaces;
所以 ReportProgressDelegate
不再有下划线。 但是,我找不到要为 IfcStore
导入的包。这是完整的代码:
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
using log4net.Config;
using Xbim.Common;
using Xbim.Ifc;
using Xbim.XbimExtensions.Interfaces;
using System.Collections.Generic;
using Xbim.IO;
using Xbim.ModelGeometry.Scene;
using Xbim.Common.Logging;
using Xbim.Ifc2x3.Kernel;
using Xbim.Common.Exceptions;
using Xbim.Common.Geometry;
using Xbim.Ifc2x3.ProductExtension;
using Xbim.XbimExtensions.Interfaces;
namespace XbimExtract
{
class Program
{
public static ILog Logger = LogManager.GetLogger(typeof(Program));
private static readonly string ApplicationName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
public static string AppName
{
get { return ApplicationName; }
}
static void Main(string[] args)
{
XmlConfigurator.Configure();
Logger.InfoFormat("{0} Started", AppName);
var arguments = Params.ParseParams(args);
if (arguments.IsValid)
{
try
{
ReportProgressDelegate progDelegate = delegate(int percentProgress, object userState)
{
Console.Write("{0:D5}", percentProgress);
ResetCursor(Console.CursorTop);
};
using (var source = IfcStore.Open(arguments.SourceModelName))
{
Logger.InfoFormat("Reading {0}", arguments.SourceModelName);
Logger.InfoFormat("Extracting and copying to " + arguments.TargetModelName);
using (var target = IfcStore.Create(source.IfcSchemaVersion, XbimStoreType.InMemoryModel))
{
var maps = new XbimInstanceHandleMap(source, target); //prevents the same thing being written twice
using (var txn = target.BeginTransaction())
{
try
{
var toInsert = arguments.EntityLabels.Select(label => source.Instances[label]).ToList();
var products = toInsert.OfType<IfcProduct>().ToList();
var others = toInsert.Except(products).ToList();
if (products.Any())
target.InsertCopy(products, true, true, maps);
if (others.Any())
foreach (var entity in others)
target.InsertCopy(entity, maps, null, false, true);
}
catch (Exception)
{
Logger.Error("Some entity labels don't exist in the source file.");
return;
}
txn.Commit();
}
File.Delete(arguments.TargetModelName);
Logger.Info("Saving to " + arguments.TargetModelName);
target.SaveAs(arguments.TargetModelName, null, progDelegate);
Logger.Info("Success");
}
}
}
catch (Exception e)
{
Logger.FatalFormat("{0}\n{1}", e.Message, e.StackTrace);
}
}
else
{
Logger.Error("Supplied params are invalid");
}
Logger.InfoFormat("{0} Ended", AppName);
#if DEBUG
Console.WriteLine("Press any key...");
Console.ReadKey();
#endif
}
private static void ResetCursor(int top)
{
try
{
if (top >= Console.BufferHeight)
return;
Console.SetCursorPosition(0, top);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}
class IfcStore
在其存在的任何地方都带有红色下划线。我应该包括什么?
您需要将 nuget 包更新到最新版本。
Xbim.Essentials.3.1.0 没有引用包含 Xbim.Ifc 命名空间和 classes.
的 Xbim.Ifc.dll
正在更新至 Xbim.Essentials.4.0.4 添加此引用并允许您使用 IfcStore class.
我正在尝试将 Xbim Extract project 用于我正在处理的应用程序。但是,Visual Studio 在一些 class 下用红色下划线表示找不到它们。我设法解决了一些错误,例如我输入了:
using Xbim.XbimExtensions.Interfaces;
所以 ReportProgressDelegate
不再有下划线。 但是,我找不到要为 IfcStore
导入的包。这是完整的代码:
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
using log4net.Config;
using Xbim.Common;
using Xbim.Ifc;
using Xbim.XbimExtensions.Interfaces;
using System.Collections.Generic;
using Xbim.IO;
using Xbim.ModelGeometry.Scene;
using Xbim.Common.Logging;
using Xbim.Ifc2x3.Kernel;
using Xbim.Common.Exceptions;
using Xbim.Common.Geometry;
using Xbim.Ifc2x3.ProductExtension;
using Xbim.XbimExtensions.Interfaces;
namespace XbimExtract
{
class Program
{
public static ILog Logger = LogManager.GetLogger(typeof(Program));
private static readonly string ApplicationName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
public static string AppName
{
get { return ApplicationName; }
}
static void Main(string[] args)
{
XmlConfigurator.Configure();
Logger.InfoFormat("{0} Started", AppName);
var arguments = Params.ParseParams(args);
if (arguments.IsValid)
{
try
{
ReportProgressDelegate progDelegate = delegate(int percentProgress, object userState)
{
Console.Write("{0:D5}", percentProgress);
ResetCursor(Console.CursorTop);
};
using (var source = IfcStore.Open(arguments.SourceModelName))
{
Logger.InfoFormat("Reading {0}", arguments.SourceModelName);
Logger.InfoFormat("Extracting and copying to " + arguments.TargetModelName);
using (var target = IfcStore.Create(source.IfcSchemaVersion, XbimStoreType.InMemoryModel))
{
var maps = new XbimInstanceHandleMap(source, target); //prevents the same thing being written twice
using (var txn = target.BeginTransaction())
{
try
{
var toInsert = arguments.EntityLabels.Select(label => source.Instances[label]).ToList();
var products = toInsert.OfType<IfcProduct>().ToList();
var others = toInsert.Except(products).ToList();
if (products.Any())
target.InsertCopy(products, true, true, maps);
if (others.Any())
foreach (var entity in others)
target.InsertCopy(entity, maps, null, false, true);
}
catch (Exception)
{
Logger.Error("Some entity labels don't exist in the source file.");
return;
}
txn.Commit();
}
File.Delete(arguments.TargetModelName);
Logger.Info("Saving to " + arguments.TargetModelName);
target.SaveAs(arguments.TargetModelName, null, progDelegate);
Logger.Info("Success");
}
}
}
catch (Exception e)
{
Logger.FatalFormat("{0}\n{1}", e.Message, e.StackTrace);
}
}
else
{
Logger.Error("Supplied params are invalid");
}
Logger.InfoFormat("{0} Ended", AppName);
#if DEBUG
Console.WriteLine("Press any key...");
Console.ReadKey();
#endif
}
private static void ResetCursor(int top)
{
try
{
if (top >= Console.BufferHeight)
return;
Console.SetCursorPosition(0, top);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}
class IfcStore
在其存在的任何地方都带有红色下划线。我应该包括什么?
您需要将 nuget 包更新到最新版本。
Xbim.Essentials.3.1.0 没有引用包含 Xbim.Ifc 命名空间和 classes.
的 Xbim.Ifc.dll正在更新至 Xbim.Essentials.4.0.4 添加此引用并允许您使用 IfcStore class.