Access the Active Design Option in a File

Access the Active Design Option in a File

dgoff96
Enthusiast Enthusiast
937 Views
4 Replies
Message 1 of 5

Access the Active Design Option in a File

dgoff96
Enthusiast
Enthusiast

Hi everyone,

 

I'm trying to figure out how to access the active Design Option in a Revit file. I have figured out how to collect all of the options in the file using a filtered element collector, but I don't know how to find which one is currently active. Is this available in the API? All I have managed to find so far is whether or not an option is "Primary"

 

Here is my code as it stands now, just collecting the options and getting their names (using python in Rhino Inside Revit):

import clr
clr.AddReference('System.Core')
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI')

import Autodesk
from System.Linq import Enumerable
from Autodesk.Revit.DB import *
from Rhino.Geometry import *
from RhinoInside.Revit import Revit, Convert

doc = Revit.ActiveDBDocument

Design_Options = []

designOp = FilteredElementCollector(doc).OfClass(DesignOption).ToElements()
for i in designOp:
    Design_Options.append(i.Name.ToString())

 

Thanks!

0 Likes
Accepted solutions (1)
938 Views
4 Replies
Replies (4)
Message 2 of 5

TripleM-Dev.net
Advisor
Advisor

Hi,

 

DesignOptions are limited exposed in the API, like getting the active designoption or setting a designoption in the viewsettings. There are some "hacks" but their not reliable.

 

What you could do is:

- Start a transaction

- Create a small floor

- Inspect it's designoption -> that would be the current one

- Cancel the Transaction (Rollback or never commit in a Using statement)

 

- Michel

0 Likes
Message 3 of 5

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

there is a static method DesignOption.GetActiveDesignOptionId(Document doc) which returns an ElementId.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 5

TripleM-Dev.net
Advisor
Advisor

Also,

I don't know if the designoption will be "attached" if the element is created like this...it does in the UI so...

 

Could fail for:

- API creates the element always without option ? or does it use the Active DesignOption?

- A Commit could be needed after the element is created so the Active designoption can be attached by Revit,

   in this case encapsule the Transaction in a TransactionGroup, Commit the transaction BUT cancel the TransactionGroup

 

0 Likes
Message 5 of 5

dgoff96
Enthusiast
Enthusiast

This is exactly what I needed. I kept thinking this would be a property of a Design Option, not something you would get from the doc itself. Thanks!

0 Likes