But the method fails when it reaches a family that is from a later version of revit.
Is there a way to extract the Revit version a family was saved in from the .rfa before loading?
Adjusted the code to use âtry: except:â and make a list of all the families that fail. Seems to be working, but failure could be for other reasons too.
Doing File-Open and scrolling through to see which thumbnails revit cant make is the only method for spotting later versions I have found so far, but this doesnt seem to work for every instance. Load Families No Warnings.dyn (8.9 KB)
You can use this piece of python to retrieve the Revit version. All you need to do is supply the paths to the family files. Revit version reporter.dyn (3.2 KB)
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#The inputs to this node will be stored as a list in the IN variables.
path = IN[0]
listout = []
for p in path:
try:
info = BasicFileInfo.Extract(p)
version = info.SavedInVersion
listout.append(version)
except:
listout.append("failed")
OUT = listout
Nice Python! This script/node is so useful! I can now add a âRevit Versionâ column to my Revit family details report!
!Muchos Gracias! FamilyCategoryIndex_2018.11.09 RevitReporter.dyn (57.8 KB)
This is from Revit 2020 running on 2.1. Its failing on the Python Node. Which is as follows.
import clr
clr.AddReference(âRevitAPIâ)
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference(âRevitNodesâ)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion) #The inputs to this node will be stored as a list in the IN variables.
path = IN[0]
listout =
for p in path:
try:
info = BasicFileInfo.Extract§
version = info.SavedInVersion
listout.append(version)
except:
listout.append(âfailedâ)
When pasting code into a post on the forum, use the </> button so it will format properly. Like the symbol after info = BasicFileInfo.Extract§ will instead look like info = BasicFileInfo.Extract(p) along with indentations being shown.
Sorry about thatâŚ
import clr
clr.AddReference(âRevitAPIâ)
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference(âRevitNodesâ)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion) #The inputs to this node will be stored as a list in the IN variables.
path = IN[0]
listout =
for p in path:
try:
info = BasicFileInfo.Extract§
version = info.SavedInVersion
listout.append(version)
except:
listout.append(âfailedâ)
clr.AddReference(âRevitAPIâ)
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference(âRevitNodesâ)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion) #The inputs to this node will be stored as a list in the IN variables.
path = IN[0]
listout =
for p in path:
try:
info = BasicFileInfo.Extract§
version = info.SavedInVersion
listout.append(version)
except:
listout.append(âfailedâ)
Going through the API for 2020, it looks like BasicFileInfo.SavedInVersion is no longer a command. This means you will need another method to get the version.
Replace version = info.SavedInVersion with version = info.Format, I think that command returns the version.
Note that this command only exists in the Revit 2019 and 2020 API, so you canât use it for earlier versions. But it looks like this is the command they plan on using going forward.
if you read a revit family as string, you can double check that the Revit version of the file is indicated as âFormat: 2019â I believe from Revit 2019 upwards
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#The inputs to this node will be stored as a list in the IN variables.
path = IN[0]
listout = []
for p in path:
try:
info = BasicFileInfo.Extract(p)
version = info.Format
listout.append(version)
except:
listout.append("failed")
OUT = listout