Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ObjectivismGH/ObjectClasses/GH_ObjectivismObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override IGH_GeometricGoo DuplicateGeometry()

public override string ToString()
{
return $"{Value.TypeName} object";
return Value.ToString();
}

public GH_ObjectivismObject(ObjectivismObject value)
Expand Down
47 changes: 47 additions & 0 deletions ObjectivismGH/ObjectClasses/ObjectProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,53 @@ public ObjectProperty(ObjectProperty other)
Data = other.Data.MapTree(DuplicateUtil);
}

public override string ToString()
{
if (Access == PropertyAccess.Item)
{
IGH_Goo first = Data.get_FirstItem(false);
if (first != null)
{
return first.ToString();
}
else
{
return "<null>";
}
}
else if (Access == PropertyAccess.List)
{
List<string> repr = new List<string>();
int n = Data.DataCount;
for (int i = 0; i < n; ++i)
{
repr.Add(Data.get_DataItem(i).ToString());
}
return "[" + string.Join(", ", repr) + "]";
}
else
{
List<string> repr = new List<string>();
foreach (GH_Path path in Data.Paths)
{
List<string> repr2 = new List<string>();
foreach (IGH_Goo data in Data[path])
{
repr2.Add(data.ToString());
}
repr.Add(" " + path.ToString() + ": [" + string.Join(", ", repr2) + "]");
}
if (repr.Count > 0)
{
return "{\n" + string.Join("\n", repr) + "\n}";
}
else
{
return "{}";
}
}
}

private IGH_Goo DeReferenceIfRequired(IGH_Goo goo)
{
if (goo is IGH_GeometricGoo geom)
Expand Down
23 changes: 23 additions & 0 deletions ObjectivismGH/ObjectClasses/ObjectivismObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Rhino.Render;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;

namespace Objectivism
Expand Down Expand Up @@ -102,6 +103,28 @@ public ObjectProperty GetProperty(string name)
}
}

private string indentString(string cont)
{
StringReader sr = new StringReader(cont);
List<string> r = new List<string>();
string line;
while ((line = sr.ReadLine()) != null) {
r.Add(" " + line);
}
return string.Join("\n", r);
}

public override string ToString()
{
List<string> repr = new List<string>();
repr.Add($"{TypeName} {{");
foreach ((string name, ObjectProperty prop) in properties)
{
repr.Add(indentString($"{name}: {prop.ToString()}"));
}
repr.Add("}");
return string.Join("\n", repr);
}

internal (ObjectivismObject obj, AccessInfo conflicts) AddOrChangeProperties(List<(string name, ObjectProperty newProperty)> changes) =>
AddOrChangeProperties(changes, this.TypeName);
Expand Down