-
Notifications
You must be signed in to change notification settings - Fork 177
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
bug(rhino): fixes missing user strings on nested instances when receiving #3170
Conversation
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); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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