首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Revit API -从Revit项目中完全删除族

Revit API -从Revit项目中完全删除族
EN

Stack Overflow用户
提问于 2020-05-28 07:24:24
回答 1查看 448关注 0票数 1

我在尝试从项目中删除族时遇到问题。我可以删除族类型,但该族似乎仍被载入到项目中。有没有办法完全移除它?

到目前为止,我已经查看了这些来源:

1) https://adndevblog.typepad.com/aec/2012/07/supported-workflow-for-unloading-a-family-using-the-revit-api.html

2) https://adndevblog.typepad.com/aec/2012/07/supported-workflow-for-unloading-a-family-using-the-revit-api.html

下面是我的代码:

代码语言:javascript
复制
FilteredElementCollector colTitleBlocks = new FilteredElementCollector(doc)
                .OfClass(typeof(FamilySymbol))
                .OfCategory(BuiltInCategory.OST_TitleBlocks);


using (Transaction tx6 = new Transaction(doc))
{
    tx6.Start("load custom titleblock that you just made");


    Element family2Unload = null;
    foreach (FamilySymbol xfamily in colTitleBlocks )
        {

        if (xfamily.FamilyName == "E1 30 x 42 Horizontal")
             {

             family2Unload = doc.GetElement(xfamily.Id) as Element;

             }
        }
   doc.Delete(family2Unload.Id);

   tx6.Commit();
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-29 04:59:51

家庭

FamilyInstance =>放置的族实例

FamilySymbol =>具有0-m个实例的族类型

Family =>具有n个类型0-m个实例的系列

示例:FamilyDelete.pushbutton

下面是我在pyRevitMEP中删除族的一个脚本:

代码语言:javascript
复制
"""
Copyright (c) 2017 Cyril Waechter
Python scripts for Autodesk Revit
This file is part of pypevitmep repository at https://github.com/CyrilWaechter/pypevitmep
pypevitmep is an extension for pyRevit. It contain free set of scripts for Autodesk Revit:
you can redistribute it and/or modify it under the terms of the GNU General Public License
version 3, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
See this link for a copy of the GNU General Public License protecting this package.
https://github.com/CyrilWaechter/pypevitmep/blob/master/LICENSE
"""
import rpw
doc = rpw.revit.doc
uidoc = rpw.revit.uidoc

from Autodesk.Revit.DB import Transaction, FamilySymbol

__doc__ = "Delete selected families from project"
__title__ = "Family delete"
__author__ = "Cyril Waechter"
__context__ = "Selection"


with rpw.db.Transaction("Delete families from project"):
    # Find families of selected object and delete it
    for id in uidoc.Selection.GetElementIds():
        el = doc.GetElement(id)
        family_id = el.Symbol.Family.Id
        doc.Delete(family_id)

对于族类型,也有相同的值:FamilyTypeDelete.pushbutton

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62054467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档