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

Call Create Group #343

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions Robot_Adapter/CRUD/Create/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using BH.oM.Reflection.Attributes;
using BH.Engine.Adapters.Robot;
using BH.oM.Adapter;
using BH.oM.Base;

namespace BH.Adapter.Robot
{
Expand Down Expand Up @@ -144,6 +145,11 @@ protected override bool ICreate<T>(IEnumerable<T> objects, ActionConfig actionCo
{
success = CreateCollection(objects as IEnumerable<BH.oM.Adapters.Robot.DesignGroup>);
}

if (objects.First() is IBHoMGroup)
{
success = CreateCollection(objects as dynamic);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No Idea how to get this to work otherwise

}
}

UpdateView();
Expand Down
13 changes: 13 additions & 0 deletions Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,21 @@ private bool CreateCollection<T>(IEnumerable<BH.oM.Base.BHoMGroup<T>> groups) wh
RobotGroupServer rGroupServer = m_RobotApplication.Project.Structure.Groups;
foreach (BHoMGroup<T> group in groups)
{
if (group.Elements.Any(x => !x.CustomData.ContainsKey(AdapterIdName)))
{
Engine.Reflection.Compute.RecordError("The Elements of the Group needs to be pre pushed/pulled to assign their Adapter Ids. The Group containing the element(s) with missing Ids have not been created.");
continue;
}

IRobotObjectType rType = Convert.RobotObjectType(typeof(T));
string members = group.Elements.Select(x => int.Parse(x.CustomData[AdapterIdName].ToString())).ToRobotSelectionString();

if (string.IsNullOrWhiteSpace(group.Name))
{
Engine.Reflection.Compute.RecordError("BHoMGroup must have a name to be pushed to Robot");
continue;
}

rGroupServer.Create(rType, group.Name, members);
}
return true;
Expand Down