Skip to content

Commit

Permalink
7.2 Deployment (#1483)
Browse files Browse the repository at this point in the history
  • Loading branch information
adecler authored Jun 20, 2024
2 parents 0f5798f + c603b10 commit a792b7f
Show file tree
Hide file tree
Showing 41 changed files with 1,160 additions and 545 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ bld/
*.suo
*.user
.vs/
.idea/
.idea/
**/launchSettings.json
2 changes: 1 addition & 1 deletion Revit_Adapter/Revit_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Adapter.Revit</RootNamespace>
<FileVersion>7.1.0.0</FileVersion>
<FileVersion>7.2.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
168 changes: 98 additions & 70 deletions Revit_Core_Adapter/CRUD/Read.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Revit_Core_Adapter/Revit_Core_Adapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Authors>BHoM</Authors>
<Copyright>Copyright © https://github.com/BHoM</Copyright>
<RootNamespace>BH.Revit.Adapter.Core</RootNamespace>
<FileVersion>7.1.0.0</FileVersion>
<FileVersion>7.2.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
48 changes: 25 additions & 23 deletions Revit_Core_Engine/Compute/SplitRequestTreeByLinks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ public static partial class Compute
[Description("Decomposes a tree created by a set of nested ILogicalRequests into a dictionary of Revit documents (both host and linked) and the IRequests relevant to them, which in total represents the same request as the original IRequest.")]
[Input("request", "An IRequest to be split into a dictionary of Revit documents and the IRequests relevant to them.")]
[Input("document", "Host document to be used as the basis of the splitting routine.")]
[Output("splitRequests", "A dictionary of Revit documents (both host and linked) and the IRequests relevant to them, which in total represents the same request as the input IRequest.")]
public static Dictionary<Document, IRequest> SplitRequestTreeByLinks(this IRequest request, Document document)
[Output("splitRequests", "A dictionary of elementIds representing Revit documents (both host as -1 and linked as link Id) and the IRequests relevant to them, which in total represents the same request as the input IRequest.")]
public static Dictionary<ElementId, IRequest> SplitRequestTreeByLinks(this IRequest request, Document document)
{

Dictionary<Document, IRequest> requestsByLinks = new Dictionary<Document, IRequest>();
Dictionary<ElementId, IRequest> requestsByLinks = new Dictionary<ElementId, IRequest>();
List<IRequest> splitPerDoc = request.SplitRequestTreeByType(typeof(FilterByLink));
foreach (IRequest splitRequest in splitPerDoc)
{
Expand All @@ -62,7 +61,7 @@ public static Dictionary<Document, IRequest> SplitRequestTreeByLinks(this IReque
/**** Private Methods ****/
/***************************************************/

private static bool TryOrganizeByLink(this IRequest request, Document document, Dictionary<Document, IRequest> requestsByLinks)
private static bool TryOrganizeByLink(this IRequest request, Document document, Dictionary<ElementId, IRequest> requestsByLinks)
{
if (request == null)
return false;
Expand All @@ -78,49 +77,55 @@ private static bool TryOrganizeByLink(this IRequest request, Document document,
List<IRequest> linkRequests = request.AllRequestsOfType(typeof(FilterByLink));
if (linkRequests.Count == 0)
{
requestsByLinks.AddRequestByLink(request, document);
requestsByLinks.AddRequestByLink(request, new ElementId(-1));
return true;
}
else if (linkRequests.Count == 1)
{
FilterByLink linkRequest = (FilterByLink)linkRequests[0];
List<ElementId> linkInstanceIds = document.ElementIdsOfLinkInstances(linkRequest.LinkName, linkRequest.CaseSensitive);

if (linkInstanceIds.Count == 1)
if (linkInstanceIds.Count == 0)
{
BH.Engine.Base.Compute.RecordError($"Active Revit document does not contain links with neither name nor path nor ElementId equal to {linkRequest.LinkName}.");
return false;
}
else if (linkInstanceIds.Count > 1)
BH.Engine.Base.Compute.RecordWarning($"There is more than one link document named {linkRequest.LinkName} - elements will be pulled from all unique instances of the links." +
$"\nPlease use full link path or its ElementId instead of link name to pull specifically from a chosen instance.");

foreach (ElementId linkInstanceId in linkInstanceIds)
{
request.RemoveSubRequest(linkRequest);
request = request.SimplifyRequestTree();
requestsByLinks.AddRequestByLink(request, ((RevitLinkInstance)document.GetElement(linkInstanceIds[0])).GetLinkDocument());
return true;
requestsByLinks.AddRequestByLink(request, linkInstanceId);
}
else if (linkInstanceIds.Count == 0)
BH.Engine.Base.Compute.RecordError($"Active Revit document does not contain links with neither name nor path nor ElementId equal to {linkRequest.LinkName}.");
else
BH.Engine.Base.Compute.RecordError($"There is more than one link document named {linkRequest.LinkName} - please use full link path or its ElementId instead of link name to pull.");
}

return false;
return true;
}
else
return false;
}

/***************************************************/

private static void AddRequestByLink(this Dictionary<Document, IRequest> requestsByLinks, IRequest request, Document document)
private static void AddRequestByLink(this Dictionary<ElementId, IRequest> requestsByLinks, IRequest request, ElementId linkId)
{
if (requestsByLinks.ContainsKey(document))
if (requestsByLinks.ContainsKey(linkId))
{
IRequest requestByLink = requestsByLinks[document];
IRequest requestByLink = requestsByLinks[linkId];
if (requestByLink is LogicalOrFilter)
((LogicalOrRequest)requestByLink).Requests.Add(request);
else
{
LogicalOrRequest newHead = new LogicalOrRequest();
newHead.Requests.Add(requestByLink);
newHead.Requests.Add(request);
requestsByLinks[document] = newHead;
requestsByLinks[linkId] = newHead;
}
}
else
requestsByLinks[document] = request;
requestsByLinks[linkId] = request;
}

/***************************************************/
Expand Down Expand Up @@ -208,6 +213,3 @@ private static bool IsValidToOrganize(this IRequest request)
/***************************************************/
}
}



84 changes: 38 additions & 46 deletions Revit_Core_Engine/Convert/Facade/FromRevit/CurtainWall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,7 @@ public static partial class Convert
[Output("curtainWall", "BH.oM.Facade.Elements.CurtainWall resulting from converting the input Revit Wall.")]
public static CurtainWall CurtainWallFromRevit(this Wall wall, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
if (wall == null)
return null;

settings = settings.DefaultIfNull();

CurtainWall bHoMCurtainWall = refObjects.GetValue<CurtainWall>(wall.Id);
if (bHoMCurtainWall != null)
return bHoMCurtainWall;

if (wall.StackedWallOwnerId != null && wall.StackedWallOwnerId != ElementId.InvalidElementId)
return null;

IEnumerable<oM.Facade.Elements.Opening> curtainPanels = wall.CurtainGrid.FacadeCurtainPanels(wall.Document, settings, refObjects);

if (curtainPanels == null || !curtainPanels.Any())
BH.Engine.Base.Compute.RecordError(String.Format("Processing of panels of Revit curtain wall failed. BHoM curtain wall without location has been returned. Revit ElementId: {0}", wall.Id.IntegerValue));

// Get external edges of whole curtain wall
List<FrameEdge> allEdges = curtainPanels.SelectMany(x => x.Edges).ToList();
List<FrameEdge> extEdges = allEdges.Distinct().Where(x => allEdges.Count(y => x.ElementId() == y.ElementId()) == 1).ToList();

bHoMCurtainWall = new CurtainWall { ExternalEdges = extEdges, Openings = curtainPanels.ToList(), Name = wall.WallType.Name };

bHoMCurtainWall.Name = wall.FamilyTypeFullName();

//Set identifiers, parameters & custom data
bHoMCurtainWall.SetIdentifiers(wall);
bHoMCurtainWall.CopyParameters(wall, settings.MappingSettings);
bHoMCurtainWall.SetProperties(wall, settings.MappingSettings);

refObjects.AddOrReplace(wall.Id, bHoMCurtainWall);

return bHoMCurtainWall;
return ((HostObject)wall).CurtainWallFromRevit(settings, refObjects);
}

/***************************************************/
Expand All @@ -97,40 +65,64 @@ public static CurtainWall CurtainWallFromRevit(this Wall wall, RevitSettings set
[Output("curtainWall", "BH.oM.Facade.Elements.CurtainWall resulting from converting the input Revit CurtainSystem.")]
public static CurtainWall CurtainWallFromRevit(this CurtainSystem system, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
if (system == null)
return ((HostObject)system).CurtainWallFromRevit(settings, refObjects);
}


/***************************************************/
/**** Private Methods ****/
/***************************************************/

private static CurtainWall CurtainWallFromRevit(this HostObject element, RevitSettings settings = null, Dictionary<string, List<IBHoMObject>> refObjects = null)
{
if (element == null)
return null;

settings = settings.DefaultIfNull();

CurtainWall bHoMCurtainWall = refObjects.GetValue<CurtainWall>(system.Id);
CurtainWall bHoMCurtainWall = refObjects.GetValue<CurtainWall>(element.Id);
if (bHoMCurtainWall != null)
return bHoMCurtainWall;

IEnumerable<oM.Facade.Elements.Opening> curtainPanels = system.ICurtainGrids().SelectMany(x => x.FacadeCurtainPanels(system.Document, settings, refObjects)).ToList();
IEnumerable<oM.Facade.Elements.Opening> curtainPanels = element.FacadeCurtainPanels(settings, refObjects);

if (curtainPanels == null || !curtainPanels.Any())
BH.Engine.Base.Compute.RecordError(String.Format("Processing of panels of Revit curtain wall failed. BHoM curtain wall without location has been returned. Revit ElementId: {0}", system.Id.IntegerValue));
BH.Engine.Base.Compute.RecordError($"Processing of panels of a Revit curtain wall failed. BHoM curtain wall without location has been returned. Revit ElementId: {element.Id.IntegerValue}");

// Unify edges
double sqTol = settings.DistanceTolerance * settings.DistanceTolerance;
List<(FrameEdge, BH.oM.Geometry.Point)> edges = new List<(FrameEdge, BH.oM.Geometry.Point)>();
foreach (oM.Facade.Elements.Opening panel in curtainPanels)
{
for (int i = 0; i < panel.Edges.Count; i++)
{
FrameEdge edge = panel.Edges[i];
BH.oM.Geometry.Point midPoint = edge.Curve.IPointAtParameter(0.5);

FrameEdge existing = edges.FirstOrDefault(x => x.Item2.SquareDistance(midPoint) <= sqTol).Item1;
if (existing != null)
panel.Edges[i] = existing;
else
edges.Add((edge, midPoint));
}
}

// Get external edges of whole curtain wall
List<FrameEdge> allEdges = curtainPanels.SelectMany(x => x.Edges).ToList();
List<FrameEdge> extEdges = allEdges.Distinct().Where(x => allEdges.Count(y => x == y) == 1).ToList();

bHoMCurtainWall = new CurtainWall { ExternalEdges = extEdges, Openings = curtainPanels.ToList(), Name = system.FamilyTypeFullName() };
bHoMCurtainWall = new CurtainWall { ExternalEdges = extEdges, Openings = curtainPanels.ToList(), Name = element.FamilyTypeFullName() };

//Set identifiers, parameters & custom data
bHoMCurtainWall.SetIdentifiers(system);
bHoMCurtainWall.CopyParameters(system, settings.MappingSettings);
bHoMCurtainWall.SetProperties(system, settings.MappingSettings);
bHoMCurtainWall.SetIdentifiers(element);
bHoMCurtainWall.CopyParameters(element, settings.MappingSettings);
bHoMCurtainWall.SetProperties(element, settings.MappingSettings);

refObjects.AddOrReplace(system.Id, bHoMCurtainWall);
refObjects.AddOrReplace(element.Id, bHoMCurtainWall);

return bHoMCurtainWall;
}

/***************************************************/
}
}




Loading

0 comments on commit a792b7f

Please sign in to comment.