我正在尝试创建运行以下代码的detail组件按钮。然而,我需要它在2015-2018年可能在2019年在未来工作。
目前,我有自定义功能区和按钮,但我不能得到这个脚本工作,因为在第一行的commandData不工作。我尝试将其作为macro进行测试,只是想先看看它是否能正常工作,然后再继续。
FamilySymbol symbol = GetElements<FamilySymbol> (commandData.Application.ActiveUIDocument.Document)
.Where(item => item.Name == "NameYouWant")
.First();
commandData.Application.ActiveUIDocument.PromptForFamilyInstancePlacement(symbol);
/// <summary>
/// Get the collection of elements of the specified type.
/// <para>The specified type must derive from Element, or you can use Element but you get everything :)</para>
/// </summary>
/// <typeparam name="T">The type of element to get</typeparam>
/// <returns>The list of elements of the specified type</returns>
public IEnumerable<T> GetElements<T>(Document document) where T : Element
{
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(T));
return collector.Cast<T>();
}它位于项目浏览器的详细信息项中
Family = Break Line
Type = Break Line任何帮助都将不胜感激!
发布于 2018-05-22 03:07:28
commandData参数是由Revit传递到外部命令的Execute方法中的参数。其中包括使外部命令能够与Revit及其数据库取得联系的数据。
宏提供了另一种访问Revit及其数据库的方法。
通过Revit API getting started material或Revit developer guide hello world walkthroughs了解如何设置外部命令,以便根据需要传入commandData。
https://stackoverflow.com/questions/50373980
复制相似问题