简体   繁体   中英

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. 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:

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...

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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