本文整理汇总了C#中ExporterIFC.SetOwnerHistoryHandle方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.SetOwnerHistoryHandle方法的具体用法?C# ExporterIFC.SetOwnerHistoryHandle怎么用?C# ExporterIFC.SetOwnerHistoryHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.SetOwnerHistoryHandle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginExport
/// <summary>
/// Initializes the common properties at the beginning of the export process.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="document">The document to export.</param>
private void BeginExport(ExporterIFC exporterIFC, Document document)
{
ExporterCacheManager.Document = document;
String writeIFCExportedElementsVar = Environment.GetEnvironmentVariable("WriteIFCExportedElements");
if (writeIFCExportedElementsVar != null && writeIFCExportedElementsVar.Length > 0)
{
m_Writer = new StreamWriter(@"c:\ifc-output-filters.txt");
}
IFCFileModelOptions modelOptions = new IFCFileModelOptions();
if (exporterIFC.ExportAs2x2)
{
modelOptions.SchemaFile = Path.Combine(ExporterUtil.RevitProgramPath, "EDM\\IFC2X2_ADD1.exp");
modelOptions.SchemaName = "IFC2x2_FINAL";
}
else
{
modelOptions.SchemaFile = Path.Combine(ExporterUtil.RevitProgramPath, "EDM\\IFC2X3_TC1.exp");
modelOptions.SchemaName = "IFC2x3";
}
m_IfcFile = IFCFile.Create(modelOptions);
exporterIFC.SetFile(m_IfcFile);
//init common properties
ExporterInitializer.InitPropertySets(ExporterCacheManager.ExportOptionsCache.FileVersion);
ExporterInitializer.InitQuantities(ExporterCacheManager.ExportOptionsCache.FileVersion, ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities);
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
// create building
IFCAnyHandle applicationHandle = CreateApplicationInformation(file, document.Application);
CreateGlobalCartesianOrigin(exporterIFC);
CreateGlobalDirection(exporterIFC);
CreateGlobalDirection2D(exporterIFC);
IFCAnyHandle units = CreateDefaultUnits(exporterIFC, document);
// Start out relative to nothing, but replace with site later.
IFCAnyHandle relativePlacement = ExporterUtil.CreateAxis2Placement3D(file);
IFCAnyHandle buildingPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement);
HashSet<IFCAnyHandle> repContexts = CreateContextInformation(exporterIFC, document);
IFCAnyHandle ownerHistory = CreateGenericOwnerHistory(exporterIFC, document, applicationHandle);
exporterIFC.SetOwnerHistoryHandle(ownerHistory);
IFCAnyHandle projectHandle = IFCInstanceExporter.CreateProject(file,
ExporterIFCUtils.CreateProjectLevelGUID(document, IFCProjectLevelGUIDType.Project), ownerHistory,
null, null, null, null, null, repContexts, units);
exporterIFC.SetProject(projectHandle);
ProjectInfo projInfo = document.ProjectInformation;
string projectAddress = projInfo != null ? projInfo.Address : String.Empty;
SiteLocation siteLoc = document.ActiveProjectLocation.SiteLocation;
string location = siteLoc != null ? siteLoc.PlaceName : String.Empty;
if (projectAddress == null)
projectAddress = String.Empty;
if (location == null)
location = String.Empty;
IFCAnyHandle buildingAddress = CreateIFCAddress(file, projectAddress, location);
string buildingName = String.Empty;
if (projInfo != null)
{
try
{
buildingName = projInfo.BuildingName;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
}
}
IFCAnyHandle buildingHandle = IFCInstanceExporter.CreateBuilding(file,
ExporterIFCUtils.CreateProjectLevelGUID(document, IFCProjectLevelGUIDType.Building),
ownerHistory, buildingName, null, null, buildingPlacement, null, buildingName,
Toolkit.IFCElementComposition.Element, null, null, buildingAddress);
exporterIFC.SetBuilding(buildingHandle);
// create levels
List<Level> levels = LevelUtil.FindAllLevels(document);
bool exportAllLevels = true;
for (int ii = 0; ii < levels.Count && exportAllLevels; ii++)
{
Level level = levels[ii];
Parameter isBuildingStorey = level.get_Parameter(BuiltInParameter.LEVEL_IS_BUILDING_STORY);
if (isBuildingStorey == null || (isBuildingStorey.AsInteger() != 0))
{
exportAllLevels = false;
break;
//.........这里部分代码省略.........
示例2: CreateProject
/// <summary>
/// Creates the IfcProject.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="doc">The document provides the owner information.</param>
/// <param name="application">The handle of IFC file to create the owner history.</param>
private void CreateProject(ExporterIFC exporterIFC, Document doc, IFCAnyHandle application)
{
string familyName;
string givenName;
List<string> middleNames;
List<string> prefixTitles;
List<string> suffixTitles;
string author = String.Empty;
ProjectInfo projectInfo = doc.ProjectInformation;
if (projectInfo != null)
{
try
{
author = projectInfo.Author;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
//if failed to get author from project info, try to get the username from application later.
}
}
if (String.IsNullOrEmpty(author))
{
author = doc.Application.Username;
}
NamingUtil.ParseName(author, out familyName, out givenName, out middleNames, out prefixTitles, out suffixTitles);
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle telecomAddress = GetTelecomAddressFromExtStorage(file, doc);
IList<IFCAnyHandle> telecomAddresses = null;
if (telecomAddress != null)
{
telecomAddresses = new List<IFCAnyHandle>();
telecomAddresses.Add(telecomAddress);
}
IFCAnyHandle person = IFCInstanceExporter.CreatePerson(file, null, familyName, givenName, middleNames,
prefixTitles, suffixTitles, null, telecomAddresses);
string organizationName = String.Empty;
string organizationDescription = String.Empty;
if (projectInfo != null)
{
try
{
organizationName = projectInfo.OrganizationName;
organizationDescription = projectInfo.OrganizationDescription;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
}
}
int creationDate = (int) GetCreationDate(doc);
IFCAnyHandle organization = IFCInstanceExporter.CreateOrganization(file, null, organizationName, organizationDescription,
null, null);
IFCAnyHandle owningUser = IFCInstanceExporter.CreatePersonAndOrganization(file, person, organization, null);
IFCAnyHandle ownerHistory = IFCInstanceExporter.CreateOwnerHistory(file, owningUser, application, null,
Toolkit.IFCChangeAction.NoChange, null, null, null, creationDate);
exporterIFC.SetOwnerHistoryHandle(ownerHistory);
// Getting contact information from Revit extensible storage that COBie extension tool creates
GetCOBieContactInfo(file, doc);
IFCAnyHandle units = CreateDefaultUnits(exporterIFC, doc);
HashSet<IFCAnyHandle> repContexts = CreateContextInformation(exporterIFC, doc);
// As per IFC implementer's agreement, we get IfcProject.Name from ProjectInfo.Number and IfcProject.Longname from ProjectInfo.Name
string projectName = (projectInfo != null) ? projectInfo.Number : null;
string projectLongName = (projectInfo != null) ? projectInfo.Name :null;
// Get project description if it is set in the Project info
string projectObjectType = (projectInfo != null) ? NamingUtil.GetObjectTypeOverride(projectInfo, null) : null;
string projectDescription = (projectInfo != null) ? NamingUtil.GetDescriptionOverride(projectInfo, null) : null;
string projectPhase = null;
if (projectInfo != null)
ParameterUtil.GetStringValueFromElement(projectInfo.Id, "Project Phase", out projectPhase);
string projectGUID = GUIDUtil.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Project);
IFCAnyHandle projectHandle = IFCInstanceExporter.CreateProject(file, projectGUID, ownerHistory,
projectName, projectDescription, projectObjectType, projectLongName, projectPhase, repContexts, units);
exporterIFC.SetProject(projectHandle);
if (ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE)
{
HashSet<IFCAnyHandle> projectHandles = new HashSet<IFCAnyHandle>();
projectHandles.Add(projectHandle);
//.........这里部分代码省略.........
示例3: CreateProject
/// <summary>
/// Creates the IfcProject.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="doc">The document provides the owner information.</param>
/// <param name="application">The handle of IFC file to create the owner history.</param>
private void CreateProject(ExporterIFC exporterIFC, Document doc, IFCAnyHandle application)
{
string familyName;
string givenName;
List<string> middleNames;
List<string> prefixTitles;
List<string> suffixTitles;
string author = String.Empty;
ProjectInfo projInfo = doc.ProjectInformation;
if (projInfo != null)
{
try
{
author = projInfo.Author;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
//if failed to get author from project info, try to get the username from application later.
}
}
if (String.IsNullOrEmpty(author))
{
author = doc.Application.Username;
}
NamingUtil.ParseName(author, out familyName, out givenName, out middleNames, out prefixTitles, out suffixTitles);
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle person = IFCInstanceExporter.CreatePerson(file, null, familyName, givenName, middleNames,
prefixTitles, suffixTitles, null, null);
string organizationName = String.Empty;
string organizationDescription = String.Empty;
if (projInfo != null)
{
try
{
organizationName = projInfo.OrganizationName;
organizationDescription = projInfo.OrganizationDescription;
}
catch (Autodesk.Revit.Exceptions.InvalidOperationException)
{
}
}
int creationDate = (int) GetCreationDate(doc);
IFCAnyHandle organization = IFCInstanceExporter.CreateOrganization(file, null, organizationName, organizationDescription,
null, null);
IFCAnyHandle owningUser = IFCInstanceExporter.CreatePersonAndOrganization(file, person, organization, null);
IFCAnyHandle ownerHistory = IFCInstanceExporter.CreateOwnerHistory(file, owningUser, application, null,
Toolkit.IFCChangeAction.NoChange, null, null, null, creationDate);
exporterIFC.SetOwnerHistoryHandle(ownerHistory);
IFCAnyHandle units = CreateDefaultUnits(exporterIFC, doc);
HashSet<IFCAnyHandle> repContexts = CreateContextInformation(exporterIFC, doc);
// find project description
string projectDescription = NamingUtil.GetDescriptionOverride(projInfo, null);
IFCAnyHandle projectHandle = IFCInstanceExporter.CreateProject(file,
GUIDUtil.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Project), ownerHistory,
null, projectDescription, null, null, null, repContexts, units);
exporterIFC.SetProject(projectHandle);
if (ExporterCacheManager.ExportOptionsCache.FileVersion == IFCVersion.IFCCOBIE)
{
HashSet<IFCAnyHandle> projectHandles = new HashSet<IFCAnyHandle>();
projectHandles.Add(projectHandle);
string clientName = projInfo != null ? projInfo.ClientName : String.Empty;
IFCAnyHandle clientOrg = IFCInstanceExporter.CreateOrganization(file, null, clientName, null, null, null);
IFCAnyHandle actor = IFCInstanceExporter.CreateActor(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, null, clientOrg);
IFCInstanceExporter.CreateRelAssignsToActor(file, GUIDUtil.CreateGUID(), ownerHistory, "Project Client/Owner", null, projectHandles, null, actor, null);
IFCAnyHandle architectActor = IFCInstanceExporter.CreateActor(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, null, person);
IFCInstanceExporter.CreateRelAssignsToActor(file, GUIDUtil.CreateGUID(), ownerHistory, "Project Architect", null, projectHandles, null, architectActor, null);
}
}