|
@@ -77,7 +77,7 @@ namespace SAGA.MBI.ToolsData
|
|
|
private static void RebuildCloudData(CalcContext baseContext)
|
|
|
{
|
|
|
baseContext.OpenDocument();
|
|
|
- var doc = baseContext.RevitDoc;
|
|
|
+ var doc = baseContext.RevitDoc;
|
|
|
try
|
|
|
{
|
|
|
JObject jobject = new JObject();
|
|
@@ -94,14 +94,16 @@ namespace SAGA.MBI.ToolsData
|
|
|
{
|
|
|
string equipid = mode.Id;
|
|
|
string spaceId = GetMSpace(doc, mode.BimID, baseContext.MSpaces.ToList());
|
|
|
- if (spaceId.IsNullOrEmpty()) continue;
|
|
|
+ if (spaceId.IsNotNullEmpty())
|
|
|
+ {
|
|
|
+ JObject jitem = new JObject();
|
|
|
+ jitem.Add("from_id", equipid);
|
|
|
+ jitem.Add("to_id", spaceId);
|
|
|
+ jitem.Add("graph_id", graphid);
|
|
|
+ jitem.Add("rel_type", reltyp);
|
|
|
+ jcriterias.Add(jitem);
|
|
|
+ };
|
|
|
|
|
|
- JObject jitem = new JObject();
|
|
|
- jitem.Add("from_id", equipid);
|
|
|
- jitem.Add("to_id", spaceId);
|
|
|
- jitem.Add("graph_id", graphid);
|
|
|
- jitem.Add("rel_type", reltyp);
|
|
|
- jcriterias.Add(jitem);
|
|
|
JObject deleteItem = new JObject();
|
|
|
deleteItem.Add("from_id", equipid);
|
|
|
deleteItem.Add("graph_id", graphid);
|
|
@@ -112,13 +114,16 @@ namespace SAGA.MBI.ToolsData
|
|
|
{
|
|
|
string equipid = mode.Id;
|
|
|
string spaceId = GetMSpace(doc, mode.BimID, baseContext.MSpaces.ToList());
|
|
|
- if (spaceId.IsNullOrEmpty()) continue;
|
|
|
- JObject jitem = new JObject();
|
|
|
- jitem.Add("from_id", equipid);
|
|
|
- jitem.Add("to_id", spaceId);
|
|
|
- jitem.Add("graph_id", graphid);
|
|
|
- jitem.Add("rel_type", reltyp);
|
|
|
- jcriterias.Add(jitem);
|
|
|
+ if (spaceId.IsNotNullEmpty())
|
|
|
+ {
|
|
|
+ JObject jitem = new JObject();
|
|
|
+ jitem.Add("from_id", equipid);
|
|
|
+ jitem.Add("to_id", spaceId);
|
|
|
+ jitem.Add("graph_id", graphid);
|
|
|
+ jitem.Add("rel_type", reltyp);
|
|
|
+ jcriterias.Add(jitem);
|
|
|
+ }
|
|
|
+
|
|
|
JObject deleteItem = new JObject();
|
|
|
deleteItem.Add("from_id", equipid);
|
|
|
deleteItem.Add("graph_id", graphid);
|
|
@@ -129,13 +134,13 @@ namespace SAGA.MBI.ToolsData
|
|
|
#region 删除
|
|
|
JObject deleteJobject = new JObject();
|
|
|
deleteJobject.Add("criterias", deleteCriterias);
|
|
|
- RelationRequest.DeleteRelation(deleteJobject);
|
|
|
+ RelationRequest.DeleteRelation(deleteJobject);
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
jobject.Add("criterias", jcriterias);
|
|
|
RelationRequest.AddRelation(jobject);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
@@ -146,10 +151,10 @@ namespace SAGA.MBI.ToolsData
|
|
|
{
|
|
|
baseContext.CloseDocument();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- private static string GetMSpace(Document doc,string bimid,List<MISpace> spaces)
|
|
|
+ private static string GetMSpace(Document doc, string bimid, List<MISpace> spaces)
|
|
|
{
|
|
|
FamilyInstance fi = doc.GetElement(bimid.GetBIMID()) as FamilyInstance;
|
|
|
if (fi == null) return null;
|
|
@@ -157,6 +162,7 @@ namespace SAGA.MBI.ToolsData
|
|
|
if (space == null) return null;
|
|
|
var spaceid = space.GetCloudBIMId();
|
|
|
var mspace = spaces.FirstOrDefault(t => t.BimID == spaceid);
|
|
|
+ //如果找不到空间,就创建空间
|
|
|
if (mspace == null)
|
|
|
{
|
|
|
mspace = DalSpace.GetSpace(space);
|
|
@@ -165,6 +171,6 @@ namespace SAGA.MBI.ToolsData
|
|
|
}
|
|
|
return mspace?.Id;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|