speckle-sharp
speckle-sharp copied to clipboard
Rhino Converter returns null if ReceiveMode is Ignore or Create
Prerequisites
- [x] I read the contribution guidelines
- [x] I checked the documentation and found no answer.
- [x] I checked existing issues and found no similar issue.
- [x] I checked the community forum for related discussions and found no answer.
- [x] I'm reporting the issue to the correct repository (see also speckle-server, speckle-sharp, specklepy, speckle-docs, and others)
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
- Setup a Converter with
Converter.ReceiveMode = ReceiveMode.Create;
- Call
Converter.ConvertToNative()
on aBlockInstance
(successful) - Call
Converter.ConvertToNative()
on the sameBlockInstance
(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
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
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! 🙌🏼
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?
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.