本文整理汇总了C#中Element.GetParameters方法的典型用法代码示例。如果您正苦于以下问题:C# Element.GetParameters方法的具体用法?C# Element.GetParameters怎么用?C# Element.GetParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element.GetParameters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
if (commandData == null || commandData.Application == null || commandData.Application.ActiveUIDocument == null)
{
TaskDialog.Show("Revit", "Comment Editor requires an open document.");
return Result.Failed;
}
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document;
// Access current selection
Selection sel = uidoc.Selection;
if (sel.GetElementIds().Count != 1)
{
TaskDialog.Show("Revit", "Comment Editor requires a single element selected.");
return Result.Failed;
}
m_element = doc.GetElement(sel.GetElementIds().FirstOrDefault());
Parameter comment = m_element.GetParameters("Comments").FirstOrDefault();
if (comment == null)
{
TaskDialog.Show("Revit", "Comment Editor requires the selected element to have a comment parameter");
return Result.Failed;
}
CommentEditorDialog ced = new CommentEditorDialog();
Window cew = new Window();
cew.Content = ced;
cew.Title = "Comment Editor";
cew.Width = ced.grid.Width;
cew.Height = ced.grid.Height;
ced.Text = comment.AsString();
cew.ResizeMode = ResizeMode.NoResize;
cew.ShowDialog();
if (cew.DialogResult.Value == false)
{
return Result.Cancelled;
}
using (Transaction tx = new Transaction(doc))
{
tx.Start("Edit Element Comment");
comment.Set(ced.Text);
tx.Commit();
}
return Result.Succeeded;
}
示例2: GetDefinition
/// <summary>
/// Return the parameter definition from
/// the given element and parameter name.
/// </summary>
static Definition GetDefinition(
Element e,
string parameter_name)
{
//Parameter p = e.get_Parameter( parameter_name ); // 2014
IList<Parameter> ps = e.GetParameters( parameter_name );
int n = ps.Count;
Debug.Assert( 1 >= n,
"expected maximum one shared parameters "
+ "named " + parameter_name );
Definition d = ( 0 == n )
? null
: ps[0].Definition;
return d;
}
示例3: GetAddedParameter
// This function should only be necessary while using ExperimentalAddParameter.
private static Parameter GetAddedParameter(Element element, string parameterName, StorageType type)
{
IList<Parameter> parameterList = element.GetParameters(parameterName);
if (parameterList == null)
return null;
foreach (Parameter parameter in parameterList)
{
if (parameter.StorageType != type)
continue;
if (parameter.IsReadOnly)
continue;
Definition paramDefinition = parameter.Definition;
if (paramDefinition == null)
continue;
if (paramDefinition.ParameterGroup == BuiltInParameterGroup.PG_IFC)
return parameter;
}
// Shouldn't get here.
return null;
}
示例4: GetDefinition
/// <summary>
/// Return the parameter definition from
/// the given element and parameter name.
/// </summary>
public static Definition GetDefinition( Element e )
{
IList<Parameter> ps = e.GetParameters(
_shared_param_name );
int n = ps.Count;
Debug.Assert( 1 >= n,
"expected maximum one shared parameters "
+ "named " + _shared_param_name );
Definition d = ( 0 == n )
? null
: ps[0].Definition;
return d;
}