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

Rhino Converter returns null if ReceiveMode is Ignore or Create #2985

Open
5 tasks done
Sticcia opened this issue Oct 9, 2023 · 3 comments
Open
5 tasks done

Rhino Converter returns null if ReceiveMode is Ignore or Create #2985

Sticcia opened this issue Oct 9, 2023 · 3 comments
Assignees
Labels
bug Something isn't working rhino

Comments

@Sticcia
Copy link

Sticcia commented Oct 9, 2023

Prerequisites

What package are you referring to?

Converters/ConverterRhinoGh

Describe the bug

We are setting up a Rhino Converter as follows:

Converter = new ConverterRhinoGh();
Converter.SetConverterSettings(MeshSettings.CurrentDoc);
Converter.SetContextDocument(doc);

Then using it to convert a a BlockInstance with Converter.ConvertToNative().
This works fine if we leave the ReceiveMode to the default value Update but we if we change it to Create or Ignore, Converter.ConvertToNative() returns null when converting the same object twice.
Added the following to the converter setup block above:

Converter.ReceiveMode = ReceiveMode.Create;
Converter.SetConverterSettings(ReceiveMode.Create);

With this configuration, Converter.ConvertToNative() returns the expected result on the first execution but null on all the following runs.
We need to convert the same object multiple times, with ReceiveMode.Update the object is replaced instead of creating a new object.
I tried replacing the id and applicationId on the BlockInstance, is there something else that needs to be done before calling Converter.ConvertToNative()?

To Reproduce

  1. Setup a Converter with Converter.ReceiveMode = ReceiveMode.Create;
  2. Call Converter.ConvertToNative() on a BlockInstance (successful)
  3. Call Converter.ConvertToNative() on the same BlockInstance (returns null)

Expected behavior

Converter.ConvertToNative() always returns the converted BlockInstance adding a new block to the Document every time.

System Info

  • Grasshopper: 7.32.23221.10241
  • Speckle.Core: 2.15.3
  • Speckle.Objects: 2.15.3

Failure Logs

No logs, also Converter.Report has no errors.

Proposed Solution

  • Add documentation and examples on how to change the converter receive mode
@Sticcia Sticcia added the bug Something isn't working label Oct 9, 2023
@AlanRynne
Copy link
Member

Hi @Sticcia!

Thanks for reporting this. It seems the converter is failing to create the same block definition over again, which causes the conversion to return null. On Update the converter will remove the block with the same name before adding the new one, but for create the behaviour is it will just fail.

You may be seeing a message like this on the Rhino command window
Screenshot 2023-10-10 at 11 58 45

Your use-case seems valid, and I'll admit it's not ideal to have things fail with no developer feedback so I'll talk to the team and try to come up with a way forward that is more intuitive and hopefully better documented! 🙌🏼

@AlanRynne AlanRynne self-assigned this Oct 10, 2023
@Sticcia
Copy link
Author

Sticcia commented Oct 10, 2023

Hi @AlanRynne,

Thanks for the quick support.
As I understand from your message you will add some form of logging of the error.
But how would we avoid hitting the error altogether?
Should we rename the BlockInstance or the Definition?
Would assigning a new ID be enough?

@AlanRynne
Copy link
Member

Renaming the definition to something else would do. Block definitions are matched by name from the RhinoDoc.ActiveDoc.InstanceDefinitions property, so you could try checking for that.

Ideally, this is something we should both fix so that create mode works and also clarify what should be the expectation for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rhino
Projects
No open projects
Status: 🧱 Blocked
Development

No branches or pull requests

2 participants