From 9770b3e31712268da00a7dd6d26e3dcf3e1e9272 Mon Sep 17 00:00:00 2001 From: Kalle Thorsager Date: Tue, 31 Mar 2020 09:44:51 +0100 Subject: [PATCH 1/5] Add the call to BHoMGroup --- Robot_Adapter/CRUD/Create/Create.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Robot_Adapter/CRUD/Create/Create.cs b/Robot_Adapter/CRUD/Create/Create.cs index 508f0939..01d89035 100644 --- a/Robot_Adapter/CRUD/Create/Create.cs +++ b/Robot_Adapter/CRUD/Create/Create.cs @@ -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 { @@ -144,6 +145,11 @@ protected override bool ICreate(IEnumerable objects, ActionConfig actionCo { success = CreateCollection(objects as IEnumerable); } + + if (objects.First() is IBHoMGroup) + { + success = CreateCollection(objects as dynamic); + } } UpdateView(); From ae4a85a08c31c1a342d00281fe32dd3cd83f4982 Mon Sep 17 00:00:00 2001 From: Kalle Thorsager Date: Tue, 31 Mar 2020 09:45:04 +0100 Subject: [PATCH 2/5] Need name warning --- Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs index 2040ebed..afed4b90 100644 --- a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs +++ b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs @@ -42,6 +42,13 @@ private bool CreateCollection(IEnumerable> groups) wh { 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; From 1b0cfb895fa399d1f73b2ac352f85669dd329cf7 Mon Sep 17 00:00:00 2001 From: Kalle Thorsager Date: Tue, 31 Mar 2020 09:49:41 +0100 Subject: [PATCH 3/5] Adapter Id check --- Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs index afed4b90..f70967fc 100644 --- a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs +++ b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs @@ -40,6 +40,11 @@ private bool CreateCollection(IEnumerable> groups) wh RobotGroupServer rGroupServer = m_RobotApplication.Project.Structure.Groups; foreach (BHoMGroup 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."); + } + IRobotObjectType rType = Convert.RobotObjectType(typeof(T)); string members = group.Elements.Select(x => int.Parse(x.CustomData[AdapterIdName].ToString())).ToRobotSelectionString(); From 3e02c816aeef157c44d1a963115040ea0887a8c7 Mon Sep 17 00:00:00 2001 From: Kalle Thorsager Date: Tue, 31 Mar 2020 09:51:11 +0100 Subject: [PATCH 4/5] Important part --- Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs index f70967fc..728289ec 100644 --- a/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs +++ b/Robot_Adapter/CRUD/Create/Groups and Lists/Groups.cs @@ -43,6 +43,7 @@ private bool CreateCollection(IEnumerable> groups) wh 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)); From 567ec51aff3c7176e877c7b52d5afe424f07734a Mon Sep 17 00:00:00 2001 From: Kalle Thorsager Date: Thu, 9 Apr 2020 13:52:16 +0100 Subject: [PATCH 5/5] Update based on @isaknaslundbh comments --- Robot_Adapter/Convert/ToRobot/Groups and Lists/Group.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Robot_Adapter/Convert/ToRobot/Groups and Lists/Group.cs b/Robot_Adapter/Convert/ToRobot/Groups and Lists/Group.cs index cefe5d23..876ea293 100644 --- a/Robot_Adapter/Convert/ToRobot/Groups and Lists/Group.cs +++ b/Robot_Adapter/Convert/ToRobot/Groups and Lists/Group.cs @@ -40,7 +40,10 @@ public static IRobotObjectType RobotObjectType(Type type) { if (type == typeof(Bar)) return IRobotObjectType.I_OT_BAR; - + + else if (type == typeof(Panel)) + return IRobotObjectType.I_OT_PANEL; + else if (type == typeof(Node)) return IRobotObjectType.I_OT_NODE;