Python Script For Family Path

Hello

I can’t seem to get the routine from here working.

I have been trying to use the Select Model Element node plugged straight into the Python script…

Thanks

Hi @Ben_Veasey
the family instance is not “converted” to a family symbol in the link’s code.
Try this :

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

clr.AddReference('RevitAPI')
import Autodesk

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

doc = DocumentManager.Instance.CurrentDBDocument

#Close all transactions
trans = TransactionManager.Instance
trans.ForceCloseTransaction()

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
fam = IN[0]
faminstance = []
path = []
family = []

for f in fam:
	faminstance.append(UnwrapElement(f))
for f in faminstance:
	family.append(f.Symbol.Family)

for f in family:

	famDoc = doc.EditFamily(f)
	if not famDoc.PathName:
		path.append('Family location not found')
	else:
		path.append(famDoc.PathName)
	famDoc.Close(False)

#Assign your output to the OUT variable.
OUT = path
2 Likes

3 Likes

Thank you guys, that works great.

Hi @Mostafa_El_Ayoubi
Is it possible to set a new path name for the family even if this directory does not exist in you local computer?
Thanks!