Skip to content

Commit

Permalink
fix(rhino): various bugs when receiving (#2898)
Browse files Browse the repository at this point in the history
* fixes stored meshes when re-receiving the same commit with different settings

* fixes null parameter values

* no longer treats model collections as convertable

* Update ConnectorBindingsRhino.Receive.cs
  • Loading branch information
clairekuang authored Sep 7, 2023
1 parent 7e51efd commit 46321b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ public override async Task<StreamState> ReceiveStream(StreamState state, Progres
converter.ReceiveMode = state.ReceiveMode;

// set converter settings
bool settingsChanged = CurrentSettings != state.Settings;
CurrentSettings = state.Settings;
var settings = GetSettingsDict(CurrentSettings);
converter.SetConverterSettings(settings);

Commit commit = await ConnectorHelpers.GetCommitFromState(state, progress.CancellationToken);
state.LastCommit = commit;

if (SelectedReceiveCommit != commit.id)
if (SelectedReceiveCommit != commit.id || settingsChanged) // clear storage if receiving a new commit, or if settings have changed!!
{
ClearStorage();
SelectedReceiveCommit = commit.id;
Expand All @@ -69,7 +70,6 @@ public override async Task<StreamState> ReceiveStream(StreamState state, Progres
() =>
{
RhinoDoc.ActiveDoc.Notes += "%%%" + commitLayerName; // give converter a way to access commit layer info

// create preview objects if they don't already exist
if (Preview.Count == 0)
{
Expand Down Expand Up @@ -335,7 +335,7 @@ ApplicationObject CreateApplicationObject(Base current, string containerId)
ApplicationObject NewAppObj()
{
var speckleType = current.speckle_type
.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)
.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
.LastOrDefault();

return new ApplicationObject(current.id, speckleType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ namespace Objects.Converter.RhinoGh;

public partial class ConverterRhinoGh
{
// parameters
public Tuple<string, string> ParameterToNative(RV.Parameter parameter)
{
var name = parameter.name;
var val = parameter.value?.ToString() ?? string.Empty;
return new Tuple<string, string>(name, val);
}

// views
public View3D ViewToSpeckle(ViewInfo view)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Objects.Converter.RhinoGh;

public partial class ConverterRhinoGh
{
// display, render, and parameters
// display, render
public RH.ObjectAttributes DisplayStyleToNative(DisplayStyle display)
{
var attributes = new RH.ObjectAttributes();
Expand Down Expand Up @@ -241,13 +241,6 @@ public Other.RenderMaterial RenderMaterialToSpeckle(Rhino.Render.RenderMaterial
return renderMaterial;
}

public Tuple<string, string> ParameterToNative(Objects.BuiltElements.Revit.Parameter parameter)
{
var name = parameter.name;
var val = parameter.value.ToString();
return new Tuple<string, string>(name, val);
}

// hatch
public Hatch[] HatchToNative(Other.Hatch hatch)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ public bool CanConvertToNative(Base @object)
#else
// This types are not supported in GH!
case Pointcloud _:
case Collection _:
case ModelCurve _:
case DirectShape _:
case View3D _:
Expand All @@ -679,7 +678,9 @@ public bool CanConvertToNative(Base @object)
case Level _:
case Text _:
case Dimension _:
case Collection c when !c.collectionType.ToLower().Contains("model"):
return true;

#endif

default:
Expand Down

0 comments on commit 46321b3

Please sign in to comment.