Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNX-9775 sending revit elements via dynamo #3495

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

oguzhankoral
Copy link
Member

@oguzhankoral oguzhankoral commented Jun 8, 2024

We have assumption on this user has installed Revit connector, otherwise we will be missing RevitSharedResources

@oguzhankoral oguzhankoral force-pushed the CNX-9775-Sending-Revit-elements-via-Dynamo branch from 5472ddb to 4c5f3e2 Compare June 8, 2024 13:09
Copy link
Member

@AlanRynne AlanRynne left a comment

Choose a reason for hiding this comment

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

Just a couple comments 🙌🏼

Comment on lines +396 to +398
// Local function to create ParameterToSpeckleData
ParameterToSpeckleData CreateParamData()
{
Copy link
Member

Choose a reason for hiding this comment

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

Why local function? 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

😓 I asked this myself too while writing.. We use creating param data under both condition of revitDocumentAggregateCache is null or not. And this param data parameters come from preprocessor directives as below, then it was more painful to extract this as private global function..

#if REVIT2020
    DisplayUnitType unitTypeId = default;
#else
    ForgeTypeId unitTypeId = null;
#endif

Comment on lines +156 to +157
categoryInfo = revitCategoryInfoCache.TryGet(categoryName);
if (categoryInfo != null)
Copy link
Member

Choose a reason for hiding this comment

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

This makes me a bit supicious... we were previously calling GetAllObjects instead of this and I'm not sure the reason why we did this.

Your change seems legit though... just wondering if we're missing something here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is also my most suspicious place, regardless I believe we should test this with real version too, on both Revit and Dynamo to understand we are having side effect on anything. 🤞

Comment on lines +166 to +169
else
{
return SHC.Undefined;
}
Copy link
Member

Choose a reason for hiding this comment

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

could be simpler if we flip the condition? could somewhat reduce nesting and make the logic a bit more linear.

The 2 return statements above this one could also be collapsed into a return categoryInfo ?? SHC.Undefined which I consider neater (super personal opinion here...)

Copy link
Member

@AlanRynne AlanRynne Jun 13, 2024

Choose a reason for hiding this comment

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

If this turns into more than a 30 second refactor, disregard it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess you were referencing to this body (from 156-163) right? Confused because your comment targeting to 166-169

if (categoryInfo != null)
      {
        return categoryInfo;
      }
      else
      {
        return SHC.Undefined;
      }

Comment on lines +144 to +147
if (revitDocumentAggregateCache is null)
{
return default;
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this safe? This means that it will always return null if the cache is not set, which is not immediately obvious.

Copy link
Member Author

Choose a reason for hiding this comment

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

The logic was around this as below so I thought it is safe to return immediately if even cache is null....

var types = revitDocumentAggregateCache
      .GetOrInitializeWithDefaultFactory<List<ElementType>>()
      .GetOrAddGroupOfTypes(typeInfo);

    if (!types.Any())
    {
      var name = typeof(T).Name;
      if (element["category"] is string category && !string.IsNullOrWhiteSpace(category))
      {
        name = category;
      }

      appObj.Update(
        status: ApplicationObject.State.Failed,
        logItem: $"Could not find any loaded family to use for category {name}."
      );

      return default;
    }

@AlanRynne AlanRynne merged commit c9e27de into dev Jul 1, 2024
32 checks passed
@AlanRynne AlanRynne deleted the CNX-9775-Sending-Revit-elements-via-Dynamo branch July 1, 2024 08:52
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.

2 participants