Get Revit Version while loading family

I have managed to get loading large numbers of families without overwrite warnings to work using this method;
http://dynamobim.org/forums/topic/modify-room-calculation-point-toggle-builtin-parameter/

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?

1 Like

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)

Hi Joseph,

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
4 Likes

Thanks Taco, thats exactly what I needed.

1 Like

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)

I’m having trouble using this on Revit 2020, Dynamo 2.1. Everything returns “Failed”.

This has worked beautifully on 2016-2019. Currently this (Index # 51) returns 2019 for the Version number.

Thank you for any insights.

Screen shot is from Revit 2019 - Dynamo 2.0.3.

Can you show screenshots (with outputs displayed) for Revit 2020 where you are getting the failure?


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”)

OUT = listout

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”)

OUT = listout

There also has to be a full empty line between code and non-code, it is a little tricky at first.

Try replacing:

except:
    listout.append("failed")

with:

except Exception as e:
    listout.append(e)

and show what the output is.

HA! Ok…

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”)

OUT = listout

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.

2 Likes

That was it!

Thank you so much.