Skip to content

Conversation

@RobertGlobant20
Copy link
Contributor

Purpose

Considering that we are using DynamoCore 3.6.0 and DynamoRevit 3.4.0, previously when installing a package in Dynamo for Revit was installing the package in the path created using DynamoCore version (e.g. C:\Users\user\AppData\Roaming\Dynamo\Dynamo Revit\3.6) but after this change now is using the DynamoRevit version path (e.g. C:\Users\user\AppData\Roaming\Dynamo\Dynamo Revit\3.4\packages).

Note: This fix is only for Dynamo for Revit

Declarations

Check these if you believe they are true

  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

Changing the package path installation for Dynamo Revit to use the DynamoRevit version (instead of DynamoCore version)

Reviewers

@QilongTang

FYIs

@zeusongit

Considering that we are using DynamoCore 3.6.0 and DynamoRevit 3.4.0 previously when installing a package in Dynamo for Revit was installing the package in the path created using DynamoCore version (e.g. C:\Users\user\AppData\Roaming\Dynamo\Dynamo Revit\3.6) but after this change now is using the DynamoRevit version path (e.g. C:\Users\user\AppData\Roaming\Dynamo\Dynamo Revit\3.4\packages).
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-9348

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the package installation path for Dynamo Revit to use the correct DynamoRevit version instead of the DynamoCore version. The change ensures packages are installed in the appropriate version-specific directory (e.g., 3.4 instead of 3.6).

  • Introduces a static HostInfo class to store and access the host version globally
  • Modifies the PathManager to use the host version for package path construction in Dynamo Revit scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/DynamoCore/Models/DynamoModel.cs Adds static HostInfo class and populates it with host version during model initialization
src/DynamoCore/Configuration/PathManager.cs Updates PathManager to use HostInfo.HostVersion for package path calculation when available

/// Contains the HostVersion inside a static class so that it can be accessed in other parts of the code without creating an instance.
/// </summary>
public static class HostInfo
{
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HostVersion field should have XML documentation explaining its purpose, when it's set, and what it represents in different hosting scenarios.

Suggested change
{
{
/// <summary>
/// Represents the version of the host application in which Dynamo is running.
/// This field is set during Dynamo initialization by the host (e.g., Revit, Civil 3D, or standalone).
/// In different hosting scenarios, this value reflects the version of the host product:
/// - In Dynamo Revit, it is set to the Revit version (e.g., 2025.2.0).
/// - In standalone Dynamo, it may be set to the Dynamo version itself.
/// Consumers should check this value to determine host-specific behaviors or compatibility.
/// </summary>

Copilot uses AI. Check for mistakes.

BuildHostDirectories(pathManagerParams.HostPath);

//In the case of Dynamo for Revit HostInfo.HostVersion will contain the DynamoRevit version so we will use this values for installing packages in the right location
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: 'this values' should be 'these values' in the comment.

Suggested change
//In the case of Dynamo for Revit HostInfo.HostVersion will contain the DynamoRevit version so we will use this values for installing packages in the right location
//In the case of Dynamo for Revit HostInfo.HostVersion will contain the DynamoRevit version so we will use these values for installing packages in the right location

Copilot uses AI. Check for mistakes.
@RobertGlobant20
Copy link
Contributor Author

This is a GIF showing that now is installing the package in the DynamoRevit version and a GIF showing that after re-opening Dynamo is loading the package from the right path and showing the installation path updated.
YqsDw2gHdp
Revit_ZKc021aR04

@RobertGlobant20
Copy link
Contributor Author

This is a GIF showing that when installing the package in DynamoSandbox (the same path remains) is using the 3.6 path.
explorer_udCPgKHyxd

if (HostInfo.HostVersion != null)
{
pathManagerParams.MajorFileVersion = HostInfo.HostVersion.Major;
pathManagerParams.MinorFileVersion = HostInfo.HostVersion.Minor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess these are considered overwriting of PathManager default behavior right? Would you point me, where are these two params used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If with default behavior you are talking about DynamoSandbox, I already tested and is installing the packages in the right path (e.g. if DynamoCore is 3.6.0 then is installed in C:\Users\user\AppData\Roaming\Dynamo\Dynamo Core\3.6).

We are using majorFileVersion and minorFileVersion inside PathManager in the next code:

return Path.Combine(folder,

And is used for building the userDataDir that later is used for building the packages dir in the next code:
commonPackages = Path.Combine(commonDataDir, PackagesDirectoryName);

Also found that for creating the PathManager instance we are using a lazy loading Singleton with parameters in the constructor but we are passing the parameters only in test mode so not used in Revit, then the only way that I found to get the Version was by using a static class.

Also not sure how we are going to test this change due that I had to use Dynamo RC3.6.0_master branch with DynamoRevit master branch to test in Revit Preview Release 2027, if I use the latest Dynamo master branch (the base of my branch) then Dynamo is not opening in Revit.

Updating comments suggested by Copilot
@RobertGlobant20
Copy link
Contributor Author

@QilongTang @zeusongit
Do you have any more comment about this PR?

/// <summary>
/// Contains the HostVersion inside a static class so that it can be accessed in other parts of the code without creating an instance.
/// </summary>
public static class HostInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For host name/version, we should use the one in DynamoModel.HostAnalyticsInfo instead of exposing it directly on the model. Any reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reddyashish the reason is due that we need to use the host name/version inside the PathManager class (which is a lazy loading Singleton), then PathManager doesn't have access to DynamoModel.HostAnalyticsInfo and the only way that I found for accessing the host name/version in the singleton (and avoiding altering the structure) was by using a public static class.

@zeusongit
Copy link
Contributor

@QilongTang Any update from the D4R side that will affect this? Can we merge and test?

@QilongTang
Copy link
Contributor

QilongTang commented Sep 24, 2025

@QilongTang Any update from the D4R side that will affect this? Can we merge and test?

Sorry I should comment way earlier, I am a bit skeptical the public static class approach under DynamoModel is the best approach here given it would duplicate info which already exists.. @RobertGlobant20 Would you brainstorm with copilot about other alternatives? Apologize for the late comment

@RobertGlobant20
Copy link
Contributor Author

@QilongTang Any update from the D4R side that will affect this? Can we merge and test?

Sorry I should comment way earlier, I am a bit skeptical the public static class approach under DynamoModel is the best approach here given it would duplicate info which already exists.. @RobertGlobant20 Would you brainstorm with copilot about other alternatives? Apologize for the late comment

GitHub Copilot is suggesting the next alternatives:

  1. Set Before First Access (Recommended)
  2. Pass via IPathResolver
  3. Modify the Lazy Initialization Logic
  4. Set Static Properties Before First Use
  5. Recreate the Singleton (Not Recommended)

I will check the options 1 and 2 since are the recommended, 4 is similar like I implemented

@RobertGlobant20
Copy link
Contributor Author

closed due that we are already working in a different implementation, see #16528

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants