Spatial Element Calculation Location - Revit Settings

I am trying to set the “default” for the Room Area Computation Location, and I thought I was getting the correct thing, but it appears that when I change the setting, it is not actually changing Revit. It seems like I am missing a call to “set” the options once they have been defined, but I must be missing something. Any help here would be appreciated.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
#The inputs to this node will be stored as a list in the IN variables.
results = []

TransactionManager.Instance.EnsureInTransaction(doc)

try:
	spEB = SpatialElementBoundaryOptions()
	spEB.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish
	results.append(spEB.SpatialElementBoundaryLocation)
except:
	results.append(False)

TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = results
1 Like

Not sure, but I think you need to start with a constructor first. This code snippet from @Gui_Talarico might shed some light for you though.

Thanks @jacob.small, I think what I am seeing is that this line:

Options that can be passed to a SpatialElementBoundaryCalculator to influence the results of the calculation.

makes me think these are only options when specifically using a BoundaryCalculator in the code and not for actually changing the (radio) setting within the Revit environment. That is what I would like to be able to do, but not sure that is exposed. I have managed to set Area / Volume settings and thought this would be similar.

Might be worth a post to the Autodesk Development Network forum for Revit if you don’t get guidance this weekend.

1 Like

@SeanP

it is not actually changing Revit

You are creating an Options object but you are not doing anything with it.
The options object needs to be used by making a call to a function that uses it, for example, to get the boundary elements of a given room:

Example

# ...
# Create Options object
options = SpatialElementBoundaryOptions()
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center

# Use Options object 
room_boundaries = some_room.GetBoundarySegments(options)
# `room_boundaries` variables now has the geometric boundaries of `some_room`, 
# extracted using the "Center" location approach of its bounding elements (center of wall)

Thanks @Gui_Talarico. I think is what I understood was happening, but not really what I am looking for. As I mentioned above, I want to change the project default setting, not provide options to a boundary calculator. From what I am seeing, I don’t think this is exposed and/or I don’t know how to access it. I have accessed the Volume Computations, and thought this would be similar. Thoughts if any?

Sorry I misunderstood your original question.
My brain went straight into your code and I obviously did not read the question :upside_down_face:

You need to use AreaVolumeSettings Class and SetSpatialElementBoundaryLocation Method

The code below will Change the “Room Area Computation” Option in the “Area and Volumes Computations” dialog. You can remove the transaction stuff in Dynamo

from Autodesk.Revit.DB import (
    AreaVolumeSettings,
    SpatialElementBoundaryLocation,
    SpatialElementType,
    Transaction
)

# Get `doc` handler
# ...
t = Transaction(doc)
t.Start('Changes Room Computation option to Center')
settings = AreaVolumeSettings.GetAreaVolumeSettings(doc)
settings.SetSpatialElementBoundaryLocation(SpatialElementBoundaryLocation.Center, SpatialElementType.Room)
t.Commit()

http://www.revitapidocs.com/2015/3accb536-c914-3581-bb80-1244b1522230.htm
http://www.revitapidocs.com/2015/d1d395b6-7cb4-358a-3838-68c619c22385.htm

3 Likes

Brilliant, thanks!