本文整理汇总了C#中IFCFile类的典型用法代码示例。如果您正苦于以下问题:C# IFCFile类的具体用法?C# IFCFile怎么用?C# IFCFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFCFile类属于命名空间,在下文中一共展示了IFCFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateElectricalCurrentMeasurePropertyFromCache
/// <summary>
/// Create a label property, or retrieve from cache.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="propertyName">The name of the property.</param>
/// <param name="value">The value of the property.</param>
/// <param name="valueType">The value type of the property.</param>
/// <returns>The created or cached property handle.</returns>
public static IFCAnyHandle CreateElectricalCurrentMeasurePropertyFromCache(IFCFile file, string propertyName, double value, PropertyValueType valueType)
{
// We have a partial cache here - we will only cache multiples of 15 degrees.
bool canCache = false;
double ampsDiv5 = Math.Floor(value / 5.0 + 0.5);
double integerAmps = ampsDiv5 * 5.0;
if (MathUtil.IsAlmostEqual(value, integerAmps))
{
canCache = true;
value = integerAmps;
}
IFCAnyHandle propertyHandle;
if (canCache)
{
propertyHandle = ExporterCacheManager.PropertyInfoCache.ElectricalCurrentCache.Find(propertyName, value);
if (propertyHandle != null)
return propertyHandle;
}
propertyHandle = CreateElectricalCurrentMeasureProperty(file, propertyName, value, valueType);
if (canCache && !IFCAnyHandleUtil.IsNullOrHasNoValue(propertyHandle))
{
ExporterCacheManager.PropertyInfoCache.ElectricalCurrentCache.Add(propertyName, value, propertyHandle);
}
return propertyHandle;
}
示例2: CreateUniformatClassification
/// <summary>
/// Creates uniformat classification.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC.</param>
/// <param name="file">The file.</param>
/// <param name="element">The element.</param>
/// <param name="elemHnd">The element handle.</param>
public static void CreateUniformatClassification(ExporterIFC exporterIFC, IFCFile file, Element element, IFCAnyHandle elemHnd)
{
// Create Uniformat classification, if it is not set.
string uniformatKeyString = "Uniformat";
string uniformatCode = "";
if (ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.UNIFORMAT_CODE, false, out uniformatCode) == null)
ParameterUtil.GetStringValueFromElementOrSymbol(element, "Assembly Code", out uniformatCode);
string uniformatDescription = "";
if (!String.IsNullOrWhiteSpace(uniformatCode))
{
if (ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.UNIFORMAT_DESCRIPTION, false, out uniformatDescription) == null)
ParameterUtil.GetStringValueFromElementOrSymbol(element, "Assembly Description", out uniformatDescription);
}
IFCAnyHandle classification;
if (!ExporterCacheManager.ClassificationCache.ClassificationHandles.TryGetValue(uniformatKeyString, out classification))
{
classification = IFCInstanceExporter.CreateClassification(file, "http://www.csiorg.net/uniformat", "1998", null, uniformatKeyString);
ExporterCacheManager.ClassificationCache.ClassificationHandles.Add(uniformatKeyString, classification);
}
InsertClassificationReference(exporterIFC, file, element, elemHnd, uniformatKeyString, uniformatCode, uniformatDescription, "http://www.csiorg.net/uniformat" );
}
示例3: CreateUniformatClassification
/// <summary>
/// Creates uniformat classification.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC.</param>
/// <param name="file">The file.</param>
/// <param name="element">The element.</param>
/// <param name="elemHnd">The element handle.</param>
public static void CreateUniformatClassification(ExporterIFC exporterIFC, IFCFile file, Element element, IFCAnyHandle elemHnd)
{
// Create Uniformat classification, if it is set.
string uniformatCode = "";
if (ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.UNIFORMAT_CODE, false, out uniformatCode) ||
ParameterUtil.GetStringValueFromElementOrSymbol(element, "Assembly Code", out uniformatCode))
{
string uniformatDescription = "";
if (!ParameterUtil.GetStringValueFromElementOrSymbol(element, BuiltInParameter.UNIFORMAT_DESCRIPTION, false, out uniformatDescription))
ParameterUtil.GetStringValueFromElementOrSymbol(element, "Assembly Description", out uniformatDescription);
IFCAnyHandle classification;
if (!ExporterCacheManager.ClassificationCache.TryGetValue("UniFormat", out classification))
{
classification = IFCInstanceExporter.CreateClassification(file, "http://www.csiorg.net/uniformat", "1998", null, "UniFormat");
ExporterCacheManager.ClassificationCache.Add("UniFormat", classification);
}
IFCAnyHandle classificationReference = IFCInstanceExporter.CreateClassificationReference(file,
"http://www.csiorg.net/uniformat", uniformatCode, uniformatDescription, classification);
HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
relatedObjects.Add(elemHnd);
IFCAnyHandle relAssociates = IFCInstanceExporter.CreateRelAssociatesClassification(file, ExporterIFCUtils.CreateGUID(),
exporterIFC.GetOwnerHistoryHandle(), "UniFormatClassification", "", relatedObjects, classificationReference);
}
}
示例4: CreateAxis
/// <summary>
/// Creates IfcAxis2Placement3D object.
/// </summary>
/// <param name="file">
/// The IFC file.
/// </param>
/// <param name="origin">
/// The origin.
/// </param>
/// <param name="zDirection">
/// The Z direction.
/// </param>
/// <param name="xDirection">
/// The X direction.
/// </param>
/// <returns>
/// The handle.
/// </returns>
public static IFCAnyHandle CreateAxis(IFCFile file, XYZ origin, XYZ zDirection, XYZ xDirection)
{
IFCAnyHandle directionOpt = IFCAnyHandle.Create();
IFCAnyHandle refOpt = IFCAnyHandle.Create();
IFCAnyHandle location = IFCAnyHandle.Create();
if (origin != null)
{
IList<double> measure = new List<double>();
measure.Add(origin.X); measure.Add(origin.Y); measure.Add(origin.Z);
location = CreateCartesianPoint(file, measure);
}
else
{
location = ExporterIFCUtils.GetGlobal3DOriginHandle();
}
bool exportzDirectionAndxDirection = (zDirection != null && xDirection != null && (!MathUtil.IsAlmostEqual(zDirection[2], 1.0) || !MathUtil.IsAlmostEqual(xDirection[0], 1.0)));
if (exportzDirectionAndxDirection)
{
IList<double> axisPts = new List<double>();
axisPts.Add(zDirection.X); axisPts.Add(zDirection.Y); axisPts.Add(zDirection.Z);
directionOpt = CreateDirection(file, axisPts);
}
if (exportzDirectionAndxDirection)
{
IList<double> axisPts = new List<double>();
axisPts.Add(xDirection.X); axisPts.Add(xDirection.Y); axisPts.Add(xDirection.Z);
refOpt = CreateDirection(file, axisPts);
}
return file.CreateAxis2Placement3D(location, directionOpt, refOpt);
}
示例5: CreateFrequencyPropertyFromElement
/// <summary>
/// Create a Frequency measure property from the element's parameter.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="exporterIFC">The ExporterIFC.</param>
/// <param name="elem">The Element.</param>
/// <param name="revitParameterName">The name of the parameter.</param>
/// <param name="ifcPropertyName">The name of the property.</param>
/// <param name="valueType">The value type of the property.</param>
/// <returns>The created property handle.</returns>
public static IFCAnyHandle CreateFrequencyPropertyFromElement(IFCFile file, ExporterIFC exporterIFC, Element elem,
string revitParameterName, string ifcPropertyName, PropertyValueType valueType)
{
double propertyValue;
if (ParameterUtil.GetDoubleValueFromElement(elem, null, revitParameterName, out propertyValue) != null)
return CreateFrequencyProperty(file, ifcPropertyName, propertyValue, valueType);
return null;
}
示例6: CreateClassification
/// <summary>
///
/// </summary>
/// <param name="exporterIFC"></param>
/// <param name="file"></param>
/// <param name="element"></param>
/// <param name="elemHnd"></param>
/// <param name="location"></param>
public static void CreateClassification(ExporterIFC exporterIFC, IFCFile file, Element element, IFCAnyHandle elemHnd, string location)
{
string paramClassificationCode = "";
string classificationName = null;
string classificationCode = null;
string classificationDescription = null;
// For now the support is fixed to 10 predefined classification code parameter names (to support limitation of schedule key that supports only one category per schedule key and needs one parameter for each)
int noClassCodeParam = 10;
string [] classCodeParamName = {"ClassificationCode", "ClassificationCode(2)", "ClassificationCode(3)", "ClassificationCode(4)", "ClassificationCode(5)",
"ClassificationCode(6)", "ClassificationCode(7)", "ClassificationCode(8)", "ClassificationCode(9)", "ClassificationCode(10)"};
int ret = 0;
for (int n = 0; n < noClassCodeParam; n++)
{
// Create A classification, if it is not set.
if (ParameterUtil.GetStringValueFromElementOrSymbol(element, classCodeParamName[n], out paramClassificationCode))
{
ret = parseClassificationCode(paramClassificationCode, out classificationName, out classificationCode, out classificationDescription);
if (string.IsNullOrEmpty(classificationName))
classificationName = "Default Classification";
IFCAnyHandle classification;
if (!ExporterCacheManager.ClassificationCache.TryGetValue(classificationName, out classification))
{
IFCClassificationMgr savedClassificationFromUI = new IFCClassificationMgr();
IFCClassification savedClassification = new IFCClassification();
if (savedClassificationFromUI.GetSavedClassificationByName(element.Document, classificationName, out savedClassification))
{
if (savedClassification.ClassificationEditionDate == null)
{
IFCAnyHandle editionDate = IFCInstanceExporter.CreateCalendarDate(file, savedClassification.ClassificationEditionDate.Day, savedClassification.ClassificationEditionDate.Month, savedClassification.ClassificationEditionDate.Year);
classification = IFCInstanceExporter.CreateClassification(file, savedClassification.ClassificationSource, savedClassification.ClassificationEdition,
editionDate, savedClassification.ClassificationName);
}
else
classification = IFCInstanceExporter.CreateClassification(file, savedClassification.ClassificationSource, savedClassification.ClassificationEdition,
null, savedClassification.ClassificationName);
}
else
classification = IFCInstanceExporter.CreateClassification(file, "", "", null, classificationName);
ExporterCacheManager.ClassificationCache.Add(classificationName, classification);
if (!String.IsNullOrEmpty(savedClassification.ClassificationLocation))
ExporterCacheManager.ClassificationLocationCache.Add(classificationName, savedClassification.ClassificationLocation);
}
if (String.IsNullOrEmpty(location))
{
ExporterCacheManager.ClassificationLocationCache.TryGetValue(classificationName, out location);
}
InsertClassificationReference(exporterIFC, file, element, elemHnd, classificationName, classificationCode, classificationDescription, location);
}
}
}
示例7: CreateActor
/// <summary>
/// Creates a handle representing an IfcActor and assigns it to the file.
/// </summary>
/// <param name="file">The file.</param>
/// <param name="guid">The GUID.</param>
/// <param name="ownerHistory">The owner history.</param>
/// <param name="name">The name</param>
/// <param name="description">The description</param>
/// <param name="objectType">The object type.</param>
/// <param name="theActor">The actor.</param>
/// <returns>The handle.</returns>
public static IFCAnyHandle CreateActor(IFCFile file, string guid, IFCAnyHandle ownerHistory,
string name, string description, string objectType, IFCAnyHandle theActor)
{
ValidateActor(guid, ownerHistory, name, description, objectType, theActor);
IFCAnyHandle actorHandle = CreateInstance(file, IFCEntityType.IfcActor);
SetActor(actorHandle, guid, ownerHistory, name, description, objectType, theActor);
return actorHandle;
}
示例8: ProcessEntries
/// <summary>
/// Creates handles for the quantities.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="exporterIFC">The ExporterIFC class.</param>
/// <param name="ifcParams">The extrusion creation data, used to get extra parameter information.</param>
/// <param name="elementToUse">The base element.</param>
/// <param name="elemTypeToUse">The base element type.</param>
/// <returns>A set of quantities handles.</returns>
public HashSet<IFCAnyHandle> ProcessEntries(IFCFile file, ExporterIFC exporterIFC, IFCExtrusionCreationData ifcParams, Element elementToUse, ElementType elemTypeToUse)
{
HashSet<IFCAnyHandle> props = new HashSet<IFCAnyHandle>();
foreach (QuantityEntry entry in m_Entries)
{
IFCAnyHandle propHnd = entry.ProcessEntry(file, exporterIFC, ifcParams, elementToUse, elemTypeToUse);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(propHnd))
props.Add(propHnd);
}
return props;
}
示例9: CreateActuatorType
/// <summary>
/// Creates an IfcActuatorType, and assigns it to the file.
/// </summary>
/// <param name="file">The file.</param>
/// <param name="guid">The GUID.</param>
/// <param name="ownerHistory">The owner history.</param>
/// <param name="name">The name.</param>
/// <param name="description">The description.</param>
/// <param name="applicableOccurrence">The attribute optionally defines the data type of the occurrence object.</param>
/// <param name="propertySets">The property set(s) associated with the type.</param>
/// <param name="representationMaps">The mapped geometries associated with the type.</param>
/// <param name="elementTag">The tag that represents the entity.</param>
/// <param name="elementType">The type name.</param>
/// <param name="predefinedType">The predefined types.</param>
/// <returns>The handle.</returns>
public static IFCAnyHandle CreateActuatorType(IFCFile file, string guid, IFCAnyHandle ownerHistory, string name,
string description, string applicableOccurrence, HashSet<IFCAnyHandle> propertySets,
IList<IFCAnyHandle> representationMaps, string elementTag, string elementType, IFCActuatorType predefinedType)
{
ValidateElementType(guid, ownerHistory, name, description, applicableOccurrence, propertySets,
representationMaps, elementTag, elementType);
IFCAnyHandle actuatorType = CreateInstance(file, IFCEntityType.IfcActuatorType);
IFCAnyHandleUtil.SetAttribute(actuatorType, "PredefinedType", predefinedType);
SetElementType(actuatorType, guid, ownerHistory, name, description, applicableOccurrence, propertySets,
representationMaps, elementTag, elementType);
return actuatorType;
}
示例10: CreateElectricalCurrentMeasureProperty
/// <summary>
/// Create a label property.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="propertyName">The name of the property.</param>
/// <param name="value">The value of the property.</param>
/// <param name="valueType">The value type of the property.</param>
/// <returns>The created property handle.</returns>
public static IFCAnyHandle CreateElectricalCurrentMeasureProperty(IFCFile file, string propertyName, double value, PropertyValueType valueType)
{
switch (valueType)
{
case PropertyValueType.EnumeratedValue:
{
IList<IFCData> valueList = new List<IFCData>();
valueList.Add(IFCDataUtil.CreateAsElectricalCurrentMeasure(value));
return IFCInstanceExporter.CreatePropertyEnumeratedValue(file, propertyName, null, valueList, null);
}
case PropertyValueType.SingleValue:
return IFCInstanceExporter.CreatePropertySingleValue(file, propertyName, null, IFCDataUtil.CreateAsElectricalCurrentMeasure(value), null);
default:
throw new InvalidOperationException("Missing case!");
}
}
示例11: CreateSweptDiskSolid
private static IFCAnyHandle CreateSweptDiskSolid(ExporterIFC exporterIFC, IFCFile file, Curve centerCurve, double radius)
{
IList<Curve> curves = new List<Curve>();
double endParam = 0.0;
if (centerCurve is Arc || centerCurve is Ellipse)
{
if (centerCurve.IsBound)
endParam = (centerCurve.get_EndParameter(1) - centerCurve.get_EndParameter(0)) * 180 / Math.PI;
else
endParam = (2 * Math.PI) * 180 / Math.PI;
}
else
endParam = 1.0;
curves.Add(centerCurve);
IFCAnyHandle compositeCurve = GeometryUtil.CreateCompositeCurve(exporterIFC, curves);
return IFCInstanceExporter.CreateSweptDiskSolid(file, compositeCurve, radius, null, 0, endParam);
}
示例12: CreatePositivePlaneAngleMeasureProperty
/// <summary>
/// Create a label property.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="propertyName">The name of the property.</param>
/// <param name="value">The value of the property.</param>
/// <param name="valueType">The value type of the property.</param>
/// <returns>The created property handle.</returns>
public static IFCAnyHandle CreatePositivePlaneAngleMeasureProperty(IFCFile file, string propertyName, double value, PropertyValueType valueType)
{
// Ensure it is positive. Don't throw, but should tell user.
if (value <= MathUtil.Eps())
return null;
switch (valueType)
{
case PropertyValueType.EnumeratedValue:
{
IList<IFCData> valueList = new List<IFCData>();
valueList.Add(IFCDataUtil.CreateAsPositivePlaneAngleMeasure(value));
return IFCInstanceExporter.CreatePropertyEnumeratedValue(file, propertyName, null, valueList, null);
}
case PropertyValueType.SingleValue:
return IFCInstanceExporter.CreatePropertySingleValue(file, propertyName, null, IFCDataUtil.CreateAsPositivePlaneAngleMeasure(value), null);
default:
throw new InvalidOperationException("Missing case!");
}
}
示例13: CreateCommonProperty
protected static IFCAnyHandle CreateCommonProperty(IFCFile file, string propertyName, IFCData valueData, PropertyValueType valueType, string unitTypeKey)
{
switch (valueType)
{
case PropertyValueType.EnumeratedValue:
{
IList<IFCData> valueList = new List<IFCData>();
valueList.Add(valueData);
return IFCInstanceExporter.CreatePropertyEnumeratedValue(file, propertyName, null, valueList, null);
}
case PropertyValueType.SingleValue:
{
if (unitTypeKey != null)
return IFCInstanceExporter.CreatePropertySingleValue(file, propertyName, null, valueData, ExporterCacheManager.UnitsCache[unitTypeKey]);
else
return IFCInstanceExporter.CreatePropertySingleValue(file, propertyName, null, valueData, null);
}
default:
throw new InvalidOperationException("Missing case!");
}
}
示例14: CreateFrequencyPropertyFromElementOrSymbol
/// <summary>
/// Create a Frequency measure property from the element's or type's parameter.
/// </summary>
/// <param name="file">The IFC file.</param>
/// <param name="exporterIFC">The ExporterIFC.</param>
/// <param name="elem">The Element.</param>
/// <param name="revitParameterName">The name of the parameter.</param>
/// <param name="revitBuiltInParam">The built in parameter to use, if revitParameterName isn't found.</param>
/// <param name="ifcPropertyName">The name of the property.</param>
/// <param name="valueType">The value type of the property.</param>
/// <returns>The created property handle.</returns>
public static IFCAnyHandle CreateFrequencyPropertyFromElementOrSymbol(IFCFile file, ExporterIFC exporterIFC, Element elem,
string revitParameterName, BuiltInParameter revitBuiltInParam, string ifcPropertyName, PropertyValueType valueType)
{
IFCAnyHandle propHnd = CreateFrequencyPropertyFromElement(file, exporterIFC, elem, revitParameterName, ifcPropertyName, valueType);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(propHnd))
return propHnd;
if (revitBuiltInParam != BuiltInParameter.INVALID)
{
string builtInParamName = LabelUtils.GetLabelFor(revitBuiltInParam);
propHnd = CreateFrequencyPropertyFromElement(file, exporterIFC, elem, builtInParamName, ifcPropertyName, valueType);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(propHnd))
return propHnd;
}
// For Symbol
Document document = elem.Document;
ElementId typeId = elem.GetTypeId();
Element elemType = document.GetElement(typeId);
if (elemType != null)
return CreateFrequencyPropertyFromElementOrSymbol(file, exporterIFC, elemType, revitParameterName, revitBuiltInParam, ifcPropertyName, valueType);
else
return null;
}
示例15: CreateDefaultMappedItem
/// <summary>
/// Creates IfcMappedItem object at (0,0,0).
/// </summary>
/// <param name="file">
/// The IFC file.
/// </param>
/// <param name="repMap">
/// The handle to be mapped.
/// </param>
/// <param name="orig">
/// The orig for mapping transformation.
/// </param>
/// <returns>
/// The handle.
/// </returns>
public static IFCAnyHandle CreateDefaultMappedItem(IFCFile file, IFCAnyHandle repMap)
{
IFCAnyHandle transformHnd = ExporterCacheManager.GetDefaultCartesianTransformationOperator3D(file);
return IFCInstanceExporter.CreateMappedItem(file, repMap, transformHnd);
}