How to set Element's Design Option?

Is it possible to set an element’s Design Option?
I’ve got a graph that creates 3D Masses from Rooms, but now we’ve got a project with some of the Rooms in Design Options, so I need to set my Masses to match.
I tried the Element.GetParameterValueByName on the Rooms and then Element.SetParameterByName on the Mass, but I get a “The parameter is read-only” error on the Set.

Can you share an image of your graph?

Edit: reason I ask is assigning design options via the API isn’t doable. Going to need a creative workflow as a workaround.

Here’s an image of the nodes I’m having trouble with

I’m piping in the Rooms to the center node, and the Masses to the one on the right.
I’d upload the whole graph, but I’ve got a lot of custom nodes, so it wouldn’t work anyway.
Pretty sure the core problem is that the D.O. parameter is read-only.

That is correct and what I was trying to allude to in my previous post.

My thought on a workaround:

First in Dynamo:
Filter your rooms by the design option.
Create the form elements for the first design option.
Select the elements in Revit after creating them.

Then in Revit:
Manually assign the design option for the selected forms.

Then back to Dynamo to start the process over again for the next design option.

By the looks of it you are attempting to place the elements into all design options so it may be that you can move them all over at once, which may ease that process.

I admit it’s a painful workaround. I have other thoughts that may help but it’s hard to see what’s best as I can’t see the forest, only the one tree. Send a camera export of of the rest of the graph (custom nodes and all) if you need help with that process or want others to weigh in on with other options. If you’re worried about client data, use a test model or even a test graph which gives the overall image.

@DaveP,

One ugly way you could change and Elements Design Option (and there will be some haters out there - I know it’s nasty before you start trollin) is to use the Postable Commands…

The node PostableCommand.AddToSet (Py) is an OOTB python node with the following code…

import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *
clr.AddReference("System.Core")
from System.Collections.Generic import HashSet

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

# IN variables...
run = tolist(IN[0])[0]
elems = tolist(UnwrapElement(IN[1]))

# Main Code...
if run:
	# Get ElementIds to list...
	elemIds = HashSet[ElementId]([e.Id for e in elems])	
	# Set Selection (required for the postable command)...
	uidoc.Selection.SetElementIds(elemIds)	
	uidoc.RefreshActiveView()
	
	# Get RevitCommandId of PostableCommand...
	rvtComId = RevitCommandId.LookupPostableCommandId(PostableCommand.AddToSet)
	# Run PostableCommand...
	uiapp.PostCommand(rvtComId)
	
	OUT = "Command Has Run"
else:
	OUT = "Please set Run to True"

Postable Commands are pretty much like pressing the button in Revit, they also usually require some UI action thereafter, so not great for Automation. In this case you will be presented by the dialog to select the Design Option(s) you want to move the elements to.

This may be what you are after. Sadly, as @JacobSmall mentioned earlier, the Revit API offers very little support in the way of Design Options and what you can do with them. Mostly Read only and Filtering. I tend to never use PostableCommands personally, but they’re in the API so thought I would mention as a last resort.

Cheers,
Dan

6 Likes

Thank you for this Post, I tryed it today.

It works well.

Great regards
Heinrich

This works really well, and for my application having the user select the design option into which to place the created geometry is preferred. Thank you!

1 Like