Revit Versions in ZTN

How can I mantain a Dynamo Zero Touch package to work with multiple Revit versions?

Thanks!

you would pick the lowest api version you want to support stick with that - so it will work on all versions - unless a newer API removes an existing method (rare)

in that case you could use system.reflection to check if the API exists before calling it - though this is slow.

I would usually make multiple package versions for each revit version. Yes, it is time consuming - from experience, we know that as Dynamo itself maintained 3 versions of Revit compatibility at a time.

I think others on this forum like Thomas Mohan and Ksobon probably have better/more experienced answers than me though.

1 Like

I’m in the same situation. I’ve been notified that Wombat has an issue with the Wall.ByCurveAndLocation node (Use of Wall.ByCurveAndLocation fails in Revit 2021 and 2022 · Issue #2 · woodsbagot/WombatDYN · GitHub) and apparently the problem is that in Revit 2021 and above they changed the way to get the UnitType property from the Revit.DB namespace :unamused:

I wouldn’t want to have 2 versions of the package just to change one line of code…sounds ridiculous!

Is there an efficient way?
@Thomas_Mahon @Konrad_K_Sobon how do you guys do this?

Depends, if your issues are restricted to a few depreciated methods - e.g. units conversion, then this is the technique I use in BimorphNodes to provide backwards compatibility so I only need to maintain and distribute one version of the app (it avoids reflection too): Host App Backwards Compatibility - #6 by Thomas_Mahon

Just take note of the limitations of this approach.

3 Likes

Thanks @Thomas_Mahon this sounds exactly like what I need to do. I’ll give it go!

@ATassera I support multiple different versions of the revit api’s via multiple dynamo packages. It’s not for everyone but works for me. GitHub - ksobon/archilab: this is archi-lab.net dynamo repo

1 Like

Thanks Kornad as well!

@Thomas_Mahon I’m trying your way and it’s really clever, but there’s one part I dont’ understand, which is when you decide which method you’re going to use (if the 2020 or the normal one) you are testing which Revit version is it, you use this code:

nodeServices.RevitVersion < NodeSettings.RevitApiNewUnitsVersion

but I don’t understand where that’s coming from and I can’t call it in VS
(sorry I’ve never done much ZTN so I might a bit noob in this field :smiley: )

Hi @andrea.tassera

Good question! So nodeServices is an instance of BimorphNodes NodeServices class (its an internal) and its RevitVersion property is initialized with the following so I have access to the Revit version at runtime:

        /// <summary>
        /// Returns the current version number of Revit as an int.
        /// </summary>
        private int GetRevitVersion(Document document)
        {
            int revitVersionNumber = Convert.ToInt16(document.Application.VersionNumber);

            return revitVersionNumber;
        }

NodeSettings is a class of public constants, where RevitApiNewUnitsVersion simply stores the following:

        /// <summary>
        /// The version of the Revit API which introduced the new ForgeTypeId units class.
        /// </summary>
        public const int RevitApiNewUnitsVersion = 2021;
2 Likes

Thanks @Thomas_Mahon that worked like a charm. Thanks for sharing!
I love how simple, and in its way elegant, it is. I never thought of it before, but I’m a big fan now.

1 Like