本文整理汇总了C#中Revit.IFC.Export.Utility.ProductWrapper.GetAllObjects方法的典型用法代码示例。如果您正苦于以下问题:C# ProductWrapper.GetAllObjects方法的具体用法?C# ProductWrapper.GetAllObjects怎么用?C# ProductWrapper.GetAllObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revit.IFC.Export.Utility.ProductWrapper
的用法示例。
在下文中一共展示了ProductWrapper.GetAllObjects方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportElementClassifications
private static void ExportElementClassifications(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
foreach (IFCAnyHandle prodHnd in productSet)
{
// No need to check the subtype since Classification can be assigned to IfcRoot
// if (IFCAnyHandleUtil.IsSubTypeOf(prodHnd, IFCEntityType.IfcElement))
ClassificationUtil.CreateClassification(exporterIFC, file, element, prodHnd);
}
transaction.Commit();
}
}
示例2: ExportElementQuantities
/// <summary>
/// Exports the IFC element quantities.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element ">The element whose quantities are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportElementQuantities(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
Document doc = element.Document;
ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
IList<IList<QuantityDescription>> quantitiesToCreate = ExporterCacheManager.ParameterCache.Quantities;
foreach (IList<QuantityDescription> currStandard in quantitiesToCreate)
{
foreach (QuantityDescription currDesc in currStandard)
{
foreach (IFCAnyHandle prodHnd in productSet)
{
if (currDesc.IsAppropriateType(prodHnd))
{
IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);
HashSet<IFCAnyHandle> quantities = currDesc.ProcessEntries(file, exporterIFC, ifcParams, element, elemType);
if (quantities.Count > 0)
{
string paramSetName = currDesc.Name;
string methodName = currDesc.MethodOfMeasurement;
IFCAnyHandle propertySet = IFCInstanceExporter.CreateElementQuantity(file, GUIDUtil.CreateGUID(), ownerHistory, paramSetName, methodName, null, quantities);
IFCAnyHandle prodHndToUse = prodHnd;
DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
if (ifcRDC != null)
{
IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, element);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
prodHndToUse = overrideHnd;
}
HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
relatedObjects.Add(prodHndToUse);
IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, relatedObjects, propertySet);
}
}
}
}
}
transaction.Commit();
}
}
示例3: ExportPsetDraughtingFor2x2
/// <summary>
/// Exports Pset_Draughting for IFC 2x2 standard.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element ">The element whose properties are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportPsetDraughtingFor2x2(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string catName = CategoryUtil.GetCategoryName(element);
Color color = CategoryUtil.GetElementColor(element);
HashSet<IFCAnyHandle> nameAndColorProps = new HashSet<IFCAnyHandle>();
nameAndColorProps.Add(PropertyUtil.CreateLabelPropertyFromCache(file, null, "Layername", catName, PropertyValueType.SingleValue, true, null));
//color
{
HashSet<IFCAnyHandle> colorProps = new HashSet<IFCAnyHandle>();
colorProps.Add(PropertyUtil.CreateIntegerPropertyFromCache(file, "Red", color.Red, PropertyValueType.SingleValue));
colorProps.Add(PropertyUtil.CreateIntegerPropertyFromCache(file, "Green", color.Green, PropertyValueType.SingleValue));
colorProps.Add(PropertyUtil.CreateIntegerPropertyFromCache(file, "Blue", color.Blue, PropertyValueType.SingleValue));
string propertyName = "Color";
nameAndColorProps.Add(IFCInstanceExporter.CreateComplexProperty(file, propertyName, null, propertyName, colorProps));
}
string name = "Pset_Draughting"; // IFC 2x2 standard
IFCAnyHandle propertySet2 = IFCInstanceExporter.CreatePropertySet(file, GUIDUtil.CreateGUID(), ownerHistory, name, null, nameAndColorProps);
HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>(productWrapper.GetAllObjects());
IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, relatedObjects, propertySet2);
transaction.Commit();
}
}
示例4: ExportElementProperties
/// <summary>
/// Exports the element properties.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element">The element whose properties are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportElementProperties(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
Document doc = element.Document;
ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;
// In some cases, like multi-story stairs and ramps, we may have the same Pset used for multiple levels.
// If ifcParams is null, re-use the property set.
ISet<string> locallyUsedGUIDs = new HashSet<string>();
IDictionary<Tuple<Element, Element, string>, IFCAnyHandle> createdPropertySets =
new Dictionary<Tuple<Element, Element, string>, IFCAnyHandle>();
IDictionary<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByPropertiesMap =
new Dictionary<IFCAnyHandle, HashSet<IFCAnyHandle>>();
foreach (IFCAnyHandle prodHnd in productSet)
{
IList<PropertySetDescription> currPsetsToCreate = GetCurrPSetsToCreate(prodHnd, psetsToCreate);
if (currPsetsToCreate.Count == 0)
continue;
ElementId overrideElementId = ExporterCacheManager.HandleToElementCache.Find(prodHnd);
Element elementToUse = (overrideElementId == ElementId.InvalidElementId) ? element : doc.GetElement(overrideElementId);
ElementType elemTypeToUse = (overrideElementId == ElementId.InvalidElementId) ? elemType : doc.GetElement(elementToUse.GetTypeId()) as ElementType;
if (elemTypeToUse == null)
elemTypeToUse = elemType;
IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);
foreach (PropertySetDescription currDesc in currPsetsToCreate)
{
// Last conditional check: if the property set comes from a ViewSchedule, check if the element is in the schedule.
if (currDesc.ViewScheduleId != ElementId.InvalidElementId)
if (!ExporterCacheManager.ViewScheduleElementCache[currDesc.ViewScheduleId].Contains(elementToUse.Id))
continue;
Tuple<Element, Element, string> propertySetKey = new Tuple<Element, Element, string>(elementToUse, elemTypeToUse, currDesc.Name);
IFCAnyHandle propertySet = null;
if ((ifcParams != null) || (!createdPropertySets.TryGetValue(propertySetKey, out propertySet)))
{
HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, ifcParams, elementToUse, elemTypeToUse);
if (props.Count > 0)
{
int subElementIndex = CheckElementTypeValidityForSubIndex(currDesc, prodHnd, element);
string guid = GUIDUtil.CreateSubElementGUID(elementToUse, subElementIndex);
if (locallyUsedGUIDs.Contains(guid))
guid = GUIDUtil.CreateGUID();
else
locallyUsedGUIDs.Add(guid);
string paramSetName = currDesc.Name;
propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
if (ifcParams == null)
createdPropertySets[propertySetKey] = propertySet;
}
}
if (propertySet != null)
{
IFCAnyHandle prodHndToUse = prodHnd;
DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
if (ifcRDC != null)
{
IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, elementToUse);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
prodHndToUse = overrideHnd;
}
HashSet<IFCAnyHandle> relatedObjects = null;
if (!relDefinesByPropertiesMap.TryGetValue(propertySet, out relatedObjects))
{
relatedObjects = new HashSet<IFCAnyHandle>();
relDefinesByPropertiesMap[propertySet] = relatedObjects;
}
relatedObjects.Add(prodHndToUse);
}
}
}
foreach (KeyValuePair<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByProperties in relDefinesByPropertiesMap)
{
IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null,
relDefinesByProperties.Value, relDefinesByProperties.Key);
//.........这里部分代码省略.........
示例5: ExportAsMappedItem
private static void ExportAsMappedItem(ExporterIFC exporterIFC, Element element, IFCFile file, IFCExportType exportType, string ifcEnumType, IFCExtrusionCreationData extraParams,
PlacementSetter setter, IFCAnyHandle localPlacementToUse, IFCAnyHandle productRepresentation, ProductWrapper productWrapper)
{
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
ElementId typeId = element.GetTypeId();
ElementType type = element.Document.GetElement(typeId) as ElementType;
IFCAnyHandle styleHandle = null;
if (type != null)
{
FamilyTypeInfo currentTypeInfo = ExporterCacheManager.TypeObjectsCache.Find(typeId, false, exportType);
bool found = currentTypeInfo.IsValid();
if (!found)
{
string typeGUID = GUIDUtil.CreateGUID(type);
string typeName = NamingUtil.GetIFCName(type);
string typeObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, type);
string applicableOccurance = NamingUtil.GetObjectTypeOverride(type, typeObjectType);
string typeDescription = NamingUtil.GetDescriptionOverride(type, null);
string typeElemId = NamingUtil.CreateIFCElementId(type);
HashSet<IFCAnyHandle> propertySetsOpt = new HashSet<IFCAnyHandle>();
IList<IFCAnyHandle> repMapListOpt = new List<IFCAnyHandle>();
styleHandle = FamilyExporterUtil.ExportGenericType(exporterIFC, exportType, ifcEnumType, typeGUID, typeName,
typeDescription, applicableOccurance, propertySetsOpt, repMapListOpt, typeElemId, typeName, element, type);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(styleHandle))
{
currentTypeInfo.Style = styleHandle;
ExporterCacheManager.TypeObjectsCache.Register(typeId, false, exportType, currentTypeInfo);
}
}
else
{
styleHandle = currentTypeInfo.Style;
}
}
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetIFCName(element);
string objectType = NamingUtil.CreateIFCObjectName(exporterIFC, element);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, objectType);
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceElemId = NamingUtil.CreateIFCElementId(element);
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
bool roomRelated = !FamilyExporterUtil.IsDistributionFlowElementSubType(exportType);
ElementId roomId = ElementId.InvalidElementId;
if (roomRelated)
{
roomId = setter.UpdateRoomRelativeCoordinates(element, out localPlacementToUse);
}
IFCAnyHandle instanceHandle = null;
// For MEP objects
string exportEntityStr = exportType.ToString();
Common.Enums.IFCEntityType exportEntity;
if (String.Compare(exportEntityStr.Substring(exportEntityStr.Length - 4), "Type", true) == 0)
exportEntityStr = exportEntityStr.Substring(0, (exportEntityStr.Length - 4));
if (Enum.TryParse(exportEntityStr, out exportEntity))
{
// For MEP object creation
instanceHandle = IFCInstanceExporter.CreateGenericIFCEntity(exportEntity, file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(instanceHandle))
return;
if (roomId != ElementId.InvalidElementId)
{
//exporterIFC.RelateSpatialElement(roomId, instanceHandle);
ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomId, instanceHandle);
productWrapper.AddElement(element, instanceHandle, setter, extraParams, false);
}
else
{
productWrapper.AddElement(element, instanceHandle, setter, extraParams, true);
}
OpeningUtil.CreateOpeningsIfNecessary(instanceHandle, element, extraParams, null, exporterIFC, localPlacementToUse, setter, productWrapper);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(styleHandle))
ExporterCacheManager.TypeRelationsCache.Add(styleHandle, instanceHandle);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper.GetAllObjects());
ExporterCacheManager.MEPCache.Register(element, instanceHandle);
// add to system export cache
// SystemExporter.ExportSystem(exporterIFC, element, instanceHandle);
}