简体   繁体   English

python revit Part.Utils如何获取附加结果

[英]python revit Part.Utils how to get append the results out

I managed to parts elements using this script but then I would also like to collect the parted element "parts" in my OUT, somehow I cannot get it right: 我设法使用此脚本分割了元素,但随后我也想在OUT中收集被分割的元素“ parts”,以某种方式我无法正确处理它:

I have skipped the standard imports because I think my confusion is between the parameters and the syntax vs API methods. 我跳过了标准导入,因为我认为我的困惑在于参数与语法与API方法之间。

I tried to use a pre existing codes by 我试图通过使用预先存在的代码

#proposed by Julien Benoit @jbenoit44 
#http://aecuandme.wordpress.com/

What I trying to achieve is get elements from the input list and determine if these elements are eligible for creating parts and then create parts from all the ones that return true. 我想要实现的是从输入列表中获取元素,并确定这些元素是否有资格创建零件,然后从所有返回true的零件中创建零件。

After I would like to collect the parts only (the results) as a list of IDS. 之后,我只想收集零件(结果)作为IDS列表。

Further, I am looking forward to extend this, so that I can also give a list of curves or lines that it can use to divide the list of parts. 此外,我期待对此进行扩展,以便我也可以给出可用于划分零件列表的曲线或直线列表。

# Make Parts

#feed IN[0] with elements
elts = []
Ids = []
Parts=[]

for i in IN[0]:
    elts.append(UnwrapElement(i))

for e in elts:
    Ids.append(e.Id)

IDS = List[ElementId](Ids)

# Start transaction of Making Parts

TransactionManager.Instance.EnsureInTransaction(doc)

if PartUtils.AreElementsValidForCreateParts(doc, IDS):
    a=PartUtils.CreateParts(doc, IDS)
    b=PartUtils.GetAssociatedParts(doc,IDS,True,True)
    Parts=[]
    for i in b:
        Parts.append(doc.GetElement(i).ToDSType(True))
    List.append(Parts)
doc.Regenerate()

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

OUT = Parts

I am sure it has something to do with this part: 我确信这与这部分有关:

b=PartUtils.GetAssociatedParts(doc,IDS,True,True)
        Parts=[]
        for i in b:
            Parts.append(doc.GetElement(i).ToDSType(True))
        List.append(Parts)
    doc.Regenerate()

I believe I just answered a very similar question in the Revit API discussion forum thread on how to get a merged part after merging with some parts : 我相信我刚刚在Revit API讨论论坛线程中回答了一个非常类似的问题,即如何在与某些部分合并后获得合并的部分

You can subscribe to the DocumentChanged event just before calling CreateParts, and unsubscribe just afterwards. 您可以在调用CreateParts之前订阅DocumentChanged事件 ,然后在之后取消订阅。

That will tell you all the element ids added to the database during the call. 这将告诉您在调用过程中添加到数据库中的所有元素ID。

This is demonstrated in the discussion on retrieving newly placed family instances . 这在有关检索新放置的家庭实例的讨论中得到了证明。

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

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