简体   繁体   English

从打开的项目Revit API + python获取工作集ID

[英]Getting Workset id's from the open project Revit API + python

I am trying to get a list of workset name and id's from the active document using Revit API inside of Python node in Dynamo. 我正在尝试使用Dynamo中Python节点内的Revit API从活动文档中获取工作集名称和ID的列表。 I am trying to access workset table but this code returns nothing: 我正在尝试访问工作集表,但是此代码未返回任何内容:

doc = __doc__

workset = ActiveWorkset(doc)
active_id = workset.ActiveWorksetId()

OUT = active_id

For now I was just trying to see if i can get active workset first but even that doesnt work. 现在,我只是想看看我是否可以先获得活动的工作集,但是那还是行不通的。

I haven't tried this in Dynamo, but my trusty RevitPythonShell thinks this should work: 我没有在Dynamo中尝试过此方法,但是我值得信赖的RevitPythonShell认为这应该可行:

worksetTable = doc.GetWorksetTable()
activeId = worksetTable.GetActiveWorksetId()
workset = worksetTable.GetWorkset(activeId)

this is based on the example from the Revit 2014 API document in the SDK... 这是基于SDK中Revit 2014 API文档中的示例...

The output: 输出:

>>> workset
<Autodesk.Revit.DB.Workset object at 0x000000000000002E [Autodesk.Revit.DB.Workset]>

Based on your example, you probably want to do this at the end: 根据您的示例,您可能最终希望这样做:

OUT = activeId

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

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