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

Enable subclass of AllChildrenOfType set output Name #11195

Conversation

ZiyunShang
Copy link
Contributor

Purpose

Refer to DynamoDS/DynamoRevit#2641 .
I want to rename the output name of "Element Types"(will be "Element Classes"). But the AllChildrenOfType can't enable that change.
This hard Code makes its inheritance very inflexible.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • 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
  • All tests pass using the self-service CI.
  • 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

Reviewers

@mjkkirschner @QilongTang

FYIs

@Amoursol

[JsonConstructor]
protected AllChildrenOfType(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(outputName, inPorts, outPorts)
{
}

[JsonConstructor]
protected AllChildrenOfType(string value, IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(value, inPorts, outPorts)
Copy link
Member

Choose a reason for hiding this comment

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

hmm - I'm not sure how this constructor will ever be invoked by the deserializer - since the outputName field doesn't get serialized I don't think anything will ever be passed here - also naming it value is probably a good way to confuse json.net - since there might be some other property called value that is serialized.

The second issue I think needs to be tested, is since the output name is not serialized, what happens when you reopen a graph containing one of these nodes that was created with a different outputName, does it deserialize correctly with the right name?

Copy link
Member

Choose a reason for hiding this comment

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

If what I said makes no sense, give this a read about how json.net uses these json constructors:
https://stackoverflow.com/questions/23017716/json-net-how-to-deserialize-without-using-the-default-constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your reply, Michael. Here is a comparison of the old and new nodes in the script, and does not affect the function.
test
I will update this variable name to avoid Json confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @ZiyunShang - one comment: The term 'Class' is not familiar to the majority of our user base inside of Dynamo, where as "Type" is familiar coming from the Revit context. It may make it more difficult for users to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Amoursol , in RevitAPI, there is a type of Element called "ElementType", which is confusing with this "Type". And after discussing with my team, I think that 'Class' is more in line with the output of this node.

[JsonConstructor]
protected AllChildrenOfType(IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(outputName, inPorts, outPorts)
{
}

[JsonConstructor]
protected AllChildrenOfType(string outputName, IEnumerable<PortModel> inPorts, IEnumerable<PortModel> outPorts) : base(outputName, inPorts, outPorts)
Copy link
Member

@mjkkirschner mjkkirschner Oct 23, 2020

Choose a reason for hiding this comment

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

Hi @ZiyunShang I still don't think this makes much sense because outputName is not a serialized property! But I don't think it hurts anything to add this.

I think your screenshot shows exactly my concern - the same node is being loaded one way, and constructed from the library another.

I think you need to change the [JsonConstructor] of the derived class in DynamoRevit to pass "Class" as the output name and call your new constructor base that you added here to get nodes to load correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mjkkirschner Maybe I need to wait until DynamoCore Library has this change before updating.

@mjkkirschner
Copy link
Member

@QilongTang any objections to merging this?

@QilongTang
Copy link
Contributor

@QilongTang any objections to merging this?

not really go for it.

@mjkkirschner mjkkirschner merged commit b85c6da into DynamoDS:master Nov 4, 2020
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