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

bug(rhino): fixes missing user strings on nested instances when receiving #3170

Conversation

clairekuang
Copy link
Member

Description & motivation

Adds missing user strings to nested blocks when converting to native. Refer to this community post for more info: https://speckle.community/t/questions-about-nested-blocks-from-rhino/8955/3

Validation of changes:

Receive this commit: https://latest.speckle.dev/streams/3f895e614f/commits/ff0ab3fe69

@clairekuang clairekuang requested a review from AlanRynne February 9, 2024 12:27
Comment on lines +95 to +126
private void SetUserInfo(Base obj, ObjectAttributes attributes)
{
// set user strings
if (obj[UserStrings] is Base userStrings)
{
foreach (var member in userStrings.GetMembers(DynamicBaseMemberType.Dynamic))
{
attributes.SetUserString(member.Key, member.Value as string);
}
}

// set name or label
var name = obj["name"] as string ?? obj["label"] as string; // gridlines have a "label" prop instead of name?
if (name != null)
{
attributes.Name = name;
}

// set revit parameters as user strings
if (obj["parameters"] is Base parameters)
{
foreach (var member in parameters.GetMembers(DynamicBaseMemberType.Dynamic))
{
if (member.Value is Objects.BuiltElements.Revit.Parameter parameter)
{
var convertedParameter = ParameterToNative(parameter);
var paramName = $"{convertedParameter.Item1}({member.Key})";
attributes.SetUserString(paramName, convertedParameter.Item2);
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that these changes are replicated both in connector and converter, this could do with some SharedResources project in Rhino to hold all these types of shared implementations.

Since we're already looking at DI and DUI3, I don't think this is a blocker for this PR, but worth keeping in mind for the use-case

Copy link
Member Author

@clairekuang clairekuang Feb 9, 2024

Choose a reason for hiding this comment

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

yeah, there are some minor differences due to dependency issues, but since we are baking some objects in the connector and some in the converter, shared resources would be great to have

@AlanRynne AlanRynne merged commit 220e4fe into dev Feb 9, 2024
32 checks passed
@AlanRynne AlanRynne deleted the CNX-8670-Rhino-nested-instances-are-not-received-with-their-user-strings branch February 9, 2024 17:51
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