Batch turn on Room Calculation Point in different families

I am trying to turn on Room Calculation Point of all families in my revit project. However, It is impossible to finish this task by dynamo.
Is there any advice about using python to do this?

@CSC_FrankieNg ,

thats a family issue. I would recomment you save all your families in a folder library. And open/close them to activate this option in the family! and that reload all of them…
crumble is a package for dealing with that. or you do it by hand if you have less then 100 families.
2022-09-19_12h29_01
2022-09-19_12h29_52

Thanks for your advice. I already downloaded the Crumple package, but I still have to open each family to turn on the Room Calculation Point toggle many times…

please try my script:
please put all the doors family in that folder

image

import os
import clr
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
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

dir = IN[0]
files = []
for file in os.listdir(dir):
	if file.endswith(".rfa"):
		files.append(os.path.join(dir, file))

for p in files:
	opendoc = app.OpenDocumentFile(p)
	ownerfamily = opendoc.OwnerFamily
	param = ownerfamily.get_Parameter(BuiltInParameter.ROOM_CALCULATION_POINT)
	
	TransactionManager.Instance.EnsureInTransaction(opendoc)
	param.Set(1)
	TransactionManager.Instance.ForceCloseTransaction()
	opendoc.Close(True)


OUT = 1

Thank you. I tried your script, but some errors appear.(I am new on Python)
Screenshot 2022-09-20 134134

my script works on cpython but not ironpython,
here is the script which works on ironpython:

import os
import clr
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
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

dir = IN[0]
files = []
for file in os.listdir(dir):
	if file.endswith(".rfa"):
		files.append(os.path.join(dir, file))

for p in files:
	opendoc = app.OpenDocumentFile(p)
	ownerfamily = opendoc.OwnerFamily
	param = ownerfamily.get_Parameter(BuiltInParameter.ROOM_CALCULATION_POINT)
	
	TransactionManager.Instance.EnsureInTransaction(opendoc)
	param.Set(1)
	TransactionManager.Instance.ForceCloseTransaction()
	opendoc.Close(True)


OUT = 1

Could you tell me the function of this script?

turn on Room Calculation Point of all families in my revit project.

image

before

after

import clr
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
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

toList = lambda x : x if hasattr(x, '__iter__') else [x]

doors = toList(UnwrapElement(IN[0]))

class FamilyOption(IFamilyLoadOptions):
	def OnFamilyFound(self, familyInUse, overwriteParameterValues):
		overwriteParameterValues.Value = False
		return True

	def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues):
		overwriteParameterValues.Value = False
		return True

opts = FamilyOption()
TransactionManager.Instance.ForceCloseTransaction()
for d in doors:
	familydoc = doc.EditFamily(d.Symbol.Family)
	ownerfamily = familydoc.OwnerFamily
	param = ownerfamily.get_Parameter(BuiltInParameter.ROOM_CALCULATION_POINT)
	TransactionManager.Instance.EnsureInTransaction(familydoc)
	param.Set(1)
	TransactionManager.Instance.ForceCloseTransaction()
	family = familydoc.LoadFamily(doc, opts)


OUT = 1

Amazing! I just tried windows category, It is work!
“for d in doors” This sentence is only for door category
I am wondering why it is work for other category.

it’s just a variable name :grinning:
the script works on door and windows (they have calculation point)

Oh, understand. Thanks again for your help!

1 Like

please mark it solved :kissing_heart: