简体   繁体   English

使用python将详细信息组件放置在Revit中

[英]Placing a detail component in Revit using python

I'm trying to create detail component buttons that run the following code. 我正在尝试创建运行以下代码的详细组件按钮。 However, I need it to work for 2015-2018 possibly 2019 in the future. 但是,我需要它在2015-2018或将来的2019中工作。

Currently I have the custom ribbon and buttons made, but I can't get this script to work due to commandData in the first line not working. 目前,我已经完成了自定义功能区和按钮的制作,但是由于第一行中的commandData无法正常工作,因此无法使此脚本正常工作。 I've tried testing this as a macro just to try and see if it will work first before continuing. 我尝试将其作为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>();
    }

It's located in the Detail Items in the project browser 它位于项目浏览器的“详细信息”中

Family = Break Line
Type   = Break Line

Any help will be greatly appreciated! 任何帮助将不胜感激!

The commandData argument is a parameter passed into the Execute method of an external command by Revit. commandData参数是Revit传递给外部命令的Execute方法的参数。 It includes data enabling the external command to get in touch with Revit and its database. 它包括使外部命令能够与Revit及其数据库联系的数据。

A macro provides a different method to access Revit and its database. 宏提供了另一种访问Revit及其数据库的方法。

Work through the Revit API getting started material or the Revit developer guide hello world walkthroughs to see how to set up an external command to get the commandData passed in as required. 通过Revit API入门材料Revit开发人员指南您好,您将了解如何设置外部命令以获取所需的commandData

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM