How to set Element's Design Option?

@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 @jacob.small 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

7 Likes