Make a Design Option Primary

Hi all, Im trying to make a graph to make a certain design option of a designoption set primary. I tried this by using the orchid nodes for getting the design option set and design option. then applying this into a python script. It got me an error, could anyone help?

This is the python script:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')

# Load the Revit API and RevitServices
clr.AddReference("RevitAPI")
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

# Import the Revit API
import Autodesk
from Autodesk.Revit.DB import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line

# Function to set the primary design option
def set_primary_design_option(option_set, option):
    try:
        option_set.SetPrimary(option)
        return True
    except:
        return False

# Get the active Revit document from the input
doc = IN[0]

# Get the DesignOptionSet and DesignOption IDs from the inputs
option_set_id = IN[1]
option_id = IN[2]

# Find the DesignOptionSet and DesignOption by their IDs
option_sets = FilteredElementCollector(doc).OfClass(DesignOptionSet).ToElements()
option_set = [x for x in option_sets if x.Id == option_set_id][0]

options = option_set.GetDesignOptions()
option = [x for x in options if x.Id == option_id][0]

# Set the primary design option
result = set_primary_design_option(option_set, option.Id)

# Assign your output to the OUT variable.
OUT = result

My guess is that the orchid data isn’t valid in the Revit context, but I can’t confirm as I don’t have the Orchid Package installed, best to ask on the linked GitHub.

1 Like

Thank you Jacob, i hace made an issue six days ago, but did not get a response yet.

Does anybody else know where the problem may be?

Try using some custom packages to collect the current document instead of the OOTB node.

Or hard code the IN[0] input to the current doc (there are examples on the forums)

some packages containing these from memory.
-Archilab
-Crumple

Or even better search the orchid package as this is likely the compatable method.

1 Like

Hi Guys,

Recieved also an answer from Erfajo. ( make a design option primary · Issue #213 · erfajo/OrchidForDynamo (github.com))

Looks like there is no method to set a design option to primary yet.