本文整理汇总了C#中BuiltInParameter类的典型用法代码示例。如果您正苦于以下问题:C# BuiltInParameter类的具体用法?C# BuiltInParameter怎么用?C# BuiltInParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuiltInParameter类属于命名空间,在下文中一共展示了BuiltInParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFilterRuleBuilder
/// <summary>
/// Convert FilterRule to our custom FilterRuleBuilder which will be displayed in form controls
/// </summary>
/// <param name="param">Parameter to which the FilterRule is applied.</param>
/// <param name="rule">FilterRule to be converted.</param>
/// <returns>Custom FilterRuleBuilder data converted from FilterRule</returns>
public static FilterRuleBuilder CreateFilterRuleBuilder(BuiltInParameter param, FilterRule rule)
{
// Maybe FilterRule is inverse rule, we need to find its inner rule(FilterValueRule)
// Note that the rule may be inversed more than once.
bool inverted = false;
FilterRule innerRule = ReflectToInnerRule(rule, out inverted);
if (innerRule is FilterStringRule)
{
FilterStringRule strRule = innerRule as FilterStringRule;
FilterStringRuleEvaluator evaluator = strRule.GetEvaluator();
return new FilterRuleBuilder(param, GetEvaluatorCriteriaName(evaluator, inverted), strRule.RuleString, strRule.CaseSensitive);
}
else if (innerRule is FilterDoubleRule)
{
FilterDoubleRule dbRule = innerRule as FilterDoubleRule;
FilterNumericRuleEvaluator evaluator = dbRule.GetEvaluator();
return new FilterRuleBuilder(param, GetEvaluatorCriteriaName(evaluator, inverted), dbRule.RuleValue, dbRule.Epsilon);
}
else if (innerRule is FilterIntegerRule)
{
FilterIntegerRule intRule = innerRule as FilterIntegerRule;
FilterNumericRuleEvaluator evaluator = intRule.GetEvaluator();
return new FilterRuleBuilder(param, GetEvaluatorCriteriaName(evaluator, inverted), intRule.RuleValue);
}
else if (innerRule is FilterElementIdRule)
{
FilterElementIdRule idRule = innerRule as FilterElementIdRule;
FilterNumericRuleEvaluator evaluator = idRule.GetEvaluator();
return new FilterRuleBuilder(param, GetEvaluatorCriteriaName(evaluator, inverted), idRule.RuleValue);
}
//
// for other rule, not supported yet
throw new System.NotImplementedException("The filter rule is not recognizable and supported yet!");
}
示例2: ParameterData
public ParameterData(
BuiltInParameter bip,
Parameter parameter,
string valueStringOrElementDescription,
bool containedInCollection,
/*
* Edited by Chekalin Victor 13.12.2012
*/
string parameterName)
{
_enum = bip;
_parameter = parameter;
/*
* Edited by Chekalin Victor 13.12.2012
*/
_parameterName = parameterName;
ValueString = valueStringOrElementDescription;
Value = GetValue;
Definition d = _parameter.Definition;
ParameterGroup = d.ParameterGroup.ToString();
GroupName = LabelUtils.GetLabelFor(d.ParameterGroup);
ContainedInCollection = containedInCollection ? "Y" : "N";
}
示例3: SetParaInt
/// <summary>
/// set certain parameter of given element to int value
/// </summary>
/// <param name="elem">given element</param>
/// <param name="paraIndex">BuiltInParameter</param>
/// <param name="value"></param>
/// <returns></returns>
public static bool SetParaInt(Element elem, BuiltInParameter paraIndex, int value)
{
Parameter para = elem.get_Parameter(paraIndex);
if (null == para)
{
return false;
}
para.Set(value);
return true;
}
示例4: 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;
}
示例5: SetParameter
/// <summary>
/// find a parameter according to the parameter's name
/// </summary>
/// <param name="element">the host object of the parameter</param>
/// <param name="paraIndex">parameter index</param>
/// <param name="value">the value of the parameter with Autodesk.Revit.DB.ElementId type</param>
/// <returns>if find the parameter return true</returns>
public static bool SetParameter(Element element,
BuiltInParameter paraIndex, ref Autodesk.Revit.DB.ElementId value)
{
Parameter parameter = element.get_Parameter(paraIndex);
if (null == parameter)
{
return false;
}
if (!parameter.IsReadOnly)
{
StorageType parameterType = parameter.StorageType;
if (StorageType.ElementId != parameterType)
{
throw new Exception("The types of value and parameter are different!");
}
parameter.Set(value);
return true;
}
return false;
}
示例6: GetProperty
/// <summary>
/// Get the room property value according the parameter name
/// </summary>
/// <param name="activeDoc">Current active document.</param>
/// <param name="room">an instance of room class</param>
/// <param name="paraEnum">the parameter used to get parameter value</param>
/// <param name="useValue">convert parameter to value type or not.
/// if true, the value of parameter will be with unit.
/// if false, the value of parameter will be without unit.</param>
/// <returns>the string value of property specified by shared parameter</returns>
public static String GetProperty(Document activeDoc, Room room, BuiltInParameter paraEnum, bool useValue)
{
String propertyValue = null; //the value of parameter
// Assuming the build in parameter is legal for room.
// if the room is not placed, some properties are not available, i.g. Level name, Area ...
// trying to retrieve them will throw exception;
// however some parameters are available, e.g.: name, number
Parameter param;
try
{
param = room.get_Parameter(paraEnum);
}
catch (Exception)
{
// throwing exception for this parameter is acceptable if it's a unplaced room
if (null == room.Location)
{
propertyValue = "Not Placed";
return propertyValue;
}
else
{
throw new Exception("Illegal built in parameter.");
}
}
// get the parameter via the built in parameter
if (null == param)
{
return "";
}
// get the parameter's storage type and convert parameter to string
StorageType storageType = param.StorageType;
switch (storageType)
{
case StorageType.Integer:
int iVal = param.AsInteger();
propertyValue = iVal.ToString();
break;
case StorageType.String:
propertyValue = param.AsString();
break;
case StorageType.Double:
// AsValueString will make the return string with unit, it's appreciated.
if (useValue)
{
propertyValue = param.AsValueString();
}
else
{
propertyValue = param.AsDouble().ToString();
}
break;
case StorageType.ElementId:
Autodesk.Revit.DB.ElementId elemId = param.AsElementId();
Element elem = activeDoc.get_Element(elemId);
propertyValue = elem.Name;
break;
default:
propertyValue = param.AsString();
break;
}
return propertyValue;
}
示例7: SetGUIDParameter
private void SetGUIDParameter(Element element, BuiltInParameter builtInParameter, string guidValue)
{
Parameter parameter = element.get_Parameter(builtInParameter);
if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.String)
{
parameter.SetValueString(guidValue);
}
else
{
ElementId parameterId = new ElementId(builtInParameter);
ExporterIFCUtils.AddValueString(element, parameterId, guidValue);
}
}
示例8: GetElementIdValueFromElementOrSymbol
/// <summary>
/// Gets element id value from parameter of an element or its element type.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="builtInParameter">The built in parameter.</param>
/// <param name="propertyValue">The output property value.</param>
/// <returns>The parameter, or null if not found.</returns>
public static Parameter GetElementIdValueFromElementOrSymbol(Element element, BuiltInParameter builtInParameter, out ElementId propertyValue)
{
Parameter parameter = GetElementIdValueFromElement(element, builtInParameter, out propertyValue);
if (parameter != null)
return parameter;
Document document = element.Document;
ElementId typeId = element.GetTypeId();
Element elemType = document.GetElement(typeId);
if (elemType != null)
return GetElementIdValueFromElement(elemType, builtInParameter, out propertyValue);
return null;
}
示例9: SetStringParameter
/// <summary>
/// Sets string value of a built-in parameter of an element.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="builtInParameter">The built-in parameter.</param>
/// <param name="propertyValue">The property value.</param>
/// <exception cref="System.ArgumentNullException">Thrown when element is null.</exception>
/// <exception cref="System.ArgumentException">Thrown when builtInParameter in invalid.</exception>
public static void SetStringParameter(Element element, BuiltInParameter builtInParameter, string propertyValue)
{
if (element == null)
throw new ArgumentNullException("element");
if (builtInParameter == BuiltInParameter.INVALID)
throw new ArgumentException("BuiltInParameter is INVALID", "builtInParameter");
Parameter parameter = element.get_Parameter(builtInParameter);
if (parameter != null && parameter.HasValue && parameter.StorageType == StorageType.String)
{
parameter.SetValueString(propertyValue);
return;
}
ElementId parameterId = new ElementId(builtInParameter);
ExporterIFCUtils.AddValueString(element, parameterId, propertyValue);
}
示例10: GetStringValueFromElement
/// <summary>
/// Gets string value from built-in parameter of an element.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="builtInParameter">The built-in parameter.</param>
/// <param name="propertyValue">The output property value.</param>
/// <exception cref="System.ArgumentNullException">Thrown when element is null.</exception>
/// <exception cref="System.ArgumentException">Thrown when builtInParameter in invalid.</exception>
/// <returns>The parameter, or null if not found.</returns>
public static Parameter GetStringValueFromElement(Element element, BuiltInParameter builtInParameter, out string propertyValue)
{
if (element == null)
throw new ArgumentNullException("element");
if (builtInParameter == BuiltInParameter.INVALID)
throw new ArgumentException("BuiltInParameter is INVALID", "builtInParameter");
propertyValue = String.Empty;
Parameter parameter = element.get_Parameter(builtInParameter);
if (parameter != null && parameter.HasValue)
{
switch (parameter.StorageType)
{
case StorageType.Double:
propertyValue = parameter.AsDouble().ToString();
return parameter;
case StorageType.Integer:
propertyValue = parameter.AsInteger().ToString();
return parameter;
case StorageType.String:
propertyValue = parameter.AsString();
return parameter;
case StorageType.ElementId:
propertyValue = PropertyUtil.ElementIdParameterAsString(parameter);
return parameter;
}
}
return null;
}
示例11: ParameterAlreadyExist
/// <summary>
/// Check to see if rule for this parameter exists or not
/// </summary>
/// <param name="param">Parameter to be checked.</param>
/// <returns>True if this parameter already has filter rule, otherwise false.</returns>
bool ParameterAlreadyExist(BuiltInParameter param)
{
if (m_currentFilterData == null || m_currentFilterData.RuleData.Count == 0)
return false;
for (int ruleNo = 0; ruleNo < m_currentFilterData.RuleData.Count; ruleNo++)
{
if (m_currentFilterData.RuleData[ruleNo].Parameter == param)
return true;
}
return false;
}
示例12: FilterRuleBuilder
/// <summary>
/// Create FilterRuleBuilder for double FilterRule
/// </summary>
/// <param name="param">Parameter of FilterRule.</param>
/// <param name="ruleCriteria">Rule criteria.</param>
/// <param name="ruleValue">Rule value.</param>
/// <param name="tolerance">Epsilon for double values comparison.</param>
public FilterRuleBuilder(BuiltInParameter param, String ruleCriteria, double ruleValue, double tolearance)
{
InitializeMemebers();
//
// set data with specified values
ParamType = StorageType.Double;
Parameter = param;
RuleCriteria = ruleCriteria;
RuleValue = ruleValue.ToString();
Epsilon = tolearance;
}
示例13: SetParameter
/// <summary>
/// set parameter whose storage type is double
/// </summary>
/// <param name="elem">Element has parameter</param>
/// <param name="builtInPara">BuiltInParameter to find parameter</param>
/// <param name="value">value to set</param>
/// <returns>is successful</returns>
private bool SetParameter(ModelElement elem,
BuiltInParameter builtInPara, double value)
{
Parameter para = elem.get_Parameter(builtInPara);
if (null != para && para.StorageType == StorageType.Double && !para.IsReadOnly)
{
var result = para.Set(value);
return result;
}
return false;
}
示例14: CreatePositiveLengthMeasurePropertyFromElementOrSymbol
/// <summary>
/// Create a positive length 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 optional built-in 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 CreatePositiveLengthMeasurePropertyFromElementOrSymbol(IFCFile file, ExporterIFC exporterIFC, Element elem,
string revitParameterName, BuiltInParameter revitBuiltInParam, string ifcPropertyName, PropertyValueType valueType)
{
double propertyValue;
if (ParameterUtil.GetDoubleValueFromElement(elem, revitParameterName, out propertyValue))
{
propertyValue *= exporterIFC.LinearScale;
return CreatePositiveLengthMeasureProperty(file, ifcPropertyName, propertyValue, valueType);
}
if (revitBuiltInParam != BuiltInParameter.INVALID)
{
string builtInParamName = LabelUtils.GetLabelFor(revitBuiltInParam);
IFCAnyHandle propHnd = CreatePositiveLengthMeasurePropertyFromElement(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 CreatePositiveLengthMeasurePropertyFromElement(file, exporterIFC, elemType, revitParameterName, ifcPropertyName, valueType);
else
return null;
}
示例15: GetProperty
/// <summary>
/// get the room property and Department property according the property name
/// </summary>
/// <param name="room">a instance of room class</param>
/// <param name="paraEnum">the property name</param>
public String GetProperty(Room room, BuiltInParameter paraEnum)
{
String propertyValue = null; //the value of parameter
// get the parameter via the parameterId
Parameter param = room.get_Parameter(paraEnum);
if (null == param)
{
return "";
}
// get the parameter's storage type
StorageType storageType = param.StorageType;
switch (storageType)
{
case StorageType.Integer:
int iVal = param.AsInteger();
propertyValue = iVal.ToString();
break;
case StorageType.String:
String stringVal = param.AsString();
propertyValue = stringVal;
break;
case StorageType.Double:
Double dVal = param.AsDouble();
dVal = Math.Round(dVal, 2);
propertyValue = dVal.ToString();
break;
default:
break;
}
return propertyValue;
}